Unwanted Automatic resize of external SWF! Grrrr…

Software: Away3D 4.x

steros, Newbie
Posted: 27 November 2011 02:34 PM   Total Posts: 19

Hey guys,

I seem to have a little trouble with an externally loaded .SWF which I want to use as AnimatedBitmapMaterial. I made the SWF in the latest flash and set the dimensions to be 256x512. Than in Flash Builder I wrote the following code:

private function onCompleteHandler(event:Event):void
{
 
var swf:MovieClip MovieClip(swfLoader.content);
 
trace(swf.width ":" swf.height);
 var 
swfMaterial:AnimatedBitmapMaterial = new AnimatedBitmapMaterial(swf);
 
back = new Plane(swfMaterial25651211);
 
back.rotationY 180;
 
back.mouseEnabled true;
 
back.+= 1;
 
addChild(back);

The trace always outputs something else! this time; 596.8:597.9
which ofcourse result in the following error when I try to use that material:
Error: Invalid bitmapData! Must be power of 2 and not exceeding 2048

How is this possible? When I run the swf by it self it keeps the 256x512 but when I load it in the dimensions change. Grrrrr

I tried to change things but I shouldn’t have to right? little dirty tricks… but none of them helped. I tried the following:

private function onCompleteHandler(event:Event):void
  {
 
var swf:MovieClip MovieClip(swfLoader.content);
 
trace(swf.width ":" swf.height);

 
swf.width 256;
 
swf.height 512;
 
trace(swf.width ":" swf.height);

 
swf.width Math.round(swf.width);
 
swf.height Math.round(swf.height);
 
trace(swf.width ":" swf.height);

 
swf.width 256.0000000000000000000000000;
 
swf.height 512.0000000000000000000000000;
 
trace(swf.width ":" swf.height);

 var 
swfMaterial:AnimatedBitmapMaterial = new AnimatedBitmapMaterial(swf);
 
back = new Plane(swfMaterial25651211);
 
back.rotationY 180;
 
back.mouseEnabled true;
 
back.+= 1;
 
addChild(back);

This was the output:
600.05:590.9 //See!? the output is different!
256.05:512
256.05:512
256.05:512

So… Is there anything I could do different? I hope I’m making an obvious mistake. Thanks guys!
Happy coding

   

Avatar
Fabrice Closier, Administrator
Posted: 27 November 2011 09:35 PM   Total Posts: 1265   [ # 1 ]

Its not about the scale ratio of the swf, it’s about its content.
You need to have in your swf, the content in all frames at a given power of 2 size.
A quick trick here is to make a rect say 256x 512 filled of 0.0001 alpha, then ensure that every frame the content of stays exactly within this bounds.

When you say new Plane(swfMaterial, 256, 512, 1, 1);
You do ask the engine to build a plane of w 256 and 512 h. with subdivision 1. Thats all. Nothing about the material. tho, of course, as its mapped 0-1, all material applied will be displayed on it at this dimension. Streched, compressed or 1 on 1…  So if you apply the above regarding the swf, it will be displayed 1 on 1 on your plane.

   

steros, Newbie
Posted: 28 November 2011 07:53 AM   Total Posts: 19   [ # 2 ]

Aha :D
Thanks again Fabrice! That trick is gonna help so much smile It’s an old game I made when I just started actionscripting so just throwing over a rect. with the desired dimensions wil help a lot :D

But the fact that I went in to that .fla and changed the stage dimensions doesn’t matter from the moment I place anything outside of(or bigger than) the scope of the stage for that specific swf… hmmmm ok
Than I’ll set the stage dimensions back to 400X600 (original) and I’ll make a rectangle of 1024x1024 with an incredibly low alpha to keep the dimensions.
I choose 1024x1024 because when it resizes it becomes more than 512 in both dimensions.
I gonna try it right away! :D

Thanks!

   

steros, Newbie
Posted: 28 November 2011 09:50 AM   Total Posts: 19   [ # 3 ]

It didn’t work! But now it does! :D haha
First of all when I added the 1024X1024 flash changed it to 1024x1023.06 for some reason :S. It seems like I can load it in now. I get some new errors but that is from within the SWF so thats one step further! smile

Thanks!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X