I have a very simple MXML component with a custom event:

---------------------

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="400" height="300">
    <mx:Metadata>
        [Event("jump", type="MyNewEvent")]
    </mx:Metadata>
   
    <mx:Button x="10" y="10" label="Button"/>
</mx:Canvas>

--------------------

package
{
    import flash.events.Event ;

    public class MyNewEvent extends Event
    {
        public var data: String;
       
        public function MyNewEvent(eventType: String, d: String)
        {
            super(eventType);
            data = "">        }
       
        public override function clone(): Event
        {
            return new MyNewEvent(type, data);
        }
    }
}

---------------------------

And I try to use it in an application like this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute">
    <mx:Script>
        <![CDATA[
            private function onJump(event: MyNewEvent)
            {
                trace(event.data);
            }
        ]]>
    </mx:Script>
   
    <MyNewComp jump="onJump(event)"/>
</mx:Application>


When compiling, I get the error "Implicit coercion of a value with static type flash.events:Event to a possibly unrelated type MyNewEvent".  According to the docs, I should be able to declare "onJump" using the type "MyNewEvent".  If I change the type to "Event", it compiles ok.  At runtime, I can actually cast it to MyNewEvent and it works fine, so the right type is being passed.  It just looks like the code generator is not using the right type when creating the listener.

__._,_.___

--
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