gotoAndPlay issue
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: gotoAndPlay issue

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    1

    Question gotoAndPlay issue

    I am using cs4 w/as3. I have a keyframe with as3 that is supposed to decide which scene to procede with based on the time of day.

    The problem arises when the code gets to the gotoAndPlay command, it doesn't process unless it's the last line in the code.

    See code example below.

    Code:
    currenttime = new Date();
    hrs=currenttime.hours;
    mins=currenttime.minutes;
    secs=currenttime.seconds;
    if (hrs==10&&mins<15) {
    	gotoAndPlay(1, "Black");
    }
    if (hrs==10&&mins<30) {
    	gotoAndPlay(1, "Orange");
    }
    if (hrs==10&&mins<45) {
    	gotoAndPlay(1, "Silver");
    }
    if (hrs==10&&mins<60) {
    	gotoAndPlay(1, "Pink");
    }
    if (hrs==11&&mins<15) {
    	gotoAndPlay(1, "Blue");
    }
    if (hrs==11&&mins<30) {
    	gotoAndPlay(1, "White");
    }
    if (hrs==11&&mins<45) {
    	gotoAndPlay(1, "Purple");
    }
    if (hrs==11&&mins<60) {
    	gotoAndPlay(1, "Yellow");
    }
    if (hrs==12&&mins<15) {
    	gotoAndPlay(1, "Red");
    }
    if (hrs==12&&mins<30) {
    	gotoAndPlay(1, "Green");
    }
    if (hrs==12&&mins<45) {
    	gotoAndPlay(1, "Black2");
    }
    if (hrs==12&&mins<60) {
    	gotoAndPlay(1, "Orange");
    }
    if (hrs==13&&mins<15) {
    	gotoAndPlay(1, "Silver");
    }
    if (hrs==13&&mins<30) {
    	gotoAndPlay(1, "Pink");
    }
    if (hrs==13&&mins<45) {
    	gotoAndPlay(1, "Blue");
    }
    if (hrs==13&&mins<60) {
    	gotoAndPlay(1, "White");
    }
    if (hrs==14&&mins<15) {
    	gotoAndPlay(1, "Purple");
    }
    if (hrs==14&&mins<30) {
    	gotoAndPlay(1, "Yellow");
    }
    if (hrs==14&&mins<45) {
    	gotoAndPlay(1, "Red");
    }
    if (hrs==14&&mins<60) {
    	gotoAndPlay(1, "Green");
    }
    if (hrs==15&&mins<15) {
    	gotoAndPlay(1, "Black2");
    }
    if (hrs==15&&mins<30) {
    	gotoAndPlay(1, "Orange");
    }
    if (hrs==15&&mins<45) {
    	gotoAndPlay(1, "Silver");
    }
    if (hrs==15&&mins<60) {
    	gotoAndPlay(1, "Pink");
    }
    if (hrs==16&&mins<15) {
    	gotoAndPlay(1, "Blue");
    }
    if (hrs==16&&mins<30) {
    	gotoAndPlay(1, "White");
    }
    if (hrs==16&&mins<45) {
    	gotoAndPlay(1, "Purple");
    }
    if (hrs==16&&mins<60) {
    	gotoAndPlay(1, "Yellow");
    }
    if (hrs==17&&mins<15) {
    	gotoAndPlay(1, "Red");
    }
    if (hrs==17&&mins<30) {
    	gotoAndPlay(1, "Green");
    }
    if (hrs==17&&mins<45) {
    	gotoAndPlay(1, "Black2");
    }
    if (hrs==17&&mins<60) {
    	gotoAndPlay(1, "Orange");
    }
    if (hrs==18&&mins<15) {
    	gotoAndPlay(1, "Silver");
    }
    if (hrs==18&&mins<30) {
    	gotoAndPlay(1, "Pink");
    }
    if (hrs==18&&mins<45) {
    	gotoAndPlay(1, "Blue");
    }
    if (hrs==18&&mins<60) {
    	gotoAndPlay(1, "White");
    }
    if (hrs==19&&mins<15) {
    	gotoAndPlay(1, "Purple");
    }
    if (hrs==19&&mins<30) {
    	gotoAndPlay(1, "Yellow");
    }
    if (hrs==19&&mins<45) {
    	gotoAndPlay(1, "Red");
    }
    if (hrs==19&&mins<60) {
    	gotoAndPlay(1, "Green");
    Thanks for any help you can provide with this.

    ~Matt

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,093
    If you're trying to improve your code...

    Controlling your flash based on the time of day takes a little bit higher level code. If you use arrays to store your colors, you can use math to get the color. Something like this:

    Code:
    arryColors = new Array("Black","Orange","Silver","Pink","Blue","White");
    currentColor = arrayOfColors[Math.floor(mins/10)];
    This puts the colors in an array and uses a math equation on the current minutes to find a color.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com