actionscript 3 - AS3 - Multiple Images Turn On/Off Not Working with Second MovieClip -
ok has been driving me insane. as3 knowledge isn't best in world, i'm trying work out i'm going wrong of this.
basically, i'm trying @ times, make visible/invisble 2 different movieclips.
the weird thing is, 1 responding. , other isn't. both identical aside jpeg contents , names. there setting i'm missing? both have matched movieclip names , instance names... when use code below, hop1 turns off/on, hop2 refuses to! missing stupidly obvious preference?
i mention, i'll have modify code work 2 different movieclips, right want both files turn off!
package { import flash.display.movieclip; import flash.events.timerevent; import flash.ui.mouse; import flash.utils.timer; import com.boo.customdate; import com.boo.screensaversimple; public class generic extends movieclip { // can set hour of power time start , end time (in 24 hour format e.g. 1330 1:30pm) // if there no hour of power, set both numbers 0 private var hourofpowerstarttime:number = 0; private var hourofpowerendtime:number = 0; private var ss:screensaversimple; public var time_check_timer:timer; private var delay_add_timer:timer; public function generic() { mouse.hide(); ss = new screensaversimple; ss.setscreensaver(screens); hop2.visible = false; time_check_timer = new timer(1000); time_check_timer.addeventlistener(timerevent.timer, checktime); delay_add_timer = new timer(1,1); delay_add_timer.addeventlistener(timerevent.timer, addallchildren); delay_add_timer.start(); } public function addallchildren(evt:timerevent=null):void { delay_add_timer.removeeventlistener(timerevent.timer, addallchildren); delay_add_timer.stop(); delay_add_timer = null; time_check_timer.start(); checktime(); } public function checktime(evt:timerevent=null):void { checkhop2(); } private function checkhop1():void { if(hourofpowerstarttime == 0 && hourofpowerendtime == 0) { if(hop2.visible == true) { hop2.visible = false; } return; } var currenttime:number = customdate.return24hournumber(); if(currenttime >= hourofpowerstarttime && currenttime <= hourofpowerendtime) { if(hop2.visible == false) { hop2.visible = true; } } else { if(hop2.visible == true) { hop2.visible = false; } } } } }
if(hop2.visible == true) { hop2.visible = false; }
fist thing if
condition complete redundant here. if think it, lines work same 1 alone:
hop2.visible = false;
also (hop2.visible == true)
same (hop2.visible)
, can assign value of condition check directly variable. can reduce function to:
private function checkhop1():void { hop2.visible = (hourofpowerstarttime || hourofpowerendtime); if (!hop2.visible) return; var currenttime:number = customdate.return24hournumber(); hop2.visible = (currenttime >= hourofpowerstarttime && currenttime <= hourofpowerendtime); }
then see call checkhop2()
:
public function checktime(evt:timerevent=null):void { checkhop2(); }
but don't see checkhop2()
function defined in code gave.
similarly don't see form call checkhop1()
function have posted. , don't why change hop2
instance inside function named checkhop1()
. suppose kind of obfuscation?
Comments
Post a Comment