Delaying actions to simulate a URC Macro
I'm using Flash to build a universal remote and could use some help simulating a timed Macro:
Example:
send command TV On
2 second delay
send command TV HDMI 1
2 second delay
send command AMP on
8 second delay
send command AMP Video 1
For the time being a movieclip with an on macro and an off macro makes sense to me.
I would like to have a frame labeled "on" formatted like so:
Object(parent).tv_1.tv_selected.gotoAndStop('on');
2 second delay
Object(parent).tv_2.tv_selected.gotoAndStop('on');
2 second delay
Object(parent).tv_3.tv_selected.gotoAndStop('on');
2 second delay
Object(parent).tv_4.tv_selected.gotoAndStop('on');
Likewise I will have a closing frame:
Object(parent).tv_1.tv_selected.gotoAndStop('off');
2 second delay
Object(parent).tv_2.tv_selected.gotoAndStop('off');
2 second delay
Object(parent).tv_3.tv_selected.gotoAndStop('off');
2 second delay
Object(parent).tv_4.tv_selected.gotoAndStop('off');
I'm sure there are a hundred ways to do this but this is what makes sense to me and my current level of AS3 skill.
Here's my existing code. I found it somewhere on the interweb. I've been using it on frames and things are starting to get ridiculous. I need help cleaning it up.
stop();
var tv_static_tv_1:Timer = new Timer(100, 1);//create a timer
//10000 equals 10*1000 because 1000 represents 1 second
//1 means it will happen only once
tv_static_tv_1.start();//start the timer
tv_static_tv_1.addEventListener(TimerEvent.TIMER_COMPLETE, tv_static_on_tv_1);//add a listener which means we'll know when the timer
//will be over and we'll call a function named change_frame
function tv_static_on_tv_1(e:TimerEvent):void{
//this function runs when the timer is over
//we remove the listener since we don't need it anymore
tv_static_tv_1.removeEventListener(TimerEvent.TIMER_COMPLETE, tv_static_on_tv_1);
//then we go to frame 2
Object(parent).tv_1.tv_static.gotoAndPlay('on');
Object(parent).tv_1.tv_background.gotoAndStop('on');
gotoAndPlay('tv_static_2');
}
