Please file a bug against Flex Builder at http://bugs.adobe.com/flex.
 
- Gordon

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of ben.clinkinbeard
Sent: Saturday, August 25, 2007 8:08 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Using [Event...] in Custom Classes



Event metadata is definitely not ignored in AS. Take a look at just
about any class in the framework and you'll see plenty [Event] tags.
It is there specifically to provide code hinting and support for
binding in MXML.

The problem here is that the code completion engine is offering class
constants that don't exist. They seem to be based on the constant
value, with some reformatting applied to convert to all uppercase and
inserting underscores anywhere there is a lowercase next to uppercase.
So MyEvtClass.FLY = "flyAway" appears in the completion list as
MyEvtClass.FLY_AWAY

Ben

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, Tony Alves <[EMAIL PROTECTED]> wrote:
>
> Jurgen,
> I believe the problem here is that you are setting up a metadata tag
on 
> your class in actionscript which is not needed and I think it was said

> that Event meta tags are ignored by the compiler in ActionScript 
> classes. Someone here can clear that up for us. I am not sure why,
but 
> it is only needed on MXML when setting up an event. Because you are 
> extending your class as an EventDispatcher, you only just need to 
> dispatch the event you are setting up.
> 
> package components
> {
> import flash.events.Event;
> public class MyClass extends EventDispatcher
> {
> public static const MY_EVENT:String = "myEvent";
> 
> private function myFunction():void
> {
> dispatchEvent(new Event(MyClass.MY_EVENT));
> }
> }
> }
> 
> THEN you can instantiate a MyClass variable and add an event listener:
> var mine:MyClass = new MyClass();
> mine.addEventListener(MyClass.MY_EVENT,someHandlerFunction);
> 
> The code assist is trying to show you the events on the event
dispatcher 
> and there really is just the two by default (activate and deactivate).
> Don't ask me why though. I always set up my Event types as constant 
> vars on my class, so I know I need to access them off my class name.
> This should work the same way for custom Events also.
> 
> Maybe an adobe flex expert can explain this better than I, but that is

> my understanding.
> 
> Regards,
> Tony
> 
> P.S. ( you were borrowing (some call it hijacking) another thread and
I 
> think it was getting missed.)
> 
> Jurgen Wrote: >>>>>>>>>>>>>>>>>>>>>>>
> There seems to be an issue using a custom class' event metadata in an
> addEventListener statement. Here is an example:
> 
> package com.example
> {
> 
> import flash.events.EventDispatcher;
> 
> [Event(name="myEvent", type="flash.events.Event")]
> 
> public class MyClass extends EventDispatcher
> {
> 
> // class code
> 
> private function myFunction():void
> {
> dispatchEvent(new Event("myEvent"));
> }
> 
> }
> 
> }
> 
> When using an instance of that class and creating an addEventListener
in
> code (not using it with MXML tags) Flex Builder's code assist lists
the
> event, but splits it apart and shows it as Event.MY_EVENT.
> 
> That of course throws a compiler error.
> 
> Is this by design and how would we work with an event in a custom
class
> using the [Event...] metatag?
> 
> I haven't checked to see if this is different with a custom event.
I'll
> check on that next, but I wanted to see if anyone has run into this
> problem before.
> 
> Thanks,
> 
> Jurgen
>



 

Reply via email to