View unanswered posts | View active topics



Reply to topic  [ 5 posts ] 
[SOLVED] [Event(...)] TAG not working? 
Author Message
Member

Joined: Wed Oct 31, 2012 8:46 pm
Posts: 4
Hi guys,

Id like to add a custom Event type to my class using:
Code:
[Event(name="complete",type="starling.events.Event")]


so i declare it after the imports and before the class definition in my code.
Then inside the class i use it like this:
Code:
this.addEventListener(Event.CHANGE, onChangeHandler);


Compilation throws error:
D:\DEV\.......\Menu.as(31): col: 35 Error: Access of possibly undefined property CHANGE through a reference with static type Class.

I read everywhere, that [Event(..)] tag support in FD is flaweless, but in my case the custom event type i added is not recognized.

Any ideas how to fix this?


Last edited by juice21 on Fri Nov 02, 2012 10:48 pm, edited 1 time in total.



Wed Oct 31, 2012 8:58 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Firstly, this tag [Event] is only an annotation to make code completion smarter, when you create a component dispatching custom events for instance - it doesn't have any other side effect (ie. nothing will work better or worse with or without it).

Secondly the error indicates a completely unrelated problem:
- it means that the class "starling.events.Event" (unlike "flash.events.Event") doesn't have any static property named "CHANGE",
- if you have a starling-based custom class where you want to dispatch a CHANGE event, you can just write:
Code:
// dispatcher
this.dispatchEvent(new Event("change"));
// listener
this.addEventListener(Event.CHANGE, onChangeHandler);


Fri Nov 02, 2012 9:56 pm
Profile WWW
Member

Joined: Wed Oct 31, 2012 8:46 pm
Posts: 4
Quote:
Firstly, this tag [Event] is only an annotation to make code completion smarter

Thank you, now i see the completion hint, and understand the purpose of the tag.

Regarding the second point, i understand how to add another event constant (by extending starling.events.Event class and adding it there), but what was strange is that after i DLoaded starling library (or was it FeathersUI? getting same errors there), initialized it and compiled it, it gave me many of those errors mentioned above. I had to manually go into each problematic starling class and change Event.CHANGE to "change" so that those errors would disappear and all compiled ok then. Weird.. i must have missed something. Im sure the Event class used was starling.events.Event (not extended Event class with additional "change" constant support), and so i thought that the [Event] tag actually dynamically adds such property to starling base Event class. My bad.


Fri Nov 02, 2012 10:45 pm
Profile
Member

Joined: Mon Jun 29, 2009 11:19 am
Posts: 2
Hi.

I've found a similar problem.
Several feathers components dispatch starling.events.Event.CHANGE. The trouble is that the starling Event doesn't have a CHANGE constant.

I've managed to partially solve the problem by extending those component classes and dispatching events with existing strings.

Some components don't like that though (ie. Slider). It doesn't seem to get skinned by the theme.

I thought it might be a case of having an older version of Starling....but thats not the case.


Fri Nov 09, 2012 1:59 pm
Profile
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
In the git repository, Starling's Event class does have a CHANGE const:
https://github.com/PrimaryFeather/Starl ... s/Event.as


Fri Nov 09, 2012 2:07 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.