array works fine, but get warning, as3
A prompt comes up to dismiss all or con开发者_运维百科tinue, but the The swf works perfectly. How do I correct this?
Thanks.Error
TypeError: Error #1010: A term is undefined and has no properties.
at testONE_fla::MainTimeline/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
LightUpSign 'array refers to instance names on stage'
import flash.utils.Timer;
import flash.events.TimerEvent;
var prog:Array = ["","prog1","prog2","prog3","prog4","prog5","prog6","prog7"];
var timer:Timer = new Timer(144);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
function onTimer(evt:TimerEvent):void {
var counting:uint = timer.currentCount % 8;
this[prog[counting]].visible = this[prog[counting]].visible ? false : true;
}
Web
When I execute the swf with HTML, there's no warning, and it works fine.My guess is that it's from having an empty string in your list of on-stage objects. If that's used for a pause in the blinking, try removing that empty string and using this as your onTimer event:
var prog:Array = ["prog1","prog2","prog3","prog4","prog5","prog6","prog7"];
function onTimer(evt:TimerEvent):void {
var counting:uint = timer.currentCount % 8;
if(counting == 0) return;
counting--;
this[prog[counting]].visible = !this[prog[counting]].visible;//no need for ternary operator
}
There's probably a cleaner way to do that but you get the idea. Let me know if that works.
精彩评论