Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick question guys... 2

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
Ok I have a clip that I want to slide on x axis to a certain point and then start over at it's begining once it reaches a certain point.

Simple for you guys I know, unfortunatley i'm retarted!

here is what I have:

Code:
onClipEvent (enterFrame) {
	_x -= 1;
	if (_root.slide>=-1088) {
		_root.slide_x = 300;
		updateAfterEvent();
	}
}

So clip slide, when you get to negative 1088 start over and 300 and slide again?

It slides, just keeps going and going and going :)

---------------------------------------------
 
Code:
onClipEvent (enterFrame) {
    _x -=1;
	//trace (_root.slide._x);
	if (_root.slide._x == -1088) {
        	_root.slide._x = 300;
        	//updateAfterEvent();
    }
}

Regards,

cubalibre2.gif
 
Is this clip event attached to the clip 'slide'?

If so the _root paths aren't necessary - at the moment you have a reference to _x and another to _root.slide._x - you can just refer to _x throughout without the path.

 
Code:
onClipEvent (enterFrame) {
	_x -=10;
	trace(this._x);
	if (_x < -1088) {
		_x = 484;
		updateAfterEvent();
	}
}


Regards,

cubalibre2.gif
 
The main reason it's wasn't working (using ==) is that since your mc's original position wasn't set to an exact pixel coordinate, substracting -10 to it, it never really equaled -1088, but maybe someting like -1088.6, so the if statement was never actually true.

Regards,

cubalibre2.gif
 
For an extra tweak you can take out the updateAfterEvent() line as it doesn't actually add anything to an enterFrame script except a load on the processor. It's only really of use when you're doing something like an onMouseMove...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top