Re: [Flashcoders] Movieclip event hook back to class instance?

2006-10-10 Thread Daniel Forslund|Lists


On 6 okt 2006, at 19.15, slangeberg wrote:

My problem is finding a way for the preloader class instance to  
tell when

the

movieclip reaches a certain frame or frame label


Actually, I prefer to set things up in an event-based model. I  
don't have
the code in front of me, but if you look at the EventDispatcher  
class, you
can have whatever movie is doing the loading to add listeners to  
that which

was loaded:

myClip.addEventListener( complete, Delegate.create( this,  
onComplete ) );


and inside of myClip, you'll need to:

this.dispatchEvent( {type:complete, target:this} );

Unfortunately this behavior is not built into MovieClip... Just some
ideas...

Scott


Thanks for the suggestions everyone!
I ended up setting up my own event handler without using listener  
functionality. It tags movieclips with an ID, which is passed to a  
central content manager, which in turn passes it to the correct class  
instance. Very simple and efficient with few lines of code. Perhaps  
not very elegant, but it works. :-)


Cheers,
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


RE: [Flashcoders] Movieclip event hook back to class instance?

2006-10-06 Thread Alain Rousseau
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


Re: [Flashcoders] Movieclip event hook back to class instance?

2006-10-06 Thread slangeberg

My problem is finding a way for the preloader class instance to tell when

the

movieclip reaches a certain frame or frame label


Actually, I prefer to set things up in an event-based model. I don't have
the code in front of me, but if you look at the EventDispatcher class, you
can have whatever movie is doing the loading to add listeners to that which
was loaded:

myClip.addEventListener( complete, Delegate.create( this, onComplete ) );

and inside of myClip, you'll need to:

this.dispatchEvent( {type:complete, target:this} );

Unfortunately this behavior is not built into MovieClip... Just some
ideas...

Scott

On 10/6/06, Daniel Forslund|Lists [EMAIL PROTECTED] wrote:


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





--

: : ) Scott
___
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