How to dynamicaly resize a button on stage in as2.0
I have a button on stage in a movie, the button ("clicker") is empty apart from the "hit" frame. The stage and button are 300x300 and i'm using swfobject to display the flash movie at 400x600 pixels. I have the following actionscript...
Stage.showMenu = false; Stage.scaleMode = "noScale"; Stage.align = "TL";
clicker._x = 0开发者_如何学编程; clicker._y = 0;
clicker.onRelease = function() { trace("onMouseDown called"); getURL(link_url, "_blank"); };
I want teh button to expand to fill the available stage space (which is 400x600 in this example) so i use the following...
clicker._width = Stage.width; clicker._height = Stage.height;
however this causes the button to disapear from the stage, possibly down to 0x0 in size, as opposed to filling the available stage space. It's been a while since i worked with actionscript so it's probably something obvious, however i can't seem to spot what the problem is. Any suggestions would be greatly appreciated?
You need to add an event listener to the Stage:
var stageListener:Object = new Object();
stageListener.onResize = function() { clicker._width = Stage.width; clicker._height = Stage.height; };
Stage.addListener(stageListener);
精彩评论