[flexcoders] Re: dispatchEvent import
Ooops, my bad. I didn't look at the example extensively and didn't note which component he was trying to use. --- In flexcoders@yahoogroups.com, turbo_vb timh...@... wrote: Hey Steve, The component that Marco is referring to is not a UIComponent, so it doesn't have a dispatchEvent() method. He'll have to change thel class to extend EventDispatcher. -TH --- In flexcoders@yahoogroups.com, valdhor valdhorlists@ wrote: The component itself has a dispatchEvent method. The this keyword is implicit in the call. It could have been written as this.dispatchEvent. --- In flexcoders@yahoogroups.com, Marco Catunda marco.catunda@ wrote: Hi, I'm learning swiz framework and stumble upon this code http://www.pastebin.org/307313 at http://www.briankotek.com/blog/files/swiz_10_rc_example/srcview/index.html My question is how could flex compiler understand the 'dispatchEvent' method in line 41 and 65? I haven't seen any explicit import of it. Cheers -- Marco Catunda
[flexcoders] Re: dispatchEvent import
Actually, you weren't wrong. It seems that if you use [Bindable], the compiler will allow dispatchEvent() in any class; in a black-box manner. -TH --- In flexcoders@yahoogroups.com, valdhor valdhorli...@... wrote: Ooops, my bad. I didn't look at the example extensively and didn't note which component he was trying to use. --- In flexcoders@yahoogroups.com, turbo_vb TimHoff@ wrote: Hey Steve, The component that Marco is referring to is not a UIComponent, so it doesn't have a dispatchEvent() method. He'll have to change thel class to extend EventDispatcher. -TH --- In flexcoders@yahoogroups.com, valdhor valdhorlists@ wrote: The component itself has a dispatchEvent method. The this keyword is implicit in the call. It could have been written as this.dispatchEvent. --- In flexcoders@yahoogroups.com, Marco Catunda marco.catunda@ wrote: Hi, I'm learning swiz framework and stumble upon this code http://www.pastebin.org/307313 at http://www.briankotek.com/blog/files/swiz_10_rc_example/srcview/index.html My question is how could flex compiler understand the 'dispatchEvent' method in line 41 and 65? I haven't seen any explicit import of it. Cheers -- Marco Catunda
Re: [flexcoders] Re: dispatchEvent import
Oh, sorry, me wrong... I didn't realize that if you put [Bindable] tag anywhere (not necessarily on class definition), then it will make compiler add extends EventDispatcher... how silly of me
[flexcoders] Re: dispatchEvent import
Hi Marco, That does look like a problem. The dispatchEvent() method is available for any UIComponent subclass or any class that extends EventDispatcher. So, if you're going to use [Bindable] properties in the presentation model, you would want to have the PM extend EventDispatcher: import flash.events.EventDispatcher; public class UserPresentationModel extends EventDispatcher { private var _currentState : String; [Bindable( currentStateChanged )] public function get currentState() : String { return _currentState; } public function set currentState( state : String ) : void { _currentState = state; dispatchEvent( new Event( currentStateChanged ) ); } } This will allow you to bind the property to a view. For events that you want to [Mediate], you would use the injected dispatcher: [Dispatcher] public var dispatcher:IEventDispatcher; dispatcher.dispatchEvent( new Event( myEvent ) ); -TH --- In flexcoders@yahoogroups.com, Marco Catunda marco.catu...@... wrote: Hi, I'm learning swiz framework and stumble upon this code http://www.pastebin.org/307313 at http://www.briankotek.com/blog/files/swiz_10_rc_example/srcview/index.ht\ ml My question is how could flex compiler understand the 'dispatchEvent' method in line 41 and 65? I haven't seen any explicit import of it. Cheers -- Marco Catunda
[flexcoders] Re: dispatchEvent import
The component itself has a dispatchEvent method. The this keyword is implicit in the call. It could have been written as this.dispatchEvent. --- In flexcoders@yahoogroups.com, Marco Catunda marco.catu...@... wrote: Hi, I'm learning swiz framework and stumble upon this code http://www.pastebin.org/307313 at http://www.briankotek.com/blog/files/swiz_10_rc_example/srcview/index.html My question is how could flex compiler understand the 'dispatchEvent' method in line 41 and 65? I haven't seen any explicit import of it. Cheers -- Marco Catunda
[flexcoders] Re: dispatchEvent import
Hey Steve, The component that Marco is referring to is not a UIComponent, so it doesn't have a dispatchEvent() method. He'll have to change thel class to extend EventDispatcher. -TH --- In flexcoders@yahoogroups.com, valdhor valdhorli...@... wrote: The component itself has a dispatchEvent method. The this keyword is implicit in the call. It could have been written as this.dispatchEvent. --- In flexcoders@yahoogroups.com, Marco Catunda marco.catunda@ wrote: Hi, I'm learning swiz framework and stumble upon this code http://www.pastebin.org/307313 at http://www.briankotek.com/blog/files/swiz_10_rc_example/srcview/index.html My question is how could flex compiler understand the 'dispatchEvent' method in line 41 and 65? I haven't seen any explicit import of it. Cheers -- Marco Catunda
Re: [flexcoders] Re: dispatchEvent import
If it ever worked that may be because of the patched compiler / preprocessor, and so all dispatchEvent calls were translated to what is marked as [Dispatcher]. Maybe it does the same as [Bindable] on class, or maybe like HaXe using directive. Otherwise - just a confusing piece of code... Well, you know, so far the only reasonable place to put metadata in AS3 was __go_to_definitionHelp, and that you don't have to write... :S
[flexcoders] Re: dispatchEvent import
The example does compile and the binding works; even when you remove the injected dispatcher. Kind of stumped on why this works in a class that doesn't extend EventDispatcher. -TH --- In flexcoders@yahoogroups.com, Oleg Sivokon olegsivo...@... wrote: If it ever worked that may be because of the patched compiler / preprocessor, and so all dispatchEvent calls were translated to what is marked as [Dispatcher]. Maybe it does the same as [Bindable] on class, or maybe like HaXe using directive. Otherwise - just a confusing piece of code... Well, you know, so far the only reasonable place to put metadata in AS3 was __go_to_definitionHelp, and that you don't have to write... :S
Re: [flexcoders] Re: dispatchEvent import
Yes, this component is neither UIComponent nor extend EventDispatcher and I don't have to change it to extend EventDispatcher because every things works well. For me it's so strange!! I don't know why. On 04/06/2010, at 18:24, turbo_vb wrote: Hey Steve, The component that Marco is referring to is not a UIComponent, so it doesn't have a dispatchEvent() method. He'll have to change thel class to extend EventDispatcher. -TH --- In flexcoders@yahoogroups.com, valdhor valdhorli...@... wrote: The component itself has a dispatchEvent method. The this keyword is implicit in the call. It could have been written as this.dispatchEvent. --- In flexcoders@yahoogroups.com, Marco Catunda marco.catunda@ wrote: Hi, I'm learning swiz framework and stumble upon this code http://www.pastebin.org/307313 at http://www.briankotek.com/blog/files/swiz_10_rc_example/srcview/index.html My question is how could flex compiler understand the 'dispatchEvent' method in line 41 and 65? I haven't seen any explicit import of it. Cheers -- Marco Catunda -- Marco Catunda
Re: [flexcoders] Re: dispatchEvent import
OK... dispatchEvent is an undocumented global function... test case: var ns:Namespace = new Namespace(); trace(ns::dispatchEvent); Another hack in AS3... well... I have couple of strong words about this, but these should be only spoken in private... crap :(