Hi, so I created my movieclip and gave it this code:
Code:
onClipEvent (load) {
if (day < 15) {
this.gotoAndStop(1);
} else if (day >= 15) {
this.gotoAndStop(2);
}
}
Inside the movieclip I have 2 frames. They both look completely different. In my game if day is less than 15, I want my movieclip to stay on frame 1, if day is greater than or equal to 15 I would like my movieclip to go to frame 2. The problem I'm having with my code is that my movieclip stays on frame 2 regardless of what day it is. Does anyone know how to fix this?
Personally I wouldnt do it as an onClipEvent.
the var day Im guessing is on the main timeline
I would do:
Code:
MC.onEnterFrame = function (){
if (day < 15) {
MC.gotoAndStop(1);
} else if (day >= 15) {
MC.gotoAndStop(2);
}
}
This way the statement is checked at the frame rate if you dont need it checked as frequently
Ie, the time of day only progresses from a proceeding function you can set it as its one function to only check when you add 1 to day.
Code:
function dayCheck(){
if (day < 15) {
MC.gotoAndStop(1);
} else if (day >= 15) {
MC.gotoAndStop(2);
}
}
//Then add the the function to the process
dayCheck();
//if doing this method you will need to place it at the top for your actions frame to check when the frame loads for the first time.
Looks good depends if he is referring to real day of the month or just from a var of his own.
One warning RaynbowzRule.
If you are basing off the real day in the month, the functions run off your system date and time, so a player could change there clock to change the time in the game.
Best of luck though
I'm sorry, I do not understand the code. Could you maybe explain? I am not referring to real time, my game has a var called day that goes up to 30 days.
// function to check day var
function CheckDay()
{
// if day var is less than 15, movie clip goto frame 1.
if (day < 15)
{
MC.gotoAndStop(1);
}
// else if day var is greater or equal to 15, movie clip goto frame 2.
else
{
MC.gotoAndStop(2);
}
// displays actual day var in output panel
trace(day);
}
// call the check day var function
CheckDay();
// the above command can be placed anywhere, when a game is complete, before a game is started etc etc