# ComponentEvent.RESIZE

**URL:** <https://forum.kirupa.com/t/componentevent-resize/283177>\
**Category:** flash\
**Created:** [March 3, 2009, 12:19pm UTC](https://forum.kirupa.com/t/componentevent-resize/283177 "2009-03-03T12:19:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aveltium](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@aveltium](https://forum.kirupa.com/u/aveltium)\
**Post date:** [March 3, 2009, 12:19pm UTC](https://forum.kirupa.com/t/componentevent-resize/283177/1 "2009-03-03T12:19:02Z")

</div>

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:

```auto

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](http://www.fileden.com/files/2009/2/3/2305269/TextResizeTest.swf)  
Source file: [http://www.fileden.com/files/2009/2/3/2305269/TextResizeTest.rar](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. 😃
