Link to home
Start Free TrialLog in
Avatar of elepil
elepil

asked on

How to use SWFObject with a resizable Flex application

My Flex application's mx:Application's width and height are set to 100%, so it's a resizable application.

How do I use SWFObject for a resizable Flex application?
Avatar of me655321
me655321

You looking for scale="exactfit"?
Here's what the documentation says:


swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes, callbackFn) has five required and five optional arguments: swfUrl (String, required) specifies the URL of your SWF
id (String, required) specifies the id of the HTML element (containing your alternative content) you would like to have replaced by your Flash content
width (String, required) specifies the width of your SWF
height (String, required) specifies the height of your SWF
version (String, required) specifies the Flash player version your SWF is published for (format is: "major.minor.release" or "major")
expressInstallSwfurl (String, optional) specifies the URL of your express install SWF and activates Adobe express install. Please note that express install will only fire once (the first time that it is invoked), that it is only supported by Flash Player 6.0.65 or higher on Win or Mac platforms, and that it requires a minimal SWF size of 310x137px.
flashvars (Object, optional) specifies your flashvars with name:value pairs  
params (Object, optional) specifies your nested object element params with name:value pairs  
attributes (Object, optional) specifies your object's attributes with name:value pairs
callbackFn (JavaScript function, optional) can be used to define a callback function that is called on both success or failure of embedding a SWF file (see API documentation)

So just set the width and height to "100%" in the embedding of SWF.

An example will be

swfobject.embedSWF("bj.swf", "bj", "100%", "100%", "6.0.0");

I gave the version as 6.0.0 because I do not know the version you published the SWF for, I didn't bother to check but you should change it to the published version.
You should take a look at the documentation if you haven't

http://code.google.com/p/swfobject/wiki/documentation

There are also the api documentation too, you should check it out

Look at the main page:

http://code.google.com/p/swfobject/

There is the FAQ, the API documentation and few other things you can check out.
Avatar of elepil

ASKER

TanLiHao, thanks again for responding.

If you go to http://www.pilby.us/bj/bj2.html, you will see my problem. (NOTE that it's bj2.html this time, not bj.html).

When you view the source, notice I put 100% for both width and height and height. The width works correctly, but the height is not, and I'm not sure why. Any insights?
ASKER CERTIFIED SOLUTION
Avatar of TanLiHao
TanLiHao
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elepil

ASKER

You would think that the creator(s) of SWFObject should've realized this issue even at the very early stages of testing. Granted that this is not the fault of SWFObject (since it operates within the constraints, limitations and flaws of Flash Player and/or the browser, this issue should not be in a FAQ but part of its main documentation.

Once gain, your solution worked, TanLiHao. I thank you very much for your time and effort spent helping me.
Yes I agree that it should have been part of the main documentation as many people would like to have fullscreen applications. Nevertheless, at least they put it in the FAQ.