You should create a new Event subclass--this is a lot easier to follow
and to maintain--but if you need a quick solution, you can use
DynamicEvent:

var event:DynamicEvent = new DynamicEvent("stuffHappened");
event.stuff = { stuffName : 'foo', stuffId : 123, stuffData : [1,2,3] };
event.otherStuff = "foo bar baz";
event.anythingAtAll = "whatever you like";

The DynamicEvent class descends from Event but is dynamic, just like
object, so you can dynamically add any properties you like. Again, this
is rarely a good idea in the long term: it's cleaner to define a custom
Event subclass. But it is possible.

-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: Mic <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: [flexcoders] passing data with custom event up displaylist
chain?
Date: Wed, 15 Oct 2008 07:30:35 -0000

is it true to say that a custom event can communicate nothing except
"an event has been sent", and that in order to send data, an event
subclass with public properties has to be coded? I have a tileList
deep within containers that must communicate its selectedItem to a
higher-level Canvas. I thought I might be able to somehow get the info
into the custom event before it is sent:

<mx:Metadata>
// [Event("updateStuff", type="flash.events.Event"))]
[Event("updateStuff", type="flash.events.MouseEvent")] 
</mx:Metadata>

mx:TileList id="myTileList" click = "updateStuff(event)"

private function updateStuff(e:Event):void{
var eventStuff:Event = new Event("updateStuff",true);
// put e data into eventStuff; - cannot do this :-)
this.dispatchEvent(eventStuff); 
}

I am presuming that it does not make sense to bubble the tileList
MouseClick up the chain and then have the higher-level Canvas listener
trap every mouse click and look for a currentTarget of "myTileList".

TIA, Mic.




 


Reply via email to