If your button in the custom class is broadcasting an event, say for an
example, and event called "changed", you can add an event listener in a
script tag in the main MXML. A snippet would be:
private function addListeners():void
{
myCustomClassInstance.addEventListener("changed", onChanged);
}
private function onChanged():void
{
currentState = "myOtherState";
}
However, if you class creates buttons, why not have those buttons
created with MXML instead of Actionscript?
There is a great Flex list on Yahoo! called Flexcoders which would be
more capable to answer this than this list.
Jason Merrill
Bank of America
GT&O L&LD Solutions Design & Development
eTools & Multimedia
Bank of America Flash Platform Developer Community
Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal GT&O Innovative Learning Blog & subscribe.
>>-----Original Message-----
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] On Behalf
>>Of Anthony Cintron
>>Sent: Friday, March 07, 2008 6:14 PM
>>To: [email protected]
>>Subject: [Flashcoders] Using States, MXML, Events, O' My
>>
>>I have a question about MXML and ActionScript and how they
>>communicate with each other. I'm working with the State tage
>>to change views. I have a Class called SpacePorter; it has 4
>>buttons that dispatchEvents( MyButton.BUTTON_CLICKED). Space
>>Porter is instantiated into my Home Class.
>>Home class is than created using mxml in my root Application.
>>Now, I want to be able with AS3 or MXML to subscribe to that
>>Broadcast so my State can change, depending on the button
>>that was clicked. I can't quite wrap my head around this with
>>my lack of MXML and ActionScript relations - especially with
>>the CDATA tags. I tried getting the button object through AS,
>>by doing:
>>homeView.button, but it seems as though i can't get to the
>>properties of an mxml (instantiated object) from a AS script
>>inside the script tag.
>>
>>I hope this makes some sense, if need be I can explain some
>>more. Could really use the help on this. This is great real
>>world attempt of me using Flex.
>>
>>Anthony C.
>>
>>--
>>_______________________________________________
>>Flashcoders mailing list
>>[email protected]
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders