Be a Supporter!

enterFrame problem,..

  • 341 Views
  • 6 Replies
New Topic Respond to this Topic
geohoundz55
geohoundz55
  • Member since: May. 31, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
enterFrame problem,.. 2009-03-17 10:10:40 Reply

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.
Forum Stats
Member
Level 46
Blank Slate
Response to enterFrame problem,.. 2009-03-17 10:20:01 Reply

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


- - Flash - Music - Images - -

BBS Signature
geohoundz55
geohoundz55
  • Member since: May. 31, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to enterFrame problem,.. 2009-03-17 10:24:26 Reply

Thank you!!

It works!

geohoundz55
geohoundz55
  • Member since: May. 31, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to enterFrame problem,.. 2009-03-17 11:04:05 Reply

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
Response to enterFrame problem,.. 2009-03-17 11:56:22 Reply

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
Response to enterFrame problem,.. 2009-03-17 12:53:08 Reply

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.
Forum Stats
Member
Level 46
Blank Slate
Response to enterFrame problem,.. 2009-03-17 13:00:16 Reply

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);
	}
}

- - Flash - Music - Images - -

BBS Signature