Groups | Blog | Home
all groups > macromedia flash sitedesign > may 2006 >

macromedia flash sitedesign : flashvars and DOM


skot:317
5/29/2006 4:58:00 PM
I thought I would try using DOM to change flv's inside my .swf. It seems to
work, yet not.

Clicking on the link should "fill" the div with the code for the swf and load
the flv. What I see is a blip (opens and closes in a split second) of it
instead. Is it a browser issue or coding?

(BTW, I'm using Mozilla and IE7 to test.)

HTML code:


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>flv_player</title>
<script language="JavaScript">
swf = "flv_player";
function change_flv(flv){
vid_html = flv;
vid_title = "Dogsitting";
params = "?myVideo="+vid_html+"&vidTitle="+vid_title;

var wc = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'
codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#
version=8,0,0,0' width='340' height='320' id='"+swf+"' align='middle'>";
wc += "<param name='allowScriptAccess' value='sameDomain' />";
wc += "<param name='"+swf+"' value='"+swf+".swf"+params+"' />";
wc += "<param name='quality' value='high' />";
wc += "<param name='bgcolor' value='#ffffff' />";
wc += "<embed src='"+swf+".swf"+params+"' quality='high' bgcolor='#ffffff'
width='340' height='320' name='"+swf+"' align='middle' swLiveConnect='true'
allowScriptAccess='sameDomain' type='application/x-shockwave-flash'
pluginspage='http://www.macromedia.com/go/getflashplayer' />";
wc += "</object>";

document.getElementById("flv").innerHTML=wc;
document.title = "FLV Player: "+vid_title;
}
</script>
</head>
<body bgcolor="#ffffff">

<div>
<p>Choose:</p>
<p>&middot; <a href="" name="dogsitting"
onclick="change_flv(name)">dogsitting</a></p>
</div>

<div id="flv">
</div>

</body>
</html>
DMennenoh **AdobeCommunityExpert**
5/31/2006 8:10:00 AM
You can do this without FlashVars simply by having a JS function modify a
variable directly in your Flash player movie. I use the following in a flv
[quoted text, click to view]

function changeVideo(fname){ if(window.brtv){
window.document["brtv"].SetVariable("theFLV", fname); window.document["brtv"].GotoFrame(0);
window.document["brtv"].Play();
}
if(document.brtv){ document.brtv.SetVariable("theFLV",
fname); document.brtv.GotoFrame(0);
document.brtv.Play(); }
}All this does is change the 'theFLV' variable within the Flash object named
'brtv'. Then it jumps to frame 1 (0 in JS) and begins play. In Flash, if
theFLV is defined I play it - and then stop on frame 2. Since I don't think
you can call a function directly from JS, I just jump back to frame 1 to
reinit.

HTH


--
Dave -
Adobe Community Expert
www.blurredistinction.com
www.macromedia.com/support/forums/team_macromedia/

AddThis Social Bookmark Button