Home Page
Favorites
Contact Us
 
HonoWeb | HonoBBS | Search | Login | Signup
 
HomeWeb DesignActionscript 2.0/3.0/Flex/Flash → actionscript 3.0 load xml file
 
 
   
User: green
Posts: 2
Joined: 2008-12-23 22:58:38
Topic
actionscript 3.0 load xml file
how to use actionscript 3.0 load and parse xml file
User:Guest
Posts:
Joined:
1

var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("data/images.xml"));

xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void
{
 trace(event.target.data);
}

User:Guest
Posts:
Joined:
2

images.xml

<images>
 <image source="images/Image1.jpg" thumb="thumbnails/Image1.jpg">Description of image 1.</image>
 <image source="images/Image2.jpg" thumb="thumbnails/Image2.jpg">Description of image 2.</image>
 <image source="images/Image3.jpg" thumb="thumbnails/Image3.jpg">Description of image 3.</image>
 <image source="images/Image4.jpg" thumb="thumbnails/Image4.jpg">Description of image 4.</image>
</images>

 

actionscript

var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("data/images.xml"));

xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void
{
 xml = XML(event.target.data);
 xmlList = xml.children();
 trace(xmlList.length());
}

2 30 1/1页 1
 
Home | Home Page | Favorites | Contact Us

Copyright ? Powered by HonoWeb 2005-2008 All rights reserved.