Hi Dan,

I think that what you'll have to do is create your own event and dispatch it
using the EventDispatcher Class.

First you'll need to initialize your "outro" mc with event dispatcher

// in mc timeline's first frame
import mx.events.EventDispatcher;
var addEventListener:Function;
var removeEventListener:Function;
var dispatchEvent:Function;

EventDispatcher.initialize(this);

// further in the mc on chosen frame
this.dispatchEvent( {target:this, type:"onFrameLabel", label:"endOutro"});


Now all you need is a listener object for that event in your code :

import mx.utils.Delegate; // or whatever Delegate class you use - Proxy or
dynamicflash's Delegate
var listener:Object = new Object();
listener.onFrameLabel = Delegate.create(this, myActions);

outroMC.addEventListener("onFrameLabel", listener);

function myActions(evtObj:Object) {
        trace(evtObj.target+" Dispatched event "+evtObj.type+" at frame
label "+evtObj.label);
        // do whatever you want here 
        if (evtObj.label == "endOutro") {
                trace("end of outro");
        }
}


If you don't want to use the timeline you could use setInterval (or
setTimeout if you use Flash 8) to delay the event dispatching to a certain
amount of time.


HTH

Alain

-----Original Message-----
From: Daniel Forslund|Lists [mailto:[EMAIL PROTECTED] 
Sent: 6 octobre 2006 08:20
To: Flashcoders mailing list
Subject: [Flashcoders] Movieclip event hook back to class instance?

Hi all!

I have a (hopefully not too ignorant) question relating to movieclips
created on the fly.
Basically, I have a preloader class that is generic and reusable.  
It's called from whatever object that does dynamic loading of content and
then in turn invokes a movieclip from a passed symbol name(can be anything,
as long as a basic movieclip structure is followed). It all works great.

However, when the loading is done I want the dynamically created mc to play
an "outro" animation that is preanimated in the movieclip (as opposed to
animated via AS, that would be easy ;) ). My problem is finding a way for
the preloader class instance to tell when the movieclip reaches a certain
frame or frame label (and is done with the outro). I can't find a suitable
event to hook into? I guess I was looking for something like
"mc.onframelabel" to hook a function to, I guess that was naive. :)

Can I in some way create a hook myself, or do I have to create a watcher
object that checks each frame where the playhead is in my dynamic loader
movieclip? Would certainly work, but it's not very elegant. My goal is to
keep the preloader movieclip code-free.

Anyway, I hope I managed to describe the problem. Apologies for any
ignorance and any terms/keywords used out of context. I'm pretty new to more
advanced actionscript, but have many moons of general coding experience. :)

Many thanks in advance,
Dan
_______________________________________________
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


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.407 / Virus Database: 268.13.0/465 - Release Date: 2006-10-06
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.407 / Virus Database: 268.13.0/465 - Release Date: 2006-10-06
 

_______________________________________________
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

Reply via email to