I don't think the timing of frame scripts is really at the heart of your question. In the case of your code snippits above, you're getting into a question of class versus instance. Let's look at this line:
this["myCustomVar"] = "bla";
There, you've defined a new variable called myCustomVar
in the root timeline instance. An instance is a single thing which exists individually and can be customized. However, customizing one instance does NOT change the Class that originally defined it. Think of a widget factory: if you take a finished widget from the end of the assembly line and paint it red, that does not mean that the factory will now produce red widgets... you've just altered one widget instance that rolled off the end of the line. In order to make your factory produce red widgets, you'd need to alter the factory itself – or the Class definition. So, I assume you have a custom class written for MyMovieClip
? If not, you'd need to do this in MyMovieClip.as
:
package
{
import flash.display.MovieClip;
public class MyMovieClip extends MovieClip
{
public var myCustomVar:String = "";
public function MyMovieClip():void {
super();
}
}
}
Once you've modified the object's class definition to include your custom variable, then all new instances of that class will be constructed with that variable. Hope that helps.