well, i have a nice clean code with a box and 3 buttons above it which resizes and changes color smoothly…the butttons follow the box position but i have a little problem…you see,when the movie loads and i press the first button the buttons moving about 10 pixel up and 20 pixels left…!!!but then when i press the other buttons they follow the box normally… :|i will attach the fla to see what i mean…if you could help me i 'd appreciate that…
thanx again…
ohh… here is the code that i use
var speed = 10;
function resizeTo(w, h, rn, gn, bn) {
main.onEnterFrame = function() {
//Color change variables
red = (rn-r);
blue = (bn-b);
green = (gn-g);
//reposition the "menu" (contains your buttons)
mw = (w-this._width)/speed;
mh = (h-this._height)/speed;
//if these objectives have been met...
if (Math.abs(mw)<0.5 and Math.abs(mh)<0.5 and
Math.abs(red)<.5 and Math.abs(blue)<.5 and Math.abs(green)<.5) {
//...set the colors to their final values.
myColor = new Color(main);
menuColor = new Color(menu);
newColor = {rb:rn, bb:bn, gb:gn};
myColor.setTransform(newColor);
menuColor.setTransform(newColor);
//...set the width and height to their final values.
this._width = w;
this._height = h;
//...set the "menu" MC on it's final position.
menu._x = _root.main._x+_root.main._width/2-menu._width;
menu._y = _root.main._y-_root.main._height/2-menu._height;
//Delete the "onEnterFrame" event handler,
// because it is no longer needed.
delete this.onEnterFrame;
trace("done");
//If those objectives have NOT been met...
} else {
//...ease the colors towards their new values.
r += red/speed;
b += blue/speed;
g += green/speed;
myColor = new Color(main);
menuColor = new Color(menu);
newColor = {rb:r, bb:b, gb:g};
myColor.setTransform(newColor);
menuColor.setTransform(newColor);
//...ease the width and height towards their final values.
this._width += mw;
this._height += mh;
//...reposition the "menu" MC on top of the "main" MC.
menu._x = _root.main._x+_root.main._width/2-menu._width;
menu._y = _root.main._y-_root.main._height/2-menu._height;
}
};
}
menu.bt1.onPress = function() {
//(WIDTH, HEIGHT, RED, GREEN, BLUE)
resizeTo(300, 250, 255, 0, 0);
};
menu.bt2.onPress = function() {
resizeTo(500, 300, 0, 255, 0);
};
menu.bt3.onPress = function() {
resizeTo(300, 300, 0, 0, 255);
};
maybe you can fix it without looking the fla…
the fla is saved in flash mx 2004