Hi, this is my first post on this forum. I’m new to Flash and Actionscript. Please forgive me if this question is too dumb.
I don’t know how to use the ComponentEvent.RESIZE event. I want to use it to resize my textfield’s background, whenever the textfield is resized (the textfield is resized automatically when the user changes the input text). I don’t know if I’m asking the right question, I will try to explain it through the code:
import fl.events.ComponentEvent;
txtInput.autoSize = TextFieldAutoSize.LEFT;
txtInput.addEventListener(ComponentEvent.RESIZE, resizeHandler);
addEventListener(Event.ENTER_FRAME, resizeOnEnterFrame);
function resizeHandler(evt:ComponentEvent):void {
InputBg.width = txtInput.width;
trace("resized");
}
function resizeOnEnterFrame(e:Event):void {
InputBg.width = txtInput.width;
}
SWF file: http://www.fileden.com/files/2009/2/3/2305269/TextResizeTest.swf
Source file: http://www.fileden.com/files/2009/2/3/2305269/TextResizeTest.rar
When I hit Ctrl+Enter to test it, the “resizeOnEnterFrame” function seems to be worky. But if I remove it with the EventListener(Event.ENTER_FRAME), the “resizeHandler” function doesn’t seem to be working at all. I think it’s because the RESIZE event was not fired at all.
Please help me to correct the code.
Thanks a lot in advances.