# Resize handler randomly works?!

**URL:** <https://forum.kirupa.com/t/resize-handler-randomly-works/323308>\
**Category:** flash\
**Created:** [June 24, 2011, 4:49pm UTC](https://forum.kirupa.com/t/resize-handler-randomly-works/323308 "2011-06-24T16:49:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikaelf](https://avatars.discourse-cdn.com/v4/letter/m/8edcca/32.png) [@mikaelf](https://forum.kirupa.com/u/mikaelf)\
**Post date:** [June 24, 2011, 4:49pm UTC](https://forum.kirupa.com/t/resize-handler-randomly-works/323308/1 "2011-06-24T16:49:09Z")

</div>

Hi all.

I have a main swf which I load in a few different external swf. For each of the external swf I have resize handlers which make sure my loaded swf are position in the correct place when window is resized. It works almost perfect… but let say 1 out of 4 times the resize handler stops and nothing happens. Why does it sometimes work only?

I know I should not have function within a function but in this case I do not know how to do it in any other way?!

I have attached the code for one of the functions:

Thankful for all advice.

```auto
function eventsLoaded(event:Event):void {
    
    mcExt = MovieClip(contentLoader.contentLoaderInfo.content)
    loadedMovieClip="events";
    preloader_mc.visible = false;
    
    this.stage.addEventListener(Event.RESIZE, resizeEvent, false,0,true); 

    eventsBG_mc.width = stage.stageWidth;
    eventsBG_mc.height=stage.stageHeight;    
    eventsBG_mc.x=stage.stageWidth;
    contentLoader.x=stage.stageWidth;
    contentLoader.y=stage.stageHeight/2-contentLoader.height/2;
    
    addChild(eventsBG_mc);
    addChild(contentLoader);
   
    var timeline:TimelineLite = new TimelineLite();
        timeline.append( new TweenLite(contentLoader, 1, {x:305, ease:Sine.easeOut}) );
        timeline.append( new TweenLite(eventsBG_mc, 1, {x:305, delay:-1, ease:Sine.easeOut}) );
    
    
    
    //resize handler
    function resizeEvent(){
            eventsBG_mc.height=stage.stageHeight;    
            contentLoader.y=stage.stageHeight/2- contentLoader.height/2;
    }
}

```
