Note that there are some explanatory texts on larger screens.

plurals
  1. POImporting a Package in Adobe Flash CS3 - Pointless Messages from "Access of Undefined Property" to none at all
    text
    copied!<p>I inherited a Flash CS3 legacy app and I am trying to refactor it a little. Eventually everything is supposed to be moved over to JS, but for now I would like to start working with what I have rather than attempting a complete rewrite. First I would like to install a little regression test. </p> <p>I am trying to setup the test in it's own package in order to reducing the seams it has with the original app. The app uses a lot of global variables and I wish not to interfere with those.</p> <p><strong>I can't get my regression test to work, since I can't figure out how to import the package properly.</strong> I am pretty certain that I am overseeing something obvious.</p> <p>My folderstructure looks as follows:</p> <pre><code>+- ascripts | +-- dependencies.as | +- root.fla +- initialize.as +- regressiontest.as </code></pre> <p><strong>root.fla</strong> is my one and only fla file. It just contains:</p> <pre><code>stop(); include "initialize.as" // Let's go outside! </code></pre> <p><strong>initialize.as</strong> contains all the magic. I am using this external file so I don't have to use the Flash IDE (since it is the worst IDE for coding). In there I have this:</p> <pre><code>// ... import fl.controls.ComboBox; include "ascripts/dependencies.as" var t = new regressiontest.TestRunner(); // 1. // ... </code></pre> <p>At <strong>1.</strong> I am trying to instantiate my regression test class. It can be found in the file <strong>regressiontest.as</strong> and looks like this:</p> <pre><code>package regressiontest { public class TestRunner { public function TestRunner() { trace('Hello'); // Actual Test Code Here ... } } } </code></pre> <p>So now when I go to flash and debug the movie using Strg+Shift+Enter, I get the following error messages. I tried every way I could think of, so here is an overview of what I achieved so far:</p> <pre><code>var t = new TestRunner(); </code></pre> <p><strong>Message</strong>: 1180: Call to a possibly undefined method TestRunner.</p> <pre><code>var t = new regressiontest.TestRunner(); </code></pre> <p><strong>Messages</strong>:</p> <p>root.as: 1120: Access of undefined property regressiontest.</p> <p>regressiontest.as: 5001: The name of package 'regressiontest' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. folder\regressiontest.as</p> <p>regressiontest.as: 5008: The name of definition 'TestRunner' does not reflect the location of this file. Please change the definition's name inside this file, or rename the file. folder\regressiontest.as</p> <pre><code>import regressiontest.TestRunner; var t = new TestRunner(); </code></pre> <p>root.as, Line 19: 1172: Definition regressiontest:TestRunner could not be found.</p> <p>root.as, Line 20: 1180: Call to a possibly undefined method TestRunner.</p> <p>What is most confusing to me is that Flash appears to be picking up the class definition in regressiontest.as somehow. When I put an obvious error, such as </p> <pre><code>public function TestRunner() { shoelace('Hello'); } </code></pre> <p>and use this to instantiate an object of the class:</p> <pre><code>var t:TestRunner = new regressiontest.TestRunner(); </code></pre> <p>then I get the <strong>Message</strong>:</p> <p>regressiontest.as: 1180: Call to a possibly undefined method shoelace.</p> <p>One might think now that the instantiation causes the problem. But when I set the code from shoelace to trace and leave the instantiation I get the following messages:</p> <p><strong>Messages</strong> Scene 1, Layer 'AS', Frame 1: 1046: Type was not found or was not a compile-time constant: TestRunner.</p> <p>root.as: 1120: Access of undefined property regressiontest.</p> <p>regressiontest.as: 5001: The name of package 'regressiontest' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. folder\regressiontest.as</p> <p>regressiontest.as: 5008: The name of definition 'TestRunner' does not reflect the location of this file. Please change the definition's name inside this file, or rename the file. folder\regressiontest.as</p> <p>I tried renaming the file within the package, I tried renaming the package, I tried importing with import regressiontest.*; and so on. What am I missing? </p> <ul> <li>What do I need to set my filename to? Does it need to match the PACKAGE NAME or the CLASS NAME? </li> <li>Am I missing some crazy camel case rule? </li> <li>Is there a maximum length to package names or something crazy like that? </li> <li>Did I forget to configure flash or the FLA file correctly? </li> <li>Am I missing some magic keyword?</li> <li>Might there be sideeffects from the includes or imports at the beginning of my script? </li> </ul> <p>I can reproduce these steps and I can provide the package via github. </p> <p>Thank you in advance, with clueless greetings from Heidelberg, Germany</p> <p>Johannes</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload