View Full Version : is communication between two MXMLs possible?
actionScriptorz
05-14-2008, 02:38 PM
i'm trying to make 2 pages communicate each other similar to XSL's "parameter" property. I want to make it so that when i click something, the action will apply to not just the mxml that the "something" was click, but also apply to other mxml pages/components?
thanks in advance
dr_zeus
05-14-2008, 06:29 PM
Events are the natural way to communicate between components.
actionScriptorz
05-14-2008, 06:54 PM
thanks, i tried having an addEventListener in mxml file A
item.addEventListener(ItemClickEvent.ITEM_CLICK, itemClickHandler);
and have the corresponding handler in mxml file B
private function itemClickHandler(event:ItemClickEvent):void
{
Alert.show("Getting click event");
}
its complaining because it cannot find the function itemClickHandler in mxml file A, how can i solve this? should i have the handler method in an as file instead and just have to refer to the script in mxml?
dr_zeus
05-14-2008, 08:37 PM
itemClickHandler is in the scope of B, so that certainly shouldn't be accessible in A.
Generally, its good to use a common parent container C as a mediator between A and B. Something happens in A, so A dispatches an event "somethingHappened". C is listening for A's event. When C receives that event, calls a function on B so that B can respond to whatever happened in B.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.