  | |  | EventDispatcher 1 frame delay | EventDispatcher 1 frame delay
2004-02-17 - By Phil Chung
Back Maybe i 'm unclear on this, but i don 't know of any components that fire any sort of "init " event right when the component initializes (please correct me if i 'm wrong, because i very well might be). Your case seems to be unique in that you want to dispatch an event immediately upon initialization, and that 's why the listener isn 't defined yet when the event fires.
As Tatsuo pointed out, you need to be able to set up the listener before any events fire in order to capture that event, which you can 't do in the example you give without using onEnterFrame or setInterval.
Phil
Original Message:
>From: "Muzak " <p.ginneberge@(protected) >
>To: <flashcoders@(protected) >
>Subject: Re: [Flashcoders] EventDispatcher 1 frame delay
>Date: Tue, 17 Feb 2004 18:09:07 +0100
>It has nothing to do with implementation.
>
>Try the provided code. Create a component out of it.
>Put it on stage and add event listening.
>Won 't work...
>
>var handlerObject:Object = {};
>handlerObject.init= function(o) {
> trace( "init ");
>};
>basic_mc.addEventListener( "init ", handlerObject);
>
>The thing is, it works for the standard components (i know about the doLater method).
>I was just wondering if there 's any way of getting it to work without having to jump through hoops... guess not tho.
>
>The code i provided was just sample code. So i 'm not looking to fire an 'init ' event. The thing is that "no " event fires that runs
>in the first frame.
>
>So if you 'd do something like this:
>
>function BasicClass(){
> init();
>}
>function init(){
> draw();
>}
>function draw(){
> dispatchEvent({type: "draw "});
> size();
>}
>function size(){
> dispatchEvent({type: "size "});
>}
>
>none of these events will get dispatched.
>
>
>regards,
>Muzak
>
>
>-- -- Original Message -- --
>From: "Phil Chung " <phil@(protected) >
>To: <flashcoders@(protected) >
>Sent: Tuesday, February 17, 2004 4:54 PM
>Subject: re: [Flashcoders] EventDispatcher 1 frame delay
>
>
> > Muzak,
> >
> > What does the implementation code look like? Without seeing it, my immediate guess might be that since you have to set up a
>listener for the event, and the listener has to be set up after the class is initialized (AFAIK), the listener for this event isn 't
>in place when the initial event is dispatched via your init function (and that 's why it works when you run in after 1 frame).
> >
> > Phil
> >
> > Original Message:
>
>
>
>=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
>Supported by Fig Leaf Software
>=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
>Be sure to check the archives and the wiki:
> http://chattyfig.figleaf.com/
>=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
>http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:104493
>=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
>To unsubscribe send a blank e-mail to:
>Normal Mode: flashcoders-unsubscribe@(protected)
>Digest Mode: flashcoders-digest-unsubscrive@(protected)
>
>
>
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:104518
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |