View Full Version : [MX] change size of a button
ukiran
September 12th, 2003, 05:49 AM
How do I refer to a button in its own handler.I need to change the size of a button on rollover using actionscript code.
this._height doesnt seem to work.
eki
September 12th, 2003, 06:10 AM
Hi,
this.nameOf Button._height;
Buttons are a bit weird in the sense they are not understood as having their own timeline so when you refer to 'this'applying an action directly on a button you are actually refering to the timeline it's included in.
Did yuou know that in MX there's not need to use buttons? if you use an 'onPress', 'onRollover, 'onRollOut', 'onRelease' ,etc event on a MovieClip it behaves like a button and its 'this' will refer to itself.
SHO
Zeth
September 12th, 2003, 06:17 AM
Blast ye eki!!! I just made him a nice pretty fla that has to be burned. Oh well. Since you seem so active, why not rummage over to my lil' post a few ones down and help me out ;)
----
//Double Button Size onRollOver
on (rollOver) {
this.button._height = this.button._height*2;
this.button._width = this.button._width*2;
}
~Zeth
Eric Jr.
September 12th, 2003, 06:19 AM
Correct, if you trace "this" in a button, it doesn't refer to itself, but to the timeline it is placed on.
This is fixed Flash MX 2004 ...
Eric Jr.
September 12th, 2003, 06:21 AM
Zeth, I believe that nobody didn't reply to your post below because it is not directly possible .. not with duplicate movieclip, nor swapdepths ...
PS: You are right, you don't understand swapdepths
Voetsjoeba
September 12th, 2003, 11:33 AM
When you use static event handlers on buttons, this will refer to the parent timeline. So you would indeed have to use this.instancename to refer to the button. Example:
on(release){
trace(this)
//trace the path to the parent of this button
}
When you use dynamic event handlers, this refers to the button, and not to the parent timeline. Example:
[AS]
button.onRelease = function(){
trace(this);
//will return the path to the button
}
[/code]
Just a thing to remember that prevents a lot of frustration ;)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.