Hi,
I had this question in November, but the archive search cannot seem
to find it anymore...
Anyway, someone showed me how to cast an externally loaded SWF to a
class of my choosing - this allowed me to control the timeline of the
loaded clip, play, stop, etc.
Here is the code to cast the clip - Animation is the class I am
casting to, mHolder is the MovieClip that the SWF is loaded into:
function mySWFIsLoaded() {
//"Type" the loaded movieclip as an instance of Animation
mHolder.__proto__ = Animation.prototype;
mHolder.__constructor__ = Animation;
mHolder.__constructor__.apply(mHolder);
//Cast and store a reference to our animation so we can control it.
mPlayingAnim = Animation(mHolder);
mPlayingAnim.show();
mPlayingAnim.play();
//We listen for events from our Animation class.
mPlayingAnim.addEventListener("animend", Delegate.create(this,
playNext));
}
//End
Below is a cut down version of my Animation class (EventDispatcherForm
extends MovieClip and implements the EventDispatcher interface):
class Animation extends EventDispatcherForm
{
private var mPlaying:Boolean = false;
private var mLoop:Boolean = false;
function Animation ()
{
stop();
}
function play() {
mPlaying = true;
super.play();
}
function onEnterFrame() {
if(mPlaying) {
//If we are at the last frame, we tell any listeners...
if(_totalframes == _currentframe && false == mLoop) {
stop();
dispatchEvent( {type:"animend"} );
}
}
}
}
Hope this helps..
Glen
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com