Any SWF has a default size baked into its header.  That size is reported in 
LoaderInfo.  The SWF can put displayobjects and draw graphics anywhere and that 
will affect the width/height of the Loader instance.

One way to diagnose this would be to use Flash to build an AS2 SWF so you can 
poke at the loaded SWFs display list.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Jonathon Stierman
Sent: Monday, May 11, 2009 9:21 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Loader coming back with incorrect dimensions




Thanks, Tracy --

Does that still apply even when the loaded SWF is not built with the Flex 
framework?

Note - I am actually not using the Flex framework at all in this project.  It's 
a pure AS3 application.  Sorry, I forgot to mention that.

My specific code looks like this:
var request:URLRequest = new URLRequest(path);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSwfComplete, false, 
0, true);
...
private function onSwfComplete(event:Event):void
{
      var loaderInfo:LoaderInfo     = event.target as LoaderInfo;
      var loader:Loader             = loaderInfo.loader;

      Out.out(this, "loaderInfo ("+loaderInfo.width+", "+loaderInfo.height+")");
      Out.out(this, "loader ("+loader.width+", "+loader.height+")");

      checkComplete();
}

The Out.out calls are a simple trace utility - and they report:
[Out] [BootstrapTask] says, "loaderInfo (441, 331)"
[Out] [BootstrapTask] says, "loader (2252.3, 2464.8)"

Very strange to me - I've never had them report different values.  But then 
again, I've never tried loading an Illustrator exported SWF either..

Jonathon

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Tracy Spratt
Sent: Monday, May 11, 2009 11:13 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Loader coming back with incorrect dimensions




There are timing issues with SWFLoader.  Perhaps the loaded swf has not 
completed its layout when you check the size?  A loaded swf is not ready on the 
loader.complete event, you must wait for the applicationComplete event.

Tracy Spratt,
Lariat Services, development services available
________________________________
From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Jonathon Stierman
Sent: Monday, May 11, 2009 11:57 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Loader coming back with incorrect dimensions





Has anyone run across a Loader instance incorrectly reporting the width/height 
of the SWF file it is loading?

Information about the application:
1.  The SWF files I am loading are generated via a File>>Export command out of 
Adobe Illustrator.  This causes it to come out as an AVM1Movie.
2.  I am loading these SWF files into an AVM2 SWF via the Loader class.  Some 
of them correctly give me the dimensions, and some of them do not.
3.  Oddly enough, on the incorrectly sized content, the Loader's LoaderInfo 
instance contains the correct dimensions.

My initial reaction was to look at the content in Illustrator and see if maybe 
some vector data was being included in the SWF way offscreen (the incorrect 
dimensions are always larger) - thus causing the SWF to report a larger width 
than I am expecting.   But I do not see any content in the Illustrator that 
would do that.

I know there is some issues with loading AVM1 content into an AVM2 SWF - I 
wouldn't think the dimensions would be something affected by this, but you 
never know.

Anyone have any ideas on what else to look at?

Jonathon

Reply via email to