vendredi 14 avril 2017

(Flash/Animate CC AS3) Getting multiple images to turn on/off at particular times not working with second MovieClip

Ok this has been driving me insane. My AS3 knowledge isn't the best in the world, but I'm trying to work out where I'm going wrong with all of this.

Basically, What I'm trying to do is at certain times, make visible/invisble two different MovieClips.

The weird thing is, one is responding. And the other isn't. They are both identical aside from jpeg contents and names. Is there a setting I'm missing? Both have matched MovieClip names and Instance names... but when I use the code below, HOP1 turns off/on, but HOP2 refuses to! Am i just missing some stupidly obvious preference?

I will mention, I'll have to modify the code to work with two different MovieClips, but right now I just want both files to 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 {

        // This is where you can set the Hour of Power time start and end time (in 24 hour format e.g. 1330 for 1:30pm)
        // If there is no hour of power, simply set both numbers to 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;
                }
            }
        }

    }

}

Aucun commentaire:

Enregistrer un commentaire