It should be an event attached to the clip itself and not within a frame
What this code does it in the load event set a position to movie to (_root.locationY) if you have more than one clip you want to move to you might want to make this variable inside the movie clip (locationY = 200) instead of on root.
the variable delay controls the easing for the object. a larger value creates a smoother effect, a smaller value moves the object rapidly towards the point (try a value between 0 and 1 eg 0.8 to get a weird oscillating effect )
the enterFrame loop calculates a step towards positionY by finding the difference between the clips current y position and the positionY variable and dividing this difference by delay.
Ok I made an mc,placed it on scene,gave the mc the code listed above.The effect I got was the square moved downwords.
So If >y is set to 200 this moves the mc 200 pixels?How can I give the effect to an mc hitting a button.Button a> moves 200 pixels.Button b >moves the mc 400 pixels.This I wanne know.
Also how rescale the mc hitting a button with this easing effect.
The value set for locationY is the final y position you want the clip to end up at.
Here's an example file that randomizes the scale and position of the clip.
Could this be added to a frame action so you could control where and when and what size and position the box appears? Or to a button?
I played with your code, and added another onmousedown after the onenterframe frame event, and it bypassed the first mousedown and went to the last. Not quite sure why it did that, or even why it worked at all.
Code:
onClipEvent(load) {
var easing = 5;
var xFinal = 500;
var yFinal = 400;
var xScaleFinal = 200;
var yScaleFinal = 200;
}
onClipEvent(mouseDown) {
var xFinal = 300;
var yFinal = 200;
var xScaleFinal = 200;
var yScaleFinal = 200;
}
onClipEvent(enterFrame) {
this._x += (xFinal - this._x) / easing;
this._y += (yFinal - this._y) / easing;
this._xscale += (xScaleFinal - this._xscale) / easing;
this._yscale += (yScaleFinal - this._yscale) / easing;
}
onClipEvent(mouseDown) {
var xFinal = 400;
var yFinal = 200;
var xScaleFinal = 400;
var yScaleFinal = 300;
}
You could move code to a button to first position the clip and then set its target position/scale/whatever other property you want to change.
maybe try something like this,
Code:
onClipEvent(load) {
var easing = 5;
var xFinal = this._x;
var yFinal = this._y;
var xScaleFinal = this._xscale;
var yScaleFinal = this._yscale;
}
// and then the same enterFrame event as before
this sets the values of the target variables to be the same as the current state of the clip. by doing this you don't see any tweening until the button or frame event sets up the new values.
Modified it a bit. I found that removing the top half of the button code made it work perfect, moving to the new location from the last location on press. Something like this:
Otherwise you had to code in the last position and size. So I have tried this code on three buttons, and it works beautifully. I appreciate the effort, I've been working nights on finding a way to do this, and got nowhere. I'm missing something essential in my thinking about code. Darn it...
I can't seem to download the file in a proper way
Can you zip the file for me.I'm on a mac and this is the only way to download fla file.I tryed to make this effect but it just did not work for me.Still a newbie you know.So I attached what I did.Can you have a look at it.If I got things wright know the code works with a scale factor.Can't this be done with a change weight,height?I really would appreciate you looked into my file.I'm really stuck in this matter. THX
Ps.this script only works in MX or does it also work in flash5
Cab you drop a fade effect also in 'my not working file'
It works perfect now.I removed the fscommand and everything seems to work perfect now.Strange,but it works now.Could you add me also code to fade the mc,or make it invisible.
How can you control the mc.Like when hit>the mc first moves,then scales,then fades,the is invisble.is this possible and how acheave that.