A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Time restricted frame transistion

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    4

    Time restricted frame transistion

    I know this is probably a simple thing but... I have a template to move PPT files over to Flash. The button for 'next frame' uses the following action script....

    on (release, keyPress "<Right>") {
    nextFrame();
    }


    I would like to make it so that users have to wait x amount of time to be able to use the 'next button'. So the user can't just click their way through a class.

    Make sense?

  2. #2
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    Try this:

    Put a variable in your actions panel, like this:
    Actionscript Code:
    var buttonTime:Number;

    Replace the code you posted above with this:
    Actionscript Code:
    on (release, keyPress "<Right>") {
        if ((getTimer()/1000)-_root.buttonTime>=3) {//Change the 3 to however many seconds you want the user to wait
            _root.buttonTime = getTimer()/1000;
            nextFrame();
        }
    }
    Last edited by hts5000; 08-18-2010 at 01:55 PM.

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    4
    Sweet! That works! Thanks so much. I did overlook one thing though... Now I need to figure out how to setup an if statement to tell the person they're clicking too soon. Basically a message saying 'you have to wait x amount of time for the next slide' or something.

  4. #4
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    All you have to do is add a dynamic text box and use this code:

    Actionscript Code:
    on (release, keyPress "<Right>") {
        if ((getTimer()/1000)-_root.buttonTime>=3) {//Change the 3 to however many seconds you want the user to wait
            _root.buttonTime = getTimer()/1000;
            nextFrame();
        } else {
            var remainingTime:Number = Math.round(3-((getTimer()/1000)-_root.buttonTime));
            dynaicTextBox = "You have to wait "+remainingTime+" seconds for the next slide";
        }
    }

    Hope this helps.

  5. #5
    Junior Member
    Join Date
    Aug 2010
    Posts
    4
    So close...

    I have this running in my actionscript

    stop();
    var buttonTime:Number;
    var remainingTime:Number = Math.round(3-((getTimer()/1000)-_root.buttonTime));
    myDate_date = new Date();
    daysofWeek_array = new Array();
    daysofWeek_array[0] = "Sunday";
    daysofWeek_array[1] = "Monday";
    daysofWeek_array[2] = "Tuesday";
    daysofWeek_array[3] = "Wednesday";
    daysofWeek_array[4] = "Thursday";
    daysofWeek_array[5] = "Friday";
    daysofWeek_array[6] = "Saturday";
    daysofMonth_array = new Array();
    daysofMonth_array[0] = "January";
    daysofMonth_array[1] = "February";
    daysofMonth_array[2] = "March";
    daysofMonth_array[3] = "April";
    daysofMonth_array[4] = "May";
    daysofMonth_array[5] = "June";
    daysofMonth_array[6] = "July";
    daysofMonth_array[7] = "August";
    daysofMonth_array[8] = "September";
    daysofMonth_array[9] = "October";
    daysofMonth_array[10] = "November";
    daysofMonth_array[11] = "December";
    myDate_date = new Date();
    currentYear = myDate_date.getFullYear();
    currentMonth = myDate_date.getMonth();
    currentDate = myDate_date.getDate();
    currentDay = myDate_date.getDay();


    Then I have the following on the button...


    on (release, keyPress "<Right>") {
    if ((getTimer()/1000)-_root.buttonTime>=3) {//Change the 3 to however many seconds you want the user to wait
    _root.buttonTime = getTimer()/1000;
    nextFrame();
    dynamicTextBox =""
    } else {
    dynamicTextBox = "You have to wait "+remainingTime+" seconds for the next slide";
    }
    }

    It works except for it doesn't show the seconds.

  6. #6
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    Don't put the remainingTime variable in your actionscript. Leave it in the button. Sorry I didn't make the clear earlier.

  7. #7
    Junior Member
    Join Date
    Aug 2010
    Posts
    4
    Tried it on the button the way you had it originally and had the same issue.

  8. #8
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    ok, weird. Either way it definitely needs to be in the button. Is anything showing up in the text field? Is the dynamic text box on in a movie clip or on the main time line? If its not on the main time line then _root will not work.

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