# Fluid Layout EventListener issues, Timeline Code

**URL:** https://forum.kirupa.com/t/fluid-layout-eventlistener-issues-timeline-code/292987
**Category:** Uncategorized
**Created:** [July 21, 2009, 7:06pm UTC](https://forum.kirupa.com/t/fluid-layout-eventlistener-issues-timeline-code/292987 "2009-07-21T19:06:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Terraform](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Terraform](https://forum.kirupa.com/u/Terraform)
#### Post date: [July 21, 2009, 7:06pm UTC](https://forum.kirupa.com/t/fluid-layout-eventlistener-issues-timeline-code/292987/1 "2009-07-21T19:06:38Z")

</div>

Hello  
I could really really use some assistance cleaning up my timeline code.

I have a fluid layout and use a ResizeHandler on frame 1 of my AS for all of my navigation/ backgrounds and anything else that remains constant throughout the movie.

many of the MC’s controlled by that initial ResizeHandler on the 1st frame control MC’s that act as buttons which advance the playhead to a corresponding frame label like so.

```auto

import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.events.Event;
import gs.TweenLite;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener (Event.RESIZE, resizeHandler);  

resizeHandler (null);
 function resizeHandler (event:Event):void {

  left_mc.x = 0;  
  left_mc.y = 0; 
  left_mc.width = stage.stageWidth;
  logo_mc.x = stage.stageWidth - logo_mc.width - 25;
  logo_mc.y = stage.stageHeight - logo_mc.height - 15;
  btn1_mc.x = 460;
  btn1_mc.y = 15;
  btn2_mc.x = 115;
  btn2_mc.y = 15;
  btn3_mc.x = 230;
  btn3_mc.y = 15;
  hit_1.x = 345;
  hit_1.y = 15;
  contact_mc.x = 15;
  contact_mc.y = 15;
  home_mc.x = 575;
  home_mc.y = 15;
}

contact_mc.addEventListener (MouseEvent.CLICK, emailClick);
home_mc.addEventListener (MouseEvent.CLICK, homeClick);

function emailClick(e:MouseEvent):void
{
	gotoAndStop("c");
}
function homeClick(e:MouseEvent):void
{
	gotoAndStop("h");
}

 

```

often on that frame I will introduce another MC that will also need to be “Fluid” within the entire layout, so the way that I have it now is I make another ResizeHandler to  
control that MC and its position and scale on the stage.

\*\*\*\* The Problem \*\*\*\*\*  
I often repeat this process a lot!  
which leaves me with many ResizeHandlers and the way I have it now is I have an addEventListener for the new handler AND depending on the frame  
many removeEventListener lines of code to “remove” all the other listeners that I have created on previous frames.  
here is an example…

```auto

stage.addEventListener (Event.RESIZE, resizeHandler1);
stage.removeEventListener (Event.RESIZE, resizeHandler3);
stage.removeEventListener (Event.RESIZE, resizeHandler2);
stage.removeEventListener (Event.RESIZE, resizeHandler4);

resizeHandler1 (null);
 function resizeHandler1 (event:Event):void 
 {
    news_mc.x = stage.stageWidth / 2 - news_mc.width / 2+ 25;
    news_mc.y = stage.stageHeight / 2 - 250;
  }
   TweenLite.from(news_mc, 4, {alpha:0});

```

Stupid I know  
but I don’t know of a better way.  
I would LOVE to learn one if someone is kind enough to explain it to me.

I am still not custom code savvy (I keep threatening to learn but flash is just a hobby for me and I have not had the time this past year so…)

Could someone show me the proper way to code multiple “listeners, and handlers” or make one handler work throughout the entire movie on the timeline using AS3.

also when the the playhead advances to a mc which has its own handler I often get this ghosting outline of a box scaling  
it is really quick but also really distracting to me.  
you can see an example of what I mean on my site when you click the “about” or “contact” buttons.

> **[SHAWNCONVEY.COM](http://shawnconvey.com/)**
>
> Shawn spent a decade as a photographer in New York and Chicago before deciding to move abroad and concentrate on film. He settled in Bosnia and Herzegovina in search for a story that humanized the people and region, as opposed to perpetuating the...

thanks everyone I really appreciate your help.
