when using intervals, claim them as a property of the class so you can
reference them.

private var intID:Number

intID=setInterval(this,"myFunction",100);


private function myFunction(){
trace("my function called");
clearInterval(intID);
delete intID;
}

> Hi All - I am new to AS2 and OOP at large, but getting there (sort-of).
>
> Can anyone please advise as to why, in the following code, the trace
> statement in the function tweenColors in returning 'undefined' ?
>
> Why can't the tweenColors function (which is called with setInterval
> from another function) see the _oTransform object ?
>
> Also, feel free to comment if you can see anything I am doing wrong
> generally speaking from an AS2 point of view (as I said, I'm new to this
> and my head is still swimming).
>
> ----------------------------------------------------------------------------------------------
> class MenuPainter extends MovieClip {      // Variables
>      private var _mcTarget:MovieClip;     private var _cColor:Color;
> private var _oTransform:Object = {};     private var _nReds:Number
> = 255;     private var _nGreens:Number = 153;     private var
> _nBlues:Number = 0;     private var _nInterval:Number;      //
> Constructor     public function MenuPainter(mcTarget:MovieClip) {
>        _mcTarget = mcTarget;          initColor();     }      //
> Initialise first color of menu     private function
> initColor():Void {          _cColor = new Color(_mcTarget);
>  _oTransform.rb = _nReds;          _oTransform.gb = _nGreens;
>    _oTransform.bb = _nBlues;
> _cColor.setTransform(_oTransform);     }      // Color menu
> function called from buttons within menu movie itself     public
> function colorMenu(nReds:Number, nGreens:Number,
> nBlues:Number):Void {          trace("MenuPainter.colorMenu public
> function called, with arguments: "+nReds+" : "+nGreens+" :
> "+nBlues);          _nReds = nReds;          _nGreens = nGreens;
>       _nBlues = nBlues;            _nInterval =
> setInterval(tweenColors, 50);     }      public function
> tweenColors():Void {          trace(_oTransform);     }}
> ----------------------------------------------------------------------------------------------
> Thanks,
> Stephen Ford.
>
>  _______________________________________________
> [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

Reply via email to