RSS
email

Passing XML to Flash from Html



step1: open new flash document

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

var xm:XML = new XML();
xm.ignoreWhite = true;
xm.parseXML(str1);
_root.createEmptyMovieClip("text_holder", _root.getNextHighestDepth());
_root.text_holder._x = 100;
_root.text_holder._y = 100;
_root.text_holder.createTextField("txt1", _root.text_holder.getNextHighestDepth(), 0, 0, 0, 0);
_root.text_holder.txt1.autoSize = "left";
_root.text_holder.txt1.text = xm.firstChild.childNodes[0].childNodes[0].firstChild;

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
<div id="flashcontent">
This text is replaced by the Flash movie.
</div>

<script type="text/javascript">
var str="<root>\n"+
"<author>\n"+
"<name>\n"+
"sara</name>\n"+
"</author>\n"+
"</root>";

var so = new SWFObject("usingswf.swf", "mymovie", "550", "400", "8", "#336699");
so.addVariable("variable1", str);

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

step9: open the html document.....


my code

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


<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>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="<root>\n"+
"<author>\n"+
"<name>\n"+
"sara</name>\n"+
"</author>\n"+
"</root>";

var so = new SWFObject("usingswf.swf", "mymovie", "550", "400", "8", "#336699");
so.addVariable("variable1", str);

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


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


var str1:String = unescape(_root.variable1);
var xm:XML = new XML();
xm.ignoreWhite = true;
xm.parseXML(str1);
_root.createEmptyMovieClip("text_holder", _root.getNextHighestDepth());
_root.text_holder._x = 100;
_root.text_holder._y = 100;
_root.text_holder.createTextField("txt1", _root.text_holder.getNextHighestDepth(), 0, 0, 0, 0);
_root.text_holder.txt1.autoSize = "left";
_root.text_holder.txt1.text = xm.firstChild.childNodes[0].childNodes[0].firstChild;




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.