enterFrame problem,..
- geohoundz55
-
geohoundz55
- Member since: May. 31, 2007
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
check HERE
I'm experimenting on sleep system and got a problem on my MC,...
once you go to other frame and back to that frame, it feels like the intervals are getting faster,..
here's the code by the way,..
onClipEvent (load) {
fight = false;
function randomW() {
W = int(Math.random()*10);
}
ChangeW = setInterval(randomW, 2000);
}
onClipEvent (enterFrame) {
if (fight == false) {
if (this.hitTest(_root.mainRanch.ranch.wall 1)) {
(W=8);
}
if (this.hitTest(_root.mainRanch.ranch.wall 2)) {
(W=9);
}
if (this._x<0) {
this._x = 0;
}
if (W == 9) {
this.Darkus1._x -= _global.mySpd;
this.Darkus1._xscale = -100;
this.Darkus1.gotoAndStop(2);
}
}
if (W == 8) {
this.Darkus1._x += _global.mySpd;
this.Darkus1._xscale = 100;
this.Darkus1.gotoAndStop(2);
} else if (W<=7) {
this.Darkus1.gotoAndStop(1);
}
}
Thanks for the help.,.,!
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
At 3/17/09 10:10 AM, geohoundz55 wrote: check HERE
I'm experimenting on sleep system and got a problem on my MC,...
once you go to other frame and back to that frame, it feels like the intervals are getting faster,..
It sounds like the code setting up the interval is being run twice. The interval is set up on the root, not on the MC (although it's possible to assign it to the MC). Just add a clearInterval(ChangeW); at the top of the onClipEvent(load) to get rid of the previous interval before setting up the new one
- geohoundz55
-
geohoundz55
- Member since: May. 31, 2007
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
- geohoundz55
-
geohoundz55
- Member since: May. 31, 2007
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
OMG,.
I thought it work,..
sorry I think it's not working,..
- geohoundz55
-
geohoundz55
- Member since: May. 31, 2007
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
I still don't figure it out,..
Can someone teach me or try to fix this code,.
onClipEvent (load) {
function randomW() {
clearInterval(ChangeW);
W = int(Math.random()*10);
}
ChangeW = setInterval(randomW, 2000);
trace(ChangeW);
beginInterval();
}
onClipEvent (enterFrame) {
if (this.hitTest(_root.mainRanch.ranch.wall 1)) {
(W=8);
}
if (this.hitTest(_root.mainRanch.ranch.wall 2)) {
(W=9);
}
if (this._x<0) {
this._x = 0;
}
if (W == 9) {
this.Darkus1._x -= _global.mySpd;
this.Darkus1._xscale = -100;
this.Darkus1.gotoAndStop(2);
}
if (W == 8) {
this.Darkus1._x += _global.mySpd;
this.Darkus1._xscale = 100;
this.Darkus1.gotoAndStop(2);
} else if (W<=7) {
this.Darkus1.gotoAndStop(1);
}
}
thanks!
- geohoundz55
-
geohoundz55
- Member since: May. 31, 2007
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
At last!
I solve it,.
I just put
onClipEvent (unload) {
clearInterval(ChangeW);
}
on the top of
onClipEvent (load)
But thanks again!
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
At 3/17/09 11:56 AM, geohoundz55 wrote: onClipEvent (load) {
function randomW() {
clearInterval(ChangeW);
W = int(Math.random()*10);
}
ChangeW = setInterval(randomW, 2000);
trace(ChangeW);
beginInterval();
}
onClipEvent (load) {
clearInterval(ChangeW);
ChangeW=setInterval(function(){
W=int(Math.random()*10);
},2000);
}
onClipEvent (enterFrame) {
if (this.hitTest (_root.mainRanch.ranch.wall1)) {
W=8;
}
if (this.hitTest (_root.mainRanch.ranch.wall2)) {
W=9;
}
if (this._x<0) {
this._x = 0;
}
if (W == 9) {
this.Darkus1._x -= _global.mySpd;
this.Darkus1._xscale = -100;
this.Darkus1.gotoAndStop(2);
}
if (W == 8) {
this.Darkus1._x += _global.mySpd;
this.Darkus1._xscale = 100;
this.Darkus1.gotoAndStop(2);
} else if (W<=7) {
this.Darkus1.gotoAndStop(1);
}
} 

