How to embed swf with it's original, unknown size?

1,142 views
Skip to first unread message

danyalejandro

unread,
Aug 29, 2009, 6:18:59 PM8/29/09
to SWFObject
Hi

I made an SWF that loads data from a database and dispays the results
as a vertical list; therefore, the height of the swf varies depending
on the stored data.

Whitout using SWFObject, I have no problems embedding the SWF. It's
height varies depending on how much content it's displaying. This is
my desired behaviour.

When I try to dynamically insert said SWF in my pages with swfobject,
I can only see it if I specify a fixed height. If I try using
width="100%", the swf dissapears.

How can I tell SWFObject to use the swf's original height? this is my
relevant code (all of it is inside the <body>):

<script type="text/javascript">
var flashvars = {};
var params = {};
params.play = "true";
params.loop = "false";
params.quality = "high";
params.wmode = "transparent";
params.allowscriptaccess = "sameDomain";
var attributes = {};
attributes.id = "MapaEstrategico";
attributes.name = "MapaEstrategico";
attributes.align = "middle";
swfobject.embedSWF("MapaEstrategico.swf", "mEstrategico", "768",
"100%", "9.0.28", "expressInstall.swf", flashvars, params,
attributes);
</script>

(...)

<div id="mEstrategico" style="width: 764px; margin: 1px auto;"
align="center"></div>

Sam Sherlock

unread,
Aug 29, 2009, 7:59:45 PM8/29/09
to swfo...@googlegroups.com
What css have you got within this page.  Setting height with percentage means you need to control the height with css

#MapaEstrategico    { height: 100% } - ought to do it
- S

chris27

unread,
Sep 29, 2009, 5:15:53 PM9/29/09
to SWFObject
Did you get a solution for this? I'm having exactly the same
problem! Been tearing my hair out - I can't believe there is no
simple solution to this. I don't know what dimensions each SWF will
be, and I don't have any control over the Actionscript code. I have a
container div and I'm adding the SWF to this using SWFObject 2.0. If I
use '100%' for the width and height properties, the SWF doesn't
display at all, as its containing div has no width or height set in
the CSS.

WHY CAN'T FLASH HANDLE THIS??? I don't want a re-sizable SWF, I just
want my containing HTML element to expand to the width and height of
each SWF as it was when it was published! It seems that you can't
dynamically add a SWF to an HTML page without giving it explicit
dimensions, and there is no simple way to find out what they should be
beforehand.

Aran Rhee

unread,
Sep 29, 2009, 6:56:03 PM9/29/09
to swfo...@googlegroups.com
Chris.
 
If you don;t know the dimensions of the swfs beforehand, then there is no way on the client-side from the page to get the dimensions. You will either need to use server side tools:
 
PHP:
 
ASP:
 
Or call a util on the server like:
 
 
The other way would be to load the swf into a wrapper swf and get it's dimensions using a class like SWFReader:
 
 
So there you go, many options for you to choose from...
 
 
Aran

Alex Harui

unread,
Sep 29, 2009, 7:37:36 PM9/29/09
to swfo...@googlegroups.com

If you load the SWF into a wrapper swf, you can just use loaderInfo to get the dimensions.  I think you can then use ExternalInterface to resize the swfObject.

 

Alex Harui

Flex SDK Developer

Adobe Systems Inc.

Blog: http://blogs.adobe.com/aharui

Aran Rhee

unread,
Sep 29, 2009, 8:25:04 PM9/29/09
to swfo...@googlegroups.com
@Alex.
 
Cheers for chiming in. This definitely works, as we have used this technique on another project. You can (optionally) use the SWFFit js project to dynamically resize the swf area as well.
 
 
Aran

chris27

unread,
Sep 30, 2009, 6:59:58 AM9/30/09
to SWFObject
Thanks Aran & Alex

So you're saying that whilst there is no way to just stick a SWF
directly into an HTML element and have it assume the correct default
size, you can create another SWF into which you load the original SWF
and use a Loader instance's loaderInfo to detect the dimensions of the
'content' SWF? That makes sense - then as you say it would be easy
enough to use ExternalInterface to call a javascript function and pass
it the correct width and height, which the javascript would then use
to resize the HTML element that contains the SWF...

Cheers

Chris

On Sep 30, 1:25 am, Aran Rhee <aran.r...@gmail.com> wrote:
> @Alex.
>
> Cheers for chiming in. This definitely works, as we have used this technique
> on another project. You can (optionally) use the SWFFit js project to
> dynamically resize the swf area as well.
>
> Aran
>
> On Wed, Sep 30, 2009 at 9:37 AM, Alex Harui <aha...@adobe.com> wrote:
> >  If you load the SWF into a wrapper swf, you can just use loaderInfo to
> > get the dimensions.  I think you can then use ExternalInterface to resize
> > the swfObject.
>
> > Alex Harui
>
> > Flex SDK Developer
>
> > Adobe Systems Inc. <http://www.adobe.com/>
>
> > Blog:http://blogs.adobe.com/aharui
>
> > *From:* swfo...@googlegroups.com [mailto:swfo...@googlegroups.com] *On
> > Behalf Of *Aran Rhee
> > *Sent:* Tuesday, September 29, 2009 3:56 PM
> > *To:* swfo...@googlegroups.com
> > *Subject:* Re: How to embed swf with it's original, unknown size?
>
> > Chris.
>
> > If you don;t know the dimensions of the swfs beforehand, then there is no
> > way on the client-side from the page to get the dimensions. You will either
> > need to use server side tools:
>
> > PHP:
>
> >http://www.webmaster-talk.com/php-forum/160440-simple-php-to-find-swf...
>
> > ASP:
>
> >http://www.4guysfromrolla.com/webtech/tips/t102001-1.shtml
>
> > Or call a util on the server like:
>
> >http://www.swftools.org/swfdump.html
>
> > The other way would be to load the swf into a wrapper swf and get it's
> > dimensions using a class like SWFReader:
>
> >http://www.senocular.com/index.php?id=2.43
>
> >http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0...
>
> > So there you go, many options for you to choose from...
>
> > Aran
>
> > On Wed, Sep 30, 2009 at 7:15 AM, chris27 <chrisfrancis2...@googlemail.com>

Aran Rhee

unread,
Sep 30, 2009, 7:53:35 AM9/30/09
to swfo...@googlegroups.com
@Chris
 
Exactly.

Reply all
Reply to author
Forward
0 new messages