Dynamic Timeline Vars

Actionscript:
  1. this.myVar = "I am a dynamic variable";
  2. trace(this.myVar);
  3.  
  4. // 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.

This entry was posted in timeline, variables and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Posted June 3, 2009 at 1:34 am | Permalink

    “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?

  2. Posted June 3, 2009 at 1:38 am | Permalink

    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.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*