Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-07 Thread Ian Thomas
Juan,
  (Yeah, it was me on Flash_Tiger... :-) )

  To be fair, I'd have suggested that to Andrew a while back, except he said:

 Thanks Steve.  I thought maybe I was onto something with the LoaderInfo 
 classes width and height props that
 return the nominal w and h, but this information doesn't seem to jive with 
 what I'm observing.

  So I assumed he'd already tried it. :-)

  But to add to the SWF header debate etc. - I believe the
loaderInfo.width and .height gives you what's in the header, so I
don't think there's much point in actually parsing the header, because
you'll get the same info. Andrew - I suspect there's something else
going on in terms of scaling or some such, because I believe that
loaderInfo.width and loaderInfo.height should be giving you valid
results -- it may be that for some reason you're interpreting them
incorrectly. Wwrong frame of reference? Ignoring the scaling of the
Loader class? Try loaderInfo.width*loader.scaleX, for example...

HTH,
 Ian

On Tue, Oct 7, 2008 at 2:33 AM, Juan Pablo Califano
[EMAIL PROTECTED] wrote:
 PD:

 I think someone at Flash_Tiger just found a way simpler and more straight
 forward means to get the stage size:


 Try loaderInfo.width and loaderInfo.height.


 http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html


 Cheers
 Juan Pablo Califano

 2008/10/5, Juan Pablo Califano [EMAIL PROTECTED]:

 Hi Andrew,

 I'm not sure were the problem could be, but checking both swf's I got
 640x480 and 600x200, which seems right. If I open the swf standalone (I
 mean double clicking on it), the player opens it with those dimensions.
 Plus, I've converted the to fla just to check the dimensions and I got back
 the same values.

 What the swf header contains is the size of the stage, or, in other words,
 the size you set for the fla document at author time (if you're using the
 Flash IDE; in that case, it's the numbers you set using the size button in
 the properties panel).

 I've also checked with another player from youtube and the size of the swf
 is 480x387, which seems to match with the rebuilt fla and with what I see in
 the site.

 Maybe those swf's are being scaled, cropped or masked by other means ?
 (when embedding, for instance) It's just a thought, anyway, perhaps if you
 post the url of the page that contains those swfs, someone is able to figure
 out why there's a difference between what you see on the screen and the
 swf's stage size.


 Cheers
 Juan Pablo Califano


 2008/10/5, Andrew Sinning [EMAIL PROTECTED]:

 Hi Juan Pablo,

 I just got back to this problem and tested your SwfHeader class.  From the
 few tests that I've run, this returns exactly the same dimensions that the
 LoaderInfo class does.

 I'm still stuck.  Here's an example of a swf on YouTube:

   http://www.youtube.com/v/C7PH3GVj104

 The LoaderInfo/SwfHeader dimensions are 640x320, but the actual dimensions
 appear to be 320x180.

 This swf


 http://client.shoutlet.com/static/imageplayer/viewer.php?config=http://client.shoutlet.com/file/64/5863.xml

 Looks to be actually 400x200 but the LoaderInfo/SwfHeader dimensions are
 600x200.


  Juan Pablo Califano wrote:



 http://pastebin.be/14115   (SwfHeader class)

 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-07 Thread Andrew Sinning

Hi Ian,

Some of what I'm seeing is that quite a few of the swfs that I happen to 
be loading contain their own internal scaling functions.  Most typically 
I'm seeing are swfs that automatically scale to stage.stageWidth and 
stage.stageHeight.  This is for the most part easy to detect, but there 
are some timing issues -- the scaling doesn't happen right away.


A different issue that I'm seeing is with the videos on YouTube.  The 
expectation is that end users will want to appropriate YouTube videos in 
their own content.  Here are two randomly selected addresses parsed out 
of the embed tags:



   url = 'http://www.youtube.com/v/PbeMwl_PA6Ahl=enfs=1'
   url = 'http://www.youtube.com/v/Jag7oTemldYhl=enfs=1'


When loaded into a parent swf, these both have loaderInfo.width/height 
of 640x480.  This differs from the width and height specified by the 
YouTube provided embed tags of 425x344, but that's not the problem.


Here's the problem, when I load these into a parent swf, with absolutely 
no scaling (I've checked, scaleX and scaleY are 1.0), the visible 
dimension of these videos is 480x385.  This size seems to have no 
relationship to the size of the parent stage at all, whether it is 
100x100 or 1000x1000. 


This is the method that I am using to bring in the swf:

   var loader:Loader = new Loader();
   var request:URLRequest = new URLRequest(url);
   loader.load(request);
   addChild(loader);   



Here's the function I use to determine the opaque rectangle of a loader 
object. 


   function getLoaderRect(loader:Loader):Rectangle {
   // start with a bitmap big enough for the end loader
   //note: it needs to be at least as big as the stage, 
because some swfs will automatically size to the stage
   var w:Number = 2*Math.floor(Math.max(stage.stageWidth, 
loader.contentLoaderInfo.width));
   var h:Number = 2*Math.floor(Math.max(stage.stageHeight, 
loader.contentLoaderInfo.height));
   var widgetBmp:BitmapData = new BitmapData(w, h, true, 
0x);

   // copy the loader into the bmp
   widgetBmp.draw(loader);
   // get the rectangle around the non-transparent pixels
   var rect:Rectangle = widgetBmp.getColorBoundsRect(0xFF, 
0x, false);

   return rect;
   }

This function is not at all fool-proof because at any given time while 
playing, the opaque area can change.  As we all know, it's not uncommon 
for there to be stray bits lying off to the side of the stage.  It's 
also typical for projects to contain only a small loading animation at 
the beginning.


From what I can tell so far, arbitrarily loaded swfs will fall into one 
of three categories:


1) swfs that have their own internal scaling functions that vary 
depending on the size of the parent swf.
2) swfs that correctly reflect the nominal w and h of their loaderInfo 
object.

3) swfs like the YouTube examples that are none of the above.



Ian Thomas wrote:

But to add to the SWF header debate etc. - I believe the
loaderInfo.width and .height gives you what's in the header, so I
don't think there's much point in actually parsing the header, because
you'll get the same info. Andrew - I suspect there's something else
going on in terms of scaling or some such, because I believe that
loaderInfo.width and loaderInfo.height should be giving you valid
results -- it may be that for some reason you're interpreting them
incorrectly. Wwrong frame of reference? Ignoring the scaling of the
Loader class? Try loaderInfo.width*loader.scaleX, for example...

  


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-07 Thread Ian Thomas
Hi Andrew,
   As far as I remember, the YouTube .swf is a shell around an .flv.

   So the dimensions of the shell .swf may bear absolutely no
resemblance at all to the size of the contained video; and off-hand, I
can't think of a way to get at the contained video size. But aren't
they all consistent in YouTube - I mean - does it ever vary?

  In other words, I think your loaderInfo.width and loaderInfo.height
are correct _for the Youtube shell .swf_ - but it, in turn, contains
an FLV, and you have no way to get at that scaling.

  I'm just guessing here. :-) But AFAIK, loaderInfo.width and .height
are correctly returning the width and height encoded into the SWF
header. They do give you the stage size.

Ian

On Tue, Oct 7, 2008 at 1:39 PM, Andrew Sinning [EMAIL PROTECTED] wrote:
 Hi Ian,

 Some of what I'm seeing is that quite a few of the swfs that I happen to be
 loading contain their own internal scaling functions.  Most typically I'm
 seeing are swfs that automatically scale to stage.stageWidth and
 stage.stageHeight.  This is for the most part easy to detect, but there are
 some timing issues -- the scaling doesn't happen right away.

 A different issue that I'm seeing is with the videos on YouTube.  The
 expectation is that end users will want to appropriate YouTube videos in
 their own content.  Here are two randomly selected addresses parsed out of
 the embed tags:


   url = 'http://www.youtube.com/v/PbeMwl_PA6Ahl=enfs=1'
   url = 'http://www.youtube.com/v/Jag7oTemldYhl=enfs=1'

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-07 Thread Andrew Sinning
Of course, it's a swf around a flv.  This makes a bit more sense now.  
My guess is that the size of the flv _will_ vary, after all there are 
lots of different video formats.  The YouTube shell is going to have its 
own internal algorithms for computing the scaling of the flv and the 
placement of the nav bar.  These factors will determine the resulting 
opaque area.


I'm still a bit confused though, because I'm wondering where does the 
YouTube shell get its information about size of the stage within which 
it resides, if not from stage.stageWidth/Height.  Typically a YouTube 
shell would get loaded into an html page and the embed tags would 
specify the size and scaling options for the video.  The standard 
YouTube supplied embed tags specify a size of 425x344, but I just did a 
test, editing the tag for both a smaller and a larger rect:  the video 
gets scaled accordingly.  So, it looks like the YouTube shell is 
dynamically scaling depending on the size of the stage within which it 
resides.  However, when I wrap it in my own shell, it always gets 
displayed at 480x385.


Of course, my intent isn't to obsess about how YouTube videos get 
displayed, but rather to tackle the generalized problem:  A user 
supplies the url (or embed code) for some arbitrary content that they 
want to include in their own presentation (e.g. a quiz).  It's easy 
enough to parse out the url of the content and load it into the 
presentation swf.  The difficult part is figuring how to size the loaded 
swf to fit within a predefined layout.  Some swfs should be 
cropped/masked to their nominal size and then scaled to fit the 
layout.  Some swfs contain internal scaling functions that will reflect 
the stage size of the presentation swf.  Other swfs don't fit nicely 
into either of these categories.



Ian Thomas wrote:

Hi Andrew,
   As far as I remember, the YouTube .swf is a shell around an .flv.

   So the dimensions of the shell .swf may bear absolutely no
resemblance at all to the size of the contained video; and off-hand, I
can't think of a way to get at the contained video size. But aren't
they all consistent in YouTube - I mean - does it ever vary?

  In other words, I think your loaderInfo.width and loaderInfo.height
are correct _for the Youtube shell .swf_ - but it, in turn, contains
an FLV, and you have no way to get at that scaling.

  I'm just guessing here. :-) But AFAIK, loaderInfo.width and .height
are correctly returning the width and height encoded into the SWF
header. They do give you the stage size.

Ian

On Tue, Oct 7, 2008 at 1:39 PM, Andrew Sinning [EMAIL PROTECTED] wrote:
  

Hi Ian,

Some of what I'm seeing is that quite a few of the swfs that I happen to be
loading contain their own internal scaling functions.  Most typically I'm
seeing are swfs that automatically scale to stage.stageWidth and
stage.stageHeight.  This is for the most part easy to detect, but there are
some timing issues -- the scaling doesn't happen right away.

A different issue that I'm seeing is with the videos on YouTube.  The
expectation is that end users will want to appropriate YouTube videos in
their own content.  Here are two randomly selected addresses parsed out of
the embed tags:


  url = 'http://www.youtube.com/v/PbeMwl_PA6Ahl=enfs=1'
  url = 'http://www.youtube.com/v/Jag7oTemldYhl=enfs=1'



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

  


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-06 Thread Juan Pablo Califano
PD:

I think someone at Flash_Tiger just found a way simpler and more straight
forward means to get the stage size:


Try loaderInfo.width and loaderInfo.height.


http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html


Cheers
Juan Pablo Califano

2008/10/5, Juan Pablo Califano [EMAIL PROTECTED]:

 Hi Andrew,

 I'm not sure were the problem could be, but checking both swf's I got
 640x480 and 600x200, which seems right. If I open the swf standalone (I
 mean double clicking on it), the player opens it with those dimensions.
 Plus, I've converted the to fla just to check the dimensions and I got back
 the same values.

 What the swf header contains is the size of the stage, or, in other words,
 the size you set for the fla document at author time (if you're using the
 Flash IDE; in that case, it's the numbers you set using the size button in
 the properties panel).

 I've also checked with another player from youtube and the size of the swf
 is 480x387, which seems to match with the rebuilt fla and with what I see in
 the site.

 Maybe those swf's are being scaled, cropped or masked by other means ?
 (when embedding, for instance) It's just a thought, anyway, perhaps if you
 post the url of the page that contains those swfs, someone is able to figure
 out why there's a difference between what you see on the screen and the
 swf's stage size.


 Cheers
 Juan Pablo Califano


 2008/10/5, Andrew Sinning [EMAIL PROTECTED]:

 Hi Juan Pablo,

 I just got back to this problem and tested your SwfHeader class.  From the
 few tests that I've run, this returns exactly the same dimensions that the
 LoaderInfo class does.

 I'm still stuck.  Here's an example of a swf on YouTube:

   http://www.youtube.com/v/C7PH3GVj104

 The LoaderInfo/SwfHeader dimensions are 640x320, but the actual dimensions
 appear to be 320x180.

 This swf


 http://client.shoutlet.com/static/imageplayer/viewer.php?config=http://client.shoutlet.com/file/64/5863.xml

 Looks to be actually 400x200 but the LoaderInfo/SwfHeader dimensions are
 600x200.


  Juan Pablo Califano wrote:



 http://pastebin.be/14115   (SwfHeader class)

 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-05 Thread Andrew Sinning

Hi Juan Pablo,

I just got back to this problem and tested your SwfHeader class.  From 
the few tests that I've run, this returns exactly the same dimensions 
that the LoaderInfo class does.


I'm still stuck.  Here's an example of a swf on YouTube:

   http://www.youtube.com/v/C7PH3GVj104

The LoaderInfo/SwfHeader dimensions are 640x320, but the actual 
dimensions appear to be 320x180.


This swf

   
http://client.shoutlet.com/static/imageplayer/viewer.php?config=http://client.shoutlet.com/file/64/5863.xml


Looks to be actually 400x200 but the LoaderInfo/SwfHeader dimensions are 
600x200.




Juan Pablo Califano wrote:



http://pastebin.be/14115   (SwfHeader class)

Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

  


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-05 Thread Juan Pablo Califano
Hi Andrew,

I'm not sure were the problem could be, but checking both swf's I got
640x480 and 600x200, which seems right. If I open the swf standalone (I
mean double clicking on it), the player opens it with those dimensions.
Plus, I've converted the to fla just to check the dimensions and I got back
the same values.

What the swf header contains is the size of the stage, or, in other words,
the size you set for the fla document at author time (if you're using the
Flash IDE; in that case, it's the numbers you set using the size button in
the properties panel).

I've also checked with another player from youtube and the size of the swf
is 480x387, which seems to match with the rebuilt fla and with what I see in
the site.

Maybe those swf's are being scaled, cropped or masked by other means ? (when
embedding, for instance) It's just a thought, anyway, perhaps if you post
the url of the page that contains those swfs, someone is able to figure out
why there's a difference between what you see on the screen and the swf's
stage size.


Cheers
Juan Pablo Califano


2008/10/5, Andrew Sinning [EMAIL PROTECTED]:

 Hi Juan Pablo,

 I just got back to this problem and tested your SwfHeader class.  From the
 few tests that I've run, this returns exactly the same dimensions that the
 LoaderInfo class does.

 I'm still stuck.  Here's an example of a swf on YouTube:

   http://www.youtube.com/v/C7PH3GVj104

 The LoaderInfo/SwfHeader dimensions are 640x320, but the actual dimensions
 appear to be 320x180.

 This swf


 http://client.shoutlet.com/static/imageplayer/viewer.php?config=http://client.shoutlet.com/file/64/5863.xml

 Looks to be actually 400x200 but the LoaderInfo/SwfHeader dimensions are
 600x200.


  Juan Pablo Califano wrote:



 http://pastebin.be/14115   (SwfHeader class)

 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-03 Thread Andrew Sinning
Thanks Juan.  I have a question about the internal class SwfRect that's 
at the end of the SwfHeader class.  I'm really new to AS3, so this will 
sound like a really dumb question:  Where does the internal class 
SwfRect go?  It's outside of the package.  Can it be in the same file?  
Does it need to be inside of a package?


Thanks!

Juan Pablo Califano wrote:

http://pastebin.be/14115   (SwfHeader class)


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-03 Thread Juan Pablo Califano
Actionscript 3.0 allows only one public symbol (class, function, variable or
constant) per .as file. I made that class internal so I could put both
classes in just one file for this sample, but apart from that, it's not
neccesary, really.

Cheers
Juan Pablo Califano


2008/10/3, Andrew Sinning [EMAIL PROTECTED]:

 Thanks Juan.  I have a question about the internal class SwfRect that's at
 the end of the SwfHeader class.  I'm really new to AS3, so this will sound
 like a really dumb question:  Where does the internal class SwfRect go?
  It's outside of the package.  Can it be in the same file?  Does it need to
 be inside of a package?

 Thanks!

 Juan Pablo Califano wrote:

 http://pastebin.be/14115   (SwfHeader class)


 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread Steve Mathews
No, this is not easy. Unfortunately the data that defines the stage size is
not directly available in AS code. I believe it is only in the swf
file's header, so you would actually have to do a lot of work to figure out
what size the swf should be masked at.
Steve

On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning [EMAIL PROTECTED]wrote:

 I'm using AS3.  After loading in an arbitrary swf using the Loader class,
 getRect and getBounds don't necessarily reveal the internally defined
 boundaries of the loaded swf, rather they seem to return the boundaries of
 the stuff inside the loaded swf which can be either smaller or larger than
 the internally defined boundaries.  Am I missing something?

 I want to load in a swf, create a mask around it so that only the stuff
 that is supposed to show is shown, and then scale it to fit a target area.
  This should be easy, right?

 Thanks!
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread Steve Abaffy
Just brainstorming here, not sure if this will work. Can you not put a box
or something on the stage that is the same size as the stage. If you can
access individual components on the stage then get the size of this box and
you will know the size of the stage. Just my $0.02 worth

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steve
Mathews
Sent: Thursday, October 02, 2008 10:39 AM
To: Flash Coders List
Subject: Re: [Flashcoders] sizing an arbitrary loaded swf

No, this is not easy. Unfortunately the data that defines the stage size is
not directly available in AS code. I believe it is only in the swf
file's header, so you would actually have to do a lot of work to figure out
what size the swf should be masked at.
Steve

On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning
[EMAIL PROTECTED]wrote:

 I'm using AS3.  After loading in an arbitrary swf using the Loader class,
 getRect and getBounds don't necessarily reveal the internally defined
 boundaries of the loaded swf, rather they seem to return the boundaries of
 the stuff inside the loaded swf which can be either smaller or larger than
 the internally defined boundaries.  Am I missing something?

 I want to load in a swf, create a mask around it so that only the stuff
 that is supposed to show is shown, and then scale it to fit a target area.
  This should be easy, right?

 Thanks!
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread kris range
or if you are loading the swf files from external data source like
xml, put an attribute in your xml of the size needed.

component url=/someswf.swf width=500 height=400 /

On Thu, Oct 2, 2008 at 9:05 AM, Steve Abaffy [EMAIL PROTECTED] wrote:
 Just brainstorming here, not sure if this will work. Can you not put a box
 or something on the stage that is the same size as the stage. If you can
 access individual components on the stage then get the size of this box and
 you will know the size of the stage. Just my $0.02 worth

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Steve
 Mathews
 Sent: Thursday, October 02, 2008 10:39 AM
 To: Flash Coders List
 Subject: Re: [Flashcoders] sizing an arbitrary loaded swf

 No, this is not easy. Unfortunately the data that defines the stage size is
 not directly available in AS code. I believe it is only in the swf
 file's header, so you would actually have to do a lot of work to figure out
 what size the swf should be masked at.
 Steve

 On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning
 [EMAIL PROTECTED]wrote:

 I'm using AS3.  After loading in an arbitrary swf using the Loader class,
 getRect and getBounds don't necessarily reveal the internally defined
 boundaries of the loaded swf, rather they seem to return the boundaries of
 the stuff inside the loaded swf which can be either smaller or larger than
 the internally defined boundaries.  Am I missing something?

 I want to load in a swf, create a mask around it so that only the stuff
 that is supposed to show is shown, and then scale it to fit a target area.
  This should be easy, right?

 Thanks!
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread Andrew Sinning
Thanks Steve.  I thought maybe I was onto something with the LoaderInfo 
classes width and height props that return the nominal w and h, but 
this information doesn't seem to jive with what I'm observing.


I'm considering using BitmapData class to physically find the visible 
boarders of loaded swf, but I guess this assumes that there aren't any 
stray bits outside of the main image.


Steve Mathews wrote:

No, this is not easy. Unfortunately the data that defines the stage size is
not directly available in AS code. I believe it is only in the swf
file's header, so you would actually have to do a lot of work to figure out
what size the swf should be masked at.
Steve

On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning [EMAIL PROTECTED]wrote:

  

I'm using AS3.  After loading in an arbitrary swf using the Loader class,
getRect and getBounds don't necessarily reveal the internally defined
boundaries of the loaded swf, rather they seem to return the boundaries of
the stuff inside the loaded swf which can be either smaller or larger than
the internally defined boundaries.  Am I missing something?

I want to load in a swf, create a mask around it so that only the stuff
that is supposed to show is shown, and then scale it to fit a target area.
 This should be easy, right?

Thanks!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

  


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread Andrew Sinning
If I understand the concept, I think this would require cross-domain 
policy to be turned on for my domain.  What we're trying to do here is 
load in an arbitrary swf hosted on an arbitrary domain.


You're talking about creating a new sprite in the scope of the loaded 
swf, right? 


Steve Abaffy wrote:

Just brainstorming here, not sure if this will work. Can you not put a box
or something on the stage that is the same size as the stage. If you can
access individual components on the stage then get the size of this box and
you will know the size of the stage. Just my $0.02 worth

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steve
Mathews
Sent: Thursday, October 02, 2008 10:39 AM
To: Flash Coders List
Subject: Re: [Flashcoders] sizing an arbitrary loaded swf

No, this is not easy. Unfortunately the data that defines the stage size is
not directly available in AS code. I believe it is only in the swf
file's header, so you would actually have to do a lot of work to figure out
what size the swf should be masked at.
Steve

On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning
[EMAIL PROTECTED]wrote:

  

I'm using AS3.  After loading in an arbitrary swf using the Loader class,
getRect and getBounds don't necessarily reveal the internally defined
boundaries of the loaded swf, rather they seem to return the boundaries of
the stuff inside the loaded swf which can be either smaller or larger than
the internally defined boundaries.  Am I missing something?

I want to load in a swf, create a mask around it so that only the stuff
that is supposed to show is shown, and then scale it to fit a target area.
 This should be easy, right?

Thanks!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

  


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread Kerry Thompson
Andrew Sinning wrote:



Andrew, it looks like you sized it a bit too small. Try posting your
question in a larger font, and we'll see what we can do to help.

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread Juan Pablo Califano
As someone already said, you can grab that data from the swf header.

I've done this in C# / .NET and I've just wrote a quick and dirty port of
the header parsing part to AS 3.0. Probably there's room for optimization
but as a proof of concept I think it's ok. Also, the code could use some
clean-up and the SwfRect part is based on an API different from ByteArray,
so basically I was not using readByte() and such but calculating offsets by
hand, which could be avoided.

So, the flow would be:

1) Load the swf as binary
2) Parse the headers to get the info you're looking for
3) Use the loadBytes method from the Loader class to load the swf from the
bytearray you already have loaded.

I'm pasting the sample code in this email, but you could see it more nicely
formatted here:

http://pastebin.be/14115   (SwfHeader class)
http://pastebin.be/14116   (Mainclass)

Cheers
Juan Pablo Califano

package {
 import flash.display.Sprite;
 import flash.net.URLLoader;
 import flash.net.URLLoaderDataFormat;
 import flash.events.*;
 import flash.net.URLRequest;

 public class Main extends Sprite {

  private var urlLoader:URLLoader;
  private var swfHeader:SwfHeader;

  public function Main() {
   init();
   loadSwf(test_data.swf);
  // loadSwf(test_data_comp.swf);
  }

  private function init() {
   urlLoader = new URLLoader();
   urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, handleComplete);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
handleSecurityError);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR,
handleIoError);
  }

private function handleComplete(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace(completeHandler:  + loader.data);
   swfHeader = new SwfHeader();
   swfHeader.parse(loader.data);

}

private function handleSecurityError(event:SecurityErrorEvent):void
{
trace(securityErrorHandler:  + event);
}

private function handleIoError(event:IOErrorEvent):void {
trace(ioErrorHandler:  + event);
}

  public function loadSwf(file:String):void {
   var req:URLRequest = new URLRequest(file);
   urlLoader.load(req);
  }
 }
}
///
//


package {
 import flash.utils.ByteArray;
 import flash.utils.Endian;

 public class SwfHeader {


  public function SwfHeader() {

  }

  public function parse(rawData:ByteArray):void {
   var signature:String = rawData.readUTFBytes(3);
   var isCompressed:Boolean;

   // this is used to uncompress swf (if necesary). It can't be uncompressed
in place
   // since the first 8 bytes are not compressed...
   var buffer:ByteArray = new ByteArray();

   if (signature == FWS) {
isCompressed  = false;
rawData.position = 8;
rawData.readBytes(buffer, 0, rawData.length - 8);
   } else if (signature == CWS) {
isCompressed = true;
rawData.position = 8;
rawData.readBytes(buffer, 0, rawData.length - 8);
buffer.uncompress();
   } else {
trace(not a valid SWF);
   }

   rawData.position = 4;
   rawData.endian  = Endian.LITTLE_ENDIAN;
   var fileSize:uint  = rawData.readUnsignedInt();

   buffer.position  = 0;
   var rect:SwfRect = new SwfRect();
   rect.parse(buffer);

   trace(width:+rect.xMax);
   trace(height:+rect.yMax);

  }
 }
}


import flash.utils.ByteArray;


internal class SwfRect {

 public var xMin:uint;
 public var xMax:uint;
 public var yMin:uint;
 public var yMax:uint;

 public function SwfRect() {

 }

 /*
 RECT:

 5 parts:
 Nbits  UB[5]  (the number of bits for storing each field)
 Xmin SB[Nbits] x
 Xmax SB[Nbits] width
 Ymin SB[Nbits] y
 Ymax SB[Nbits] height
 */
 public function parse(buffer:ByteArray):void {
  // get the first 5 bits to know the size of each field
  var fieldBitSize:int = buffer[0]  3;
  // total data bits (w/o padding): the 5 bits read plus the fieldBitSize
of each field
  var rectBitSize:int  = 5 + (fieldBitSize * 4);
  // the rect struct is padded with 0'z for byte aligning...
  rectBitSize= rectBitSize + (8 - rectBitSize % 8);
  // divide by 8 to get the size of the rect in bytes
  var size:int   = rectBitSize / 8;

  var curOffset:uint = 0;

  var i:int  = 0;
  var bitPos:int = 5;  // the first bit to read:  0123 4xxx xxx xxx, etc
  var mask:int = 0;

 // int[] tmp = new int[4];
  var tmp:Array = new Array();

  while(i4) {


   var curField:int = 0;

   var bitsRead:int = 0;
   var bit:int   = 0;

   while(bitsReadfieldBitSize) {

// if we've hit the byte boundary, add 1 to the current offset in the
stream
if(bitPos % 8 == 0) {
 curOffset++;
}
// set the mask according to the position of the bit in its byte
mask = 1  (7 - (bitPos % 8));
// get the bit value applying the mask
bit = (buffer[curOffset]  mask);
// if the bit is on, shift it to its position in curField and