Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-28-2008, 12:01 AM   #1
sagachoo
Registered User
 
Join Date: Mar 2008
Posts: 15
Arrow How to change param "FlashVars" via JavaScript

Hi,

I want to change FlashVars in my flash object but it doesn't work

here is my code:

function moveflashmap()
{
document.getElementById("flashmap").FlashVars = 'region=europe';

}

and my flash object

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="780" height="372" id="flashmap">
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="./flash/map.swf" />
<param name="FlashVars" value="" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent" />
<embed src="./flash/map.swf" quality="high" flashvars="region=" bgcolor="#ffffff" width="780" height="372" name="map" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />


I want to change FlashVars value to something else

please advise.

Choo
</object>
sagachoo is offline   Reply With Quote
Old 03-28-2008, 02:57 PM   #2
yell0wdart
jordanrift.com
 
Join Date: Sep 2007
Location: Phoenix, AZ
Posts: 366
Default

Well, first off, you'd be best off doing some reading on working with JS and the DOM. This site has been very useful. Specific to your problem would be parts 4 - 6.

http://www.ibm.com/developerworks/vi...Mastering+Ajax

Code:
function moveflashmap()
{ 
    // This won't work.  You're not accessing a FlashVars property of an element.  In the DOM, attributes are treated like any other node.
    document.getElementById("flashmap").FlashVars = 'region=europe'; 
}
You'd be better off doing something like this:

Code:
// First off, we need to give an ID to your <param> that contains your flashvars attribute.

<param name="FlashVars" value="" id="flash" />

// Now in our JS, we can access this node directly, rather than trying to get it through its parent.

function moveflashmap()
{ 
    var myElement = document.getElementById("flash");
    myElement.setAttribute("value", "*YOUR CUSTOM FLASHVARS GO HERE*");
    // Above, we access the value attribute of our referenced <param> element
}
__________________

bad developer

Jordan Rift
yell0wdart is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash, JavaScript and the HTML DOM (dHTML) drZoode HTML and JavaScript 10 08-21-2008 06:59 PM
Makin the button change color on release and other buttons to back in default color hardcoremore Simple Stuff (Newbies) 2 03-20-2008 01:07 PM
Simple Javascript Photo Gallery PreCoder HTML and JavaScript 0 02-25-2008 06:48 AM
javascript text color change? johnny_cat ActionScript 1.0 (and below) 0 03-24-2005 07:27 PM
Flash calling Javascript cerupcat ActionScript 2.0 4 02-11-2005 08:54 PM


All times are GMT. The time now is 11:53 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.