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,0x000000);
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._______________________________________________
> > > [email protected]
> > > 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
> > >
> > _______________________________________________
> > [email protected]
> > 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
> >
>
_______________________________________________
[email protected]
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