What i am trying to do is a bit different to what is outlined in your code.
Imagine a very basic idea of a ball bouncing up and down. i need the ball/box to animate back up to x=200, rather than just immediately returning there.
i guess i want to know how to terminate a script and then start a new block of code.
in literal terms:
if(the ball is less than y=600 ){
move the ball down uniformly at regular intervals
}
then
if(the ball has reached y=600 ){
move the ball back up to y=200 at regular intervals
}
this is not really what i mean. I am pretty competent at scripting, this is not the problem. My problem is that when there are things with eventhandlers, in a one frame animation, then how do i get a set of actions performed, then for that script to beterminated and the next section of script to begin?
Am i making it hard to understand? I’m just having a hard time expressing myself in these terms!
Example:
onClipEvent(enterFrame){
if(this._x<600 ){
this._x+=2;
}
if(this._x>200 ){
this._x-=2;
}
}
obviously this script won’t work as i am asking it to do to opposite things at the same time - so it does nothing!
however i want to do the first bit (if(this._x<600), then when this is complete, i want that part of the script to be terminated/destroyed.
then i want it to do the second bit (if(this._x.200 ).
when this second condition is met, the ball will stop at x=200;
i hope this more clear, and your advice is really appreciated.
I guess I dont understand. The first part of the script does what you want… get to the end and come back. Now, you want it to stop when it gets to the beginning, and not go back and forth. Right?
In that case…
onClipEvent(enterFrame){
//check status
switch(_root.status){
case "start":
this._x+=30;
if(this._x>600){
_root.status="reverse";
}
break;
case "reverse":
this._x-=30;
if(this._x<0){
_root.status="stop";
}
break;
case "stop":
this._x=this._x;
break;
}
}
to begin, frame 1 has a variable called status… like:
You might want to take a look at some of the tutorials at Bit-101. There’s couple of fairly advanced tutorials, including gravity and easing, which is somewhat similar to what you want to do. Here’s the url: http://www.bit-101.com/
Hope this helps!
The Kza