Actionscript:
-
this.myVar = "I am a dynamic variable";
-
trace(this.myVar);
-
-
// trace(myVar) // will cause an error
This code will add dynamic untyped variables to the timeline. Although this example is pretty useless, it scratches the surface of an interesting topic.... by default all flash timeline code gets compiled into a giant dynamic document class that uses the undocumented addFrameScript() function. This means that all import statements on the timeline, even ones not on frame one become part of this large document class.
2 Comments
“all import statements on the timeline, even ones not on frame one become part of this large document class”
Just curious about this because in my experience (mostly As2 for player v8+) I’ve had to put the import statements in the same frame as the code that uses them. eg if I put the imports all in frame 1 then try to use the classes in frame 5 I get an error.
Do you find otherwise?
Well, in AS3 if your using the built in actionscript packages on the timeline you never need import statements. In As2 you needed import statements for things like the flash.filters… and yes, you would need to repeat those import statements on any frame you wanted to use flash.filters…. If your using a library/external package in AS3 you’ll need to repeat import statements from frame to frame… despite them all going into a large document class in the end… hope that clears it up, it’s a bit confusing.