Hi all, I have done a search on this topic, but couldn’t find the right solution for me.
I’ve made a flash file which contains the following:[LIST=1]
[][COLOR=RoyalBlue]backgroundMC [/COLOR](consist of vector art made in illustrator and imported)
[][COLOR=RoyalBlue]holderMC [/COLOR](loads an external swf which contains my game)[/LIST]I want the background to scale when the Stage get resized so I used the following code as everyone else does:
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]scaleMode[/COLOR] = [COLOR=#ff0000]“noScale”[/COLOR];
[COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]align[/COLOR] = [COLOR=#ff0000]“LT”[/COLOR];
[COLOR=#000000]function[/COLOR] resizeBGCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
backgroundMC.[COLOR=#0000ff]_width[/COLOR] = [COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]width[/COLOR];
backgroundMC.[COLOR=#0000ff]_height[/COLOR] = [COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]height[/COLOR];
backgroundMC.[COLOR=#0000ff]_x[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]width[/COLOR] / [COLOR=#000080]2[/COLOR][COLOR=#000000])[/COLOR];
backgroundMC.[COLOR=#0000ff]_y[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]height[/COLOR] / [COLOR=#000080]2[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]var[/COLOR] stageL:[COLOR=#0000ff]Object[/COLOR] = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]Object[/COLOR]COLOR=#000000[/COLOR];
stageL.[COLOR=#0000ff]onResize[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
resizeBGCOLOR=#000000[/COLOR];
holderMC.[COLOR=#0000ff]_x[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]width[/COLOR] / [COLOR=#000080]2[/COLOR][COLOR=#000000])[/COLOR]-[COLOR=#000080]360[/COLOR][COLOR=#000000])[/COLOR];
holderMC.[COLOR=#0000ff]_y[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]round[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]height[/COLOR] / [COLOR=#000080]2[/COLOR][COLOR=#000000])[/COLOR]-[COLOR=#000080]150[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]addListener[/COLOR]COLOR=#000000[/COLOR];
[/LEFT]
[/FONT]
This works perfectly fine for me, but it has one glitch… :huh:
The Stage.addListener keeps on listening for the Stage to resize, but this seems to cause my game.swf to run real slow :’(
If I use
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000ff]Stage[/COLOR].[COLOR=#0000ff]removeListener[/COLOR]COLOR=#000000[/COLOR];
[/LEFT]
[/FONT]
it should be resolved, but…
Then if I resize my window the backgroundMC doesn’t, because the listener isn’t active anymore… Is there a way to resolve this?
**So to make a long story short:
**I want my Stage to resize the backgroundMC, but without causing my game.swf (which is dynamicly loaded) to run slow…
Thanks in advance