Athing needs a script block that imports the MyEvents.EnableChangedEvent.

 

Matt

 


From: [email protected] [mailto:[email protected]] On Behalf Of Emile Swain
Sent: Wednesday, February 01, 2006 6:38 AM
To: [email protected]
Subject: [flexcoders] flex 2 beta 1, custom event error

 

Hi,

 

I’ve been trying to implement a custom event but get the following compile time error.

 

Type annotation is not a compile-time constant:MyClassName

 

To be honest the whole thing was botched pretty quickly but given all the code is cut and paste from the help docs I’m stuck as to how to properly implement a custom event class.

 

 

In my application script tag

<![CDATA[

                                   

            import MyEvents.EnableChangedEvent;

            public function doit(eventObj:MyEvents.EnableChangedEvent)

            {

                        trace("yo = " + eventObj.isEnabled);

            }

                                   

]]>

 

 

Component event captured and told to pass event to doit() method above.

<Athing buttoned="doit(event)">

                                   

</Athing>

 

 

 

 

The Athing component

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Canvas xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" xmlns:yo:"MyEvents.EnableChangedEvent">

             <mx:Metadata>

                          [Event(name="buttoned", type="MyEvents.EnableChangedEvent")]

            </mx:Metadata>

            <mx:Button click="dispatchEvent(new MyEvents.EnableChangedEvent('buttoned'))"/>

            <mx:Text x="71" y="0" text="hello">

                       

            </mx:Text>

</mx:Canvas>

 

 

The my event class

// ActionScript file

package MyEvents

{

        import flash.events.Event;

 

        public class EnableChangedEvent extends Event

        {

                        static public BUTTONED:String = "buttoned";

            // Public constructor.

            public function EnableChangedEvent(type:String,  isEnabled:String="")

            {

                // Call the constructor of the superclass.

                super(type);

               

                // Set the new property.

                this.isEnabled = isEnabled;

            }

 

            // Define a public variable to hold the state of the enable property.

            public var isEnabled:String;

 

            // Override the inherited clone() method.

            override public function clone():Event {

                return new EnableChangedEvent(type, isEnabled);

            }

    }

}

 

 

 

 




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to