flash - blinking movieclip with timer -


i trying make movieclip blink, blinks when hit something, create effect of game.i have hit test when hitted, caught called on object.the caught function of object make stop , start blink based on timer.my timer set on new timer(400); why object not blink? conditions seem correct.

if (hit.hittestobject(f.hit))     f.caught();       private function blinkinghandler(evt:timerevent):void     {          _canblink = true;         if (_canblink)         {             this.alpha = 0;             _canblink = false;             this.alpha = 100;             trace("blinking");         }     }     public function caught() : void     {            _blinktimer.start();           //removeeventlistener(event.enter_frame, loop);          //this.stop();     } 

first, i'm going assume have added event listener trigger blinkinghandler call when timer fires:

_blinktimer.addeventlistener(timerevent.timer, blinkinghandler); 

now, blinkinghandler have posted never hide object. alpha set 0, set 1 in same call, net result alpha not display @ 0. must set alpha 0, let few frames render, set 1 on next timer tick, , on. try this:

private function blinkinghandler(evt:timerevent):void {     if(_canblink) this.alpha = 1;     else this.alpha = 0;     _canblink = !_canblink; } 

you do:

visible = !visible; 

to toggle visibility on each timer tick.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -