Re: [Flashcoders] AS2 and watch ...
Well, I use it sometimes as an update broadcast mecanism. Let's say I have some value objects floating around, and when I change a property on any of these, I use the watch to broadcast an event if for example the value has changed (by testing the newValue and the oldValue). It can be sometimes useful for some little and simple tasks that don't rely on a heavy process, like applying watches on global vars. Of course, you can do all of this without using the watch function, it's just a matter of design, choice and code comfort :) Julien Stephen Ford a écrit : How often do you use 'watch' in your applications?. It seems pretty powerful to me, and I've only just discovered it. Any thoughts on this. Cheers, Stephen.___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] AS2 and watch ...
Hello :) You can use watch with a MovieClip if you want create components with an event when you use the enabled property for example :) import mx.utils.Delegate ; class MyButton extends MovieClip { // o Constructor public function MyButton() { this.watch(enabled, Delegate.create(this, _changeEnabled) ; } // -o Init Broadcaster static public var INIT = AsBroadcaster.initialize(MyButton.prototype) ; // -o Public Methods public function up():Void { this.gotoAndStop(up) ; // first frame in your component this._alpha = 100 ; } public function disabled():Void { this.gotoAndStop(disabled) ; // the skin when you button is disabled this._alpha = 60 ; } // o Private Methods private methods _changeEnabled( id , oldValue, newValue) { trace(id : + id + , change + oldValue + to + newValue) ; if (newValue) { up() ; } else { disabled() ; } return newValue ; } private function onPress():Void { broadcastMessage(onClick, this) ; } } In flash you create a MovieClip symbole with AS2 class MyButton ! Try this : myButton.addListener(this) ; this.onClick = function ( who:MovieClip ) { trace(Click : + who) ; } Key.addListener(this) ; onKeyDown = function () { myButton.enabled = ! myButton.enabled ; // press key to test please :) } EKA+ :) 2006/7/6, Julien Vignali [EMAIL PROTECTED]: Well, I use it sometimes as an update broadcast mecanism. Let's say I have some value objects floating around, and when I change a property on any of these, I use the watch to broadcast an event if for example the value has changed (by testing the newValue and the oldValue). It can be sometimes useful for some little and simple tasks that don't rely on a heavy process, like applying watches on global vars. Of course, you can do all of this without using the watch function, it's just a matter of design, choice and code comfort :) Julien Stephen Ford a écrit : How often do you use 'watch' in your applications?. It seems pretty powerful to me, and I've only just discovered it. Any thoughts on this. Cheers, Stephen.___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS2 and watch ...
Or a simple linedraw, I've used the watch once with the tween class. var test_mc:MovieClip = this.createEmptyMovieClip(test_mc,1); test_mc.lineWidth = 0; var f:Function = function(prop, oldVal, newVal){ this.clear(); this.lineStyle(1,0x00); this.moveTo(0,25); this.lineTo(newVal,25); return newVal; } test_mc.watch(lineWidth,f); this.onEnterFrame = function(){ test_mc.lineWidth++; } Bernard -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens eka Verzonden: donderdag 6 juli 2006 9:40 Aan: Flashcoders mailing list Onderwerp: Re: [Flashcoders] AS2 and watch ... Hello :) You can use watch with a MovieClip if you want create components with an event when you use the enabled property for example :) import mx.utils.Delegate ; class MyButton extends MovieClip { // o Constructor public function MyButton() { this.watch(enabled, Delegate.create(this, _changeEnabled) ; } // -o Init Broadcaster static public var INIT = AsBroadcaster.initialize(MyButton.prototype) ; // -o Public Methods public function up():Void { this.gotoAndStop(up) ; // first frame in your component this._alpha = 100 ; } public function disabled():Void { this.gotoAndStop(disabled) ; // the skin when you button is disabled this._alpha = 60 ; } // o Private Methods private methods _changeEnabled( id , oldValue, newValue) { trace(id : + id + , change + oldValue + to + newValue) ; if (newValue) { up() ; } else { disabled() ; } return newValue ; } private function onPress():Void { broadcastMessage(onClick, this) ; } } In flash you create a MovieClip symbole with AS2 class MyButton ! Try this : myButton.addListener(this) ; this.onClick = function ( who:MovieClip ) { trace(Click : + who) ; } Key.addListener(this) ; onKeyDown = function () { myButton.enabled = ! myButton.enabled ; // press key to test please :) } EKA+ :) 2006/7/6, Julien Vignali [EMAIL PROTECTED]: Well, I use it sometimes as an update broadcast mecanism. Let's say I have some value objects floating around, and when I change a property on any of these, I use the watch to broadcast an event if for example the value has changed (by testing the newValue and the oldValue). It can be sometimes useful for some little and simple tasks that don't rely on a heavy process, like applying watches on global vars. Of course, you can do all of this without using the watch function, it's just a matter of design, choice and code comfort :) Julien Stephen Ford a écrit : How often do you use 'watch' in your applications?. It seems pretty powerful to me, and I've only just discovered it. Any thoughts on this. Cheers, Stephen.___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] AS2 and watch ...
I use 'watch' for exactly this purpose - drawing differences between an enabled and disabled MovieClip by watching the 'enabled' property. Cheers, Ian On 7/6/06, eka [EMAIL PROTECTED] wrote: Hello :) You can use watch with a MovieClip if you want create components with an event when you use the enabled property for example :) ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] AS2 and watch ...
Hi, i never used it, mostly because I wondered about performance stuff and found it to be making my code a bit obscure (although once it has reached black, it doesnt seem to go beyond). I don't mean to hijack this thread, but does any of you know whether the watch thing has a high performance cost or not? greetz Hans On 7/6/06, Ian Thomas [EMAIL PROTECTED] wrote: I use 'watch' for exactly this purpose - drawing differences between an enabled and disabled MovieClip by watching the 'enabled' property. Cheers, Ian On 7/6/06, eka [EMAIL PROTECTED] wrote: Hello :) You can use watch with a MovieClip if you want create components with an event when you use the enabled property for example :) ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] AS2 and watch ...
How often do you use 'watch' in your applications?. It seems pretty powerful to me, and I've only just discovered it. Any thoughts on this. Cheers, Stephen.___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] AS2 and watch ...
never...if i need to handle something when a property is updated then i usually broadcast an event. -- Forwarded message -- From: Stephen Ford [EMAIL PROTECTED] Date: Jul 5, 2006 6:27 PM Subject: [Flashcoders] AS2 and watch ... To: flashcoders flashcoders@chattyfig.figleaf.com How often do you use 'watch' in your applications?. It seems pretty powerful to me, and I've only just discovered it. Any thoughts on this. Cheers, Stephen.___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com