View Full Version : Help: Motion
Luigi Vercotti
02-18-2005, 09:51 PM
var xSpeed:Number = 10;
var xEasy:Number = .6;
//var xStop:Number =
ballX.onEnterFrame = function ():Void{
xSpeed *= xEasy;
this._x -= xSpeed;
}
:confused:
I made this script to move my movie clip "ballX" to the left and stop and I want to return it back. How do I do it?
I want move the ballX few pixels to the left and then back to the right. I want to move let say 20 pix to the left and 20 pix back, I know how to do it with position of _x, but I want this "ballX" put it anywhere on the stage later on.
:confused: :D :)
IceCo
02-18-2005, 11:28 PM
Here you go. The ball will hit the left frame of the Stage and then bounce back.
Note that the ball shape in the movieClip has to be centered at stage for this code to work properly.
ballX.onEnterFrame = function ()
{
xSpeed *= xEasy;
// detect if the ball hits the boundry of the Stage
if ((this._x - xSpeed) < (ballX._width / 2))
{
this._x = ballX._width / 2;
xSpeed *= -1;
}
this._x -= xSpeed;
};
williamy
02-18-2005, 11:48 PM
1.u know the _x to movie the mc to left or right ,so u can also use _y .
2.if u wanna the mc bounce back when it touch the leftside bar, u can use the "if" to control it,
exam:
//----------------------->>
mc._x=100;
mc.onEnterFrame=function(){
mc._x-=10;
if(mc._x<=10)
mc._x=100;
}
//------------end
can u see it?
Luigi Vercotti
02-19-2005, 01:19 PM
sorry guys, but nothing works
"Iceco" it does the same thing as mine, it goes to the left and stop
"Williamy" it works, but I will use the movie clip a lot and I can't every time set the position of movie clip _x like you did _x=100
I want to put the movie clip anywhere on the stage and it will go little bit to the right and then slide back.
Please anyone... :D
IceCo
02-19-2005, 07:45 PM
R u sure that it doesn't work? (see the attached file)
var xSpeed:Number = 20;
var xEasy:Number = 0.9;
ball.onEnterFrame = function ()
{
xSpeed *= xEasy;
// detect if the ball hits the boundry of the Stage
if ((this._x - xSpeed) < (this._width / 2))
{
this._x = this._width / 2;
xSpeed *= -1;
}
else // I forgot to include this in my previous code
{
this._x -= xSpeed;
}
};
Luigi Vercotti
02-20-2005, 06:09 PM
ye, this one works :D :)
thank you very much ;) :) :D :)
Luigi Vercotti
02-20-2005, 06:20 PM
oh, sorry it works, but it still doesn't work as I need.
When I move your mc "ball" in the middle of the stage or simply further to the right the ball slides to the left and stop and doesn't go back.
Can be done...?
JohnF
02-20-2005, 06:23 PM
My brain hurts
IceCo
02-24-2005, 05:01 AM
That is because the speed of the ball is reduced to 0 before it hits the left boundry of Stage. ;) What exactly do you want to build?
Luigi Vercotti
02-24-2005, 06:11 AM
I want to have a movie clip "ball" which will be part of button, when you rollOver I want the ball slide to the left and then slide back(let say 15pix left and back).
I know how to do it with motion tween, and also with actionScript, but only when I set up _x, but the problem is I want to put the movie clip in different places on the stage, then I have setup each _x of the ball. I am looking for the way so I don't have to setup _x everytime.
:confused:
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.