I got this code from another thread, and changed it into a button event handler.
It 's a motion tween via AS.
Is it possible to have a second button change
it back to it’s original shape?
btn_1.onRelease = function() {
var hDiff = Math.round(25-this._height);
var wDiff = Math.round(500-this._width);
this._width += wDiff/1;
this._height += hDiff/1;
};
But think: how can that possibly create motion if that code is only executed once ? To have actionscripted motion, you need a repeating code, such as in onEnterFrame handler or in a function which you call using setInterval for example. That code will only change the dimensions of that movieclip once, but there will not be any motion.
Like Voetsjoeba says, you need to do the motion in a function that gets executed over more than one frame.
That’s what it does now. onEnterFrame gets executed once every frame. onRelease only gets executed once when you press the button. You can change the size in onRelease but it won’t be a smooth change.
I’d suggest that you make 2 functions: expand and contract. When you hit button 1, you set the onEnterFrame event to execute the expand function. And when you hit button 2, you set onEnterFrame to execute the contract function.
There’s probably a better way of doing what I want. But I came across this code while searching.
I wanted a button that expanded, and once another btn
was pressed contracted.
Still got so much to learn…