Hey there,
When a timer in my game hits 40 I want it to go to the next frame. Here is what I have:
onClipEvent (enterFrame) {
var atFrame:Boolean = false;
if (_root.timer == 40) {
atFrame = true;
} else {
_root.timer++;
}
if (atFrame == true) {
myRandom = random(3);
if (myRandom == 0) {
gotoAndStop("game1");
}
if (myRandom == 1) {
gotoAndStop("game2");
}
if (myRandom == 2) {
gotoAndStop("game3");
}
}
}
Where "game1-3" are the names of my frames. And timer is the name of my dynamicText.
Any suggestions as to why this isn't working would be greatly appreciated.
Kind Regards, Eric
_root.timer=0I change the code
_root.timer = 0;
onClipEvent (enterFrame) {
var atFrame:Boolean = false;
if (++_root.timer == 40) {
goGame(); }
}
function goGame() {
myRandom = int(Math.random()*3);
if (myRandom == 0) {
_root.gotoAndStop("game1");
}
if (myRandom == 1) {
_root.gotoAndStop("game2");
}
if (myRandom == 2) {
_root.gotoAndStop("game3");
}
}
"game1","game2","game3" are the label in the time line or the name of the frames inside the movieclip?
try this
code in the time line:
_root.timer = 0;
stop();
function goGame() {
myRandom = int(Math.random()*3);
if (myRandom == 0) {
gotoAndStop("game1");
}
if (myRandom == 1) {
gotoAndStop("game2");
}
if (myRandom == 2) {
gotoAndStop("game3");
}
}
code in the moveclip
onClipEvent (enterFrame) {
var atFrame:Boolean = false;
if (int(++_root.timer) == int(40)) {
_parent.goGame();
}
}
you´re welcome
is too a solution
onClipEvent (load) {
function goGame() {
myRandom = int(Math.random()*3);
if (myRandom == 0) {
gotoAndStop("game1"); //for frame inside the movieclip or _parent.gotoAndStop("game1");
}
if (myRandom == 1) {
gotoAndStop("game2"); //for frame inside the movieclip or _parent.gotoAndStop("game2");
}
if (myRandom == 2) {
gotoAndStop("game3"); //for frame inside the movieclip or _parent.gotoAndStop("game3");
}
}
}
onClipEvent (enterFrame) {
var atFrame:Boolean = false;
if (++_root.timer==40) {
goGame();
}
}
North America
Europe, Middle East and Africa
Asia Pacific