Hi I am new to as3
I have a layer question
I know that in flash cs3 each object is given its own layer
I declare the loader object in the function
the addchild after load is complete for that picture
but it seem to be only loading the one image
that is the last image in my xml.
I am trying to get it to load all the images on the screen at once
I have the following code that loads an image on to the screen from an xml file.
this is the xml.Code:var loader:URLLoader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.TEXT; loader.addEventListener(Event.COMPLETE,loadXML); loader.load(new URLRequest("xml/main.xml")); var myXML:XML; function loadXML(evt:Event):void { try{ myXML = new XML(evt.target.data); //trace(myXML); }catch(e:TypeError){ trace("Could Not Parse the XML\n"); trace(e.message); } } function init(event:MouseEvent):void { var n = 0; var currSlide:DisplayObject; var bitmap:Loader = new Loader(); for(var i = 0;i<myXML.title.length();i++){ var stImage:String = myXML.title[i].image.toString(); bitmap.load(new URLRequest(stImage)); bitmap.x = Math.floor(50+n); bitmap.y = Math.floor(50+n); n++; addChild(bitmap); } }
Code:<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE data[ <!ELEMENT title(comments, image)> <!ATTLIST title name CDATA #REQUIRED> <!ELEMENT comments (#PCDATA)> <!ELEMENT image (#PCDATA)> ]> <data> <title name="Phone No1."> <comments>This is phone Number 1</comments> <image>img/1.jpg</image> </title> <title name="Phone No2."> <comments>This is phone Number 2</comments> <image>img/2.jpg</image> </title> <title name="Phone No3."> <comments>This is phone Number 3</comments> <image>img/3.jpg</image> </title> <title name="Phone No4."> <comments>This is phone Number 4</comments> <image>img/4.jpg</image> </title> <title name="Phone No5."> <comments>This is phone Number 5</comments> <image>img/5.jpg</image> </title> <title name="Phone No6."> <comments>This is phone Number 6</comments> <image>img/6.jpg</image> </title> <title name="Phone No7."> <comments>This is phone Number 7</comments> <image>img/7.jpg</image> </title> </data>


Reply With Quote
Bookmarks