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(swfMaterial, 256, 512, 1, 1);
back.rotationY = 180;
back.mouseEnabled = true;
back.z += 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(swfMaterial, 256, 512, 1, 1);
back.rotationY = 180;
back.mouseEnabled = true;
back.z += 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