RSS
email

Passing Value to Flash from Html:



step1: open new flash document

step2: paste the below code in first frame and dont run ..

trace("please run the html page");
getURL("javascript:alert("+_root.variable1+")");

step3: save the flash movie (usingswf.fla)

step4: publish the flash movie (shift + F12) or (File->publish )

step5: html comment the object tag ()

step6: download the swfdeconcept ..here

step7: copy and paste the javascript file(swfobject.js) to the folder where html page is places

step8: paste below code next to commented object tag

<script type="text/javascript" src="swfobject.js"></script>
<div id="flashcontent">
This text is replaced by the Flash movie.
</div>

<script type="text/javascript">
var str="hello";
var so = new SWFObject("usingswf.swf", "mymovie", "400", "200", "8", "#336699");
so.addVariable("variable1", "str");

so.write("flashcontent");
</script>

step9: open the html document.....alert message with hello


Note : if no alert ...please change the Version settings to flashplayer 7 and uncheck html in format tab

----------------------------------------------------
my code

+++++++++html++++++++


<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>usingswf</title>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<!--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="550" height="400" id="usingswf" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="usingswf.swf" /><param name="quality" value="high" /><param name="bgcolor"

value="#ffffff" /><embed src="usingswf.swf" quality="high" bgcolor="#ffffff" width="550" height="400"

name="usingswf" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"

pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object-->


<div id="flashcontent">
This text is replaced by the Flash movie.
</div>

<script type="text/javascript">
var str="hello";
var so = new SWFObject("usingswf.swf", "mymovie", "400", "200", "8", "#336699");
so.addVariable("variable1", "str");

so.write("flashcontent");
</script>
</body>
</head>



+++++++++Flash++++++++

trace("please run the html page");
getURL("javascript:alert("+_root.variable1+")");



thanks to SWFDECONCEPT

Bookmark and Share

0 comments:

 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.