In AS3 code you use the addEventListener() method to register an event
handler to receive a particular kind of event from a particular object:
 
package com.example.test
{
    public class Test extends VBox
    {
        // Constructor
        public function Test
        {
            super();
            addEventListener(FlexEvent.INITIALIZE, myHandler);
        }
 
        // Handler for "initialize" event
        private function myHandler():void
        {
            // Do something
        }
    }
}
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Ian Shafer
Sent: Wednesday, February 14, 2007 4:31 PM
To: [email protected]
Subject: [flexcoders] Handling initialized event with AS3 custom
component



Hello,

How do I handle an "initialized" event using an AS3 custom component?

In MXML it would be like this:

<mx:VBox initialize="myHandler">
<mx:Script><![CDATA[
private function myHandler():void {
// Do something
}
]]></mx:Script>
</mx:VBox>

My guess is that I can do something like this:

package com.example.test {
public class Test extends VBox {
private function initialize():void {
// Do something
}
}
}

But I can't find any documentation.

Thanks,

Ian



 

Reply via email to