PDA

View Full Version : Loading AS2/other SWF into Flash CS3 (as3) project - Scaling Issues


tmeh
09-10-2008, 06:34 PM
Hello,

I've been buggering about gettin this fixed for quite some time now, and have decided I should probably see if someone can help me out, and save me alot more time.

Basically I am loading an external SWF (mostly AS2 games) into a an AS3 project (Flash CS3). I have tried loading it into a movieclip holder, and also adding the loader, and content, directly onto the stage.

My problem is that there are numerous scaling issues with this. Since the SWF's come in varied dimensions, and I would like them all to fit in the same space, I am trying to reduce their size to fit this area. I have attempted scaling/force defining dimensions for the loader, the loader's content, and the holder MC, and none of these seem to work properly consistantly .

Basically I use the loader info to determine the dimensions of the SWF I am loading, and then redefine it (it being the loader, content, or mc holder - i've tried them all) to fit the height I want, and adjust the width to match the aspect ratio.

When I try this, the loaded SWF seems to change to random sizes, even so much so that it will be different upon re-publishing the flash file numerous times.

As an example, lets say I load an external SWF that is 400x300 onto a stage that is 600x400, and I am trying to get the SWF to be 200x[whatever maintains aspect ratio]. The result is that the SWF's height ends up being about 20% or even 60-70% of the stage, visually. When I decide to trace the width/height of the SWF AFTER it has been resized, and looks wrong on stage, it returns the correct dimensions (200x[whatever]). Why would it be doing this? It says it has been resized properly via trace, but what I see is completely different.

So after trying a million game SWF's to load, some of the actually work (locally) by chance. So I decide to upload it a webserver, and try it out there. Well, here is another problem which boggles my mind. When I open the site with IE7, the SWF (1/1000000 that actually worked locally), scales perfectly and functions. However, when I open the site with FF, again the scaling goes all bonkers, and decides it wants to be 80% the height, for example, of the space I'm trying to fit it in, and thus 80% of the height it appeared as in IE7. And also, it rarely, but sometimes DOES work in FF. This is the same webpage with the same Flash AS3 swf loading the SAME game swf. Same conditions, completely varied results.

Would anyone know why trying to resize an loaded SWF is so buggy? and ideally, anyone know how to fix this problem?

To reiterate, I want to scale a swf I am loading, and have been incapable because it decides to be any random dimensions it wants to when I try scaling it.

Any help or direction would be greatly greatly appreciated, as I have not been able to find any help or documentation of these errors online, and it is driving me crazy.

Thank you very much in advance if you can offer any help.

-
G

hobbis
09-11-2008, 04:26 AM
Not sure if this helps, but sometimes when loading through the browser, there is a delay when the swf has loaded and all of the properties may not be available yet. Maybe you are calling the resize functions a little too soon. This used to be a problem with MovieClipLoader in AS2 but I am surprised it is happening with AS3.

Also, if you have masks in your loaded movies, this will give odd behaviours as the size of the movieclip includes everything which means if there is a movieclip outside of your swf document boundries, you will have a larger than expected clip.

tmeh
09-11-2008, 11:03 PM
Thanks for the reply.

I call the functions after the SWF has been completely loaded, so perhaps I'll try to tag on an additional timer, and see if that makes a difference.
Regarding the objects off-stage adding to the loaded SWF's dimensions, does this also apply when I scale the SWF? So if I set the loaded SWF's width to 200, will this mean 200 includes all the out-of-view elements in the loaded swf? This still would not explain why it would work in IE7 and only sometimes in FF though. Interesting buggery isnt it?

-
G

hobbis
09-12-2008, 07:31 AM
Yes to your question regarding out-of-view elements although this doesn't sound like the actual problem as you're right, FF and IE should behave exactly (fingers crossed) the same way.

Maybe the delay will sort it out?

tmeh
09-15-2008, 05:59 AM
hello again

so i've tried the delay, and that did not fix the issue at all.

still stuck and tryin to figure this one out :P

tmeh
09-18-2008, 11:47 PM
UPDATE:

Ok so the problem does seem to revolve around this stage sizeing issue.

For example, I made my own SWF to load as an AS3 file, with 4 squares, one in each corner of the stage. When I loaded this swf, everything worked perfectly.

I then went back to this SWF, and added 2 more squares off the stage to the right. I published this new SWF and tried loading it into my same container, and it screwed up. The results are interesting. When I trace the dimensions of the SWF, they give me the correct stage width/height. However, when I attempt to resize the SWF, it resizing the ENTIRE swf, including all the objects offstage.

For a more clear example, here is the situation with the swf that I made myself:
The stage is 600x400. I placed a square in each corner, and a square off stage to the right at 620 (the square is 30x30). When I load the swf inside another project, and resize the width to 400, it resizes the entire 650 (this is the stage + the extra object offstage) into the 400..
So what I see is that within the now 400px holder, there is the 4 squares in each corner of my 600x400 swf, AND the extra square off to the right at 630.

Is there any way to change this, so that I can ignore off-stage elements inside a loaded swf.
Due to the difference between many games out there (which is what I am trying to load), I have been unable to write a script that consistently scales each SWF in the same way.

Any help would be appreciated. Perhaps someone could point Senocular in my direction :)

Cheers

-
G