private var myListener:Function;
private var releaseGaia:Function;
public var __count:Number=0;
public var __prevCount:Number=-1;
public function IndexPage()
{
super();
_alpha = 0;
myListener=Delegate.create(this, onBeforeTransitionIn);
releaseGaia= Gaia.api.beforeTransitionIn(myListener, true)
}
public function onBeforeTransitionIn(event:GaiaEvent):Void
{
MovieClip.prototype.scope=this;
// Initialise & check every movieclip on first frame
// before page transitions in....
MovieClip.prototype.onEnterFrame=function() {
//if (this._done) return; // comment this out to test fully
this.scope.__count++;
trace("MC initialising:"+this);
this._done=true;
this.scope.__prevCount=this.scope.__count;
}
// Flush away all enterframes once no more new movieclips are detected
this.onEnterFrame=function() {
if (__count==__prevCount) {
trace("FLUSHING!"+__count);
delete MovieClip.prototype.onEnterFrame;
releaseGaia();
delete this.onEnterFrame;
}
}
}
Does this work? Can I create more hijackable events such as when an external swf asset loads… or a certain frame within a timeline is reached and I want to dispatch a custom hijacckable event?
With such a script, it’ll be possible to to tell the designer to put all required assets on Frame 1 in the timeline…(some of which can be set alpha/visible to zero so the user doesn’t see it…and then handle a hijacked event to process all these clips on their first frame, then delete off the prototype enterframe.) By checking the name type of the movieclip and other parameters (eg. Instance Name on Stage: formfield_fname_$parameter1$parameter2 ), can simply rename the MC and hook up a class with this.name=this.name.split("__")[0], split $parameters, etc. then create new FormField(this, parameter1, parameter2), and voila …it’s already hooked up. No need to type any code in the timeline. No need to do any linkage class IDing on the library. What do you think of this technique?
Just need more hijacakable events to jam up the framework, perform the necessary actions, and release it again! Can I create my own? It’s a pity we don’t have a transition assetLoaded or subSection loaded event thingie as well.