views:

81

answers:

1

I have a complicated problem with a couple of SWFLoaders.

I have an application that loads a swf with a SWFLoader. The loaded swf loads another swf (just a compiled fla). I am adding all my resize and position logic in my loaded swf and it works good on event resize, but when I'm trying to run the same code in my swfs applicationComplete it fails. The same code on startup works great if I run my swf as a standanlone, but for some reason the scale is different when I load it into my application.

I'm just setting it's width and height to the browsers size so everything but the scale is the same!

This is my trace from my loaded swf as a standalone: swfLoader: 1435 742 FlexLoader: 1319.1 742 1.0305555555555554 1.0305555555555554

and this is from the same loaded swf when it's loaded in my application: swfLoader: 1435 742 FlexLoader: 1159.55 742 0.9053196681307955 0.9053196681307955

swfLoader is my loaded swf's swfloader that loads my compiled fla. That is what I need to resize and position to the center. The next numbers are width and height. FlexLoader is the swfLoaders loader (or content if you will). The numbers are width, height, scaleX and scaleY.

As you can see the size is the same (this is also the same for the loaded swfs application), but the scale is different. Both scales are calculated from with 1280 and height 720 wich is my compiled fla's size.

The only reason why I'm messing around with scale at all is that I can't find the accurate width of my compiled fla to center it (application.width - loadedSwf.width / 2) So if anybody knows a better way to find that I would appreciate that to very much!! :)

The part I'm not getting is why the scales are different? What part am I missing? I am completely lost and been trying to solve this for quite some time now :p

A: 

As with normal Flash Display Objects, you must set the size of an item based on its internal contents. If you take a SWF (SWFa) and load it into another (SWFb), and have SWFb tell SWFa to be wider and taller, Flash is not expanding SWFa's stage, it is scaling SWFa's stage, unless you have adjusted the StageScaleMode of SWFa to StageScaleMode.NO_SCALE. If you have done that, you still need to handle repositioning all the items on SWFa's stage when it resizes so that the items remain centered as its stage grows/shrinks.

Tegeril
The problem was actually more complicated than that, but I just managed to get it working! My compiled fla had objects outside of the set document size wich caused a problem. I did not expect it to be a differnce there at all. It looked like it was positioned right and the size was right, but apparently it wasn't.
Tinelise
Ohhh, ok, I see, well, I'm glad you got it working.
Tegeril