Mailing List
Home
Flash Pro
Extending Flash
Flash Macromedia Developer
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
EventDispatcher 1 frame delay

EventDispatcher 1 frame delay

2004-02-17       - By Muzak

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

Here 's some more code:

import mx.events.EventDispatcher;

class BasicClass extends MovieClip {
private var __width:Number;
private var __height:Number;
private var preview_mc:MovieClip;
//
private static var __eventInit = EventDispatcher.initialize(BasicClass.prototype);
var addEventListener:Function;
var removeEventListener:Function;
var dispatchEvent:Function;
//
function BasicClass() {
__width = _width;
__height = _height;
_xscale = _yscale=100;
init();
}

function init() {
createChildren();
}

function createChildren() {
draw();
}

function draw() {
dispatchEvent({type: "draw "});
size();
}

function size() {
preview_mc._width = __width;
preview_mc._height = __height;
dispatchEvent({type: "size "});
}

function setSize(w,h){
__width = w;
__height = h;
size();
}

function changeEvent() {
trace( "BasicClass ::: changeEvent ");
dispatchEvent({type: "change "});
}
}

In the FLA, code and component instance in first frame, nothing else.

var handlerObject:Object = {};
handlerObject.draw = function(o) {
trace( "handlerObject ::: draw ");
};
handlerObject.size = function(o) {
trace( "handlerObject ::: size ");
};
handlerObject.change = function(o) {
trace( "handlerObject ::: change ");
};
basic_mc.addEventListener( "draw ", handlerObject);
basic_mc.addEventListener( "size ", handlerObject);
basic_mc.addEventListener( "change ", handlerObject);
//
basic_mc.setSize(200,200);
basic_mc.changeEvent();


// trace output:
BasicClass ::: size
BasicClass ::: setSize
BasicClass ::: size
handlerObject ::: size
BasicClass ::: changeEvent
handlerObject ::: change


So, the 'size ' event only gets triggered when the setSize() method is called.
Maybe my way of saying that 'it takes a frame ' is not correct.
I just assumed that, since there 's a size event dispatched in the size method and i have a listener set up for it, I expected it to
work right away (as soon as the component initializes), which doesn 't seem to be the case.
I think what was unclear to me is when exactly listeners are being added.

Sorry if I 'm not making any sense. I 'm having a hard time explaining what 's in my head :(

Thanks for your time.

kind regards,
Muzak

-- -- Original Message -- --
From: "Tatsuo Kato " <studio@(protected) >
To: <flashcoders@(protected) >
Sent: Tuesday, February 17, 2004 7:59 PM
Subject: Re: [Flashcoders] EventDispatcher 1 frame delay


> hm, I still don 't get your point, Muzak. Neither does Phil, it seems.
>
> It doesn 't take a frame or an interval for an object initialized with
> mx.events.EventDispatcher to be able to dispatch an event.
> It only needs a fact that a listener is registered before dispatching.
>
> And it works for me wherever it 's written, frame1 of _root or the
> component or wherever.
> In order for it to work, it just needs a listener having been registered
> before dispatching.
>
> Cheers,
> --
> Tatsuo Kato
> http://tatsuokato.com
>



=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
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:104525
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)