Update/Change params.bgcolor once loaded???

107 views
Skip to first unread message

Aaron

unread,
Jun 21, 2012, 8:57:00 AM6/21/12
to swfo...@googlegroups.com
Hello!

Once i have used "swfobject.embedSWF"
 
With the params set -- is there any way to change the values?

I have this...
 
var params = {};
params.bgcolor = "#ffffff";
 
 
But what i would like to do now - is let the user click a javascript link to change the stage color if they want.
 

I've tried this ---> document.getElementById("mySWF").setAttribute("bgcolor", "#00FF00");
 
But that didnt work.
 

Thanks for the help!

Nathan Mynarcik

unread,
Jun 21, 2012, 9:48:33 AM6/21/12
to swfo...@googlegroups.com

Set the wmode to transparent for the swf and use javascript to change the bg of the dom element that contains your swf

Nathan Mynarcik

(mobile)

--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/swfobject/-/jb5armhQppQJ.
To post to this group, send email to swfo...@googlegroups.com.
To unsubscribe from this group, send email to swfobject+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swfobject?hl=en.

Aran Rhee

unread,
Jun 21, 2012, 11:55:12 AM6/21/12
to swfo...@googlegroups.com
Yep - What Nathan says will work.

Otherwise what you will need to do is expose an ExternalInterface method on your swf which changes the color of a movieclip (which covers your stage area) inside of itself. There are a bunch of tutorials on externalInterface out on the web...

The only reason I offer that solution is that wmode=transparent brings about a bunch of browser rendering bugs (some of which have no work-arounds) - Just google wmode=transparent bug to see what I mean. Depending on the complexity of your page and whether you have layers above / below Flash, this may not be an issue for you - Just test in all the browsers you want to support thoroughly.


Cheers,
Aran

Nathan Mynarcik

unread,
Jun 21, 2012, 12:00:55 PM6/21/12
to swfo...@googlegroups.com
wmode=opaque seems to work across more browsers in my experience.

The ExternalInterface call I thought about too right after I submitted my first response.  It really depends on how comfortable you are in coding AS vs. JS and providing them to communicate to eachother.

Aran Rhee

unread,
Jun 21, 2012, 12:09:04 PM6/21/12
to swfo...@googlegroups.com
wmode=opaque does work better, but it doesn't let the color through does it? I know it places the swf in the z-index stack with the rest of the DOM elements, but I think (as the name suggests), that the BG is then opaque and will be locked to what was specified in the swf / embed call... 

Nathan Mynarcik

unread,
Jun 21, 2012, 12:12:24 PM6/21/12
to swfo...@googlegroups.com
Doh! I think you are right. Touché!

@Aaron Personally, I would do the wmode=transparent with the JS call to change the dom element's bg.  It requires less lines of code and no need to recompile the swf (if your swf doesn't have a movieclip as it's background). But either suggestion here should do the trick for ya, and both are fairly easy!
Reply all
Reply to author
Forward
0 new messages