actionscript 3 - loading texts from XML into flash AS3? -
I have this XML that shows some data from mysql database.
I need to draw some of them from XML data (i.e. name, value, etc.) and show them in the flash application.
Now, I can drag images into them in the flash but I have trouble displaying the texts from XML in Flash.
This is the structure of my XML:
& lt; Data & gt; & Lt; ID & gt; 127 & lt; / Id & gt; & Lt; Name & gt; Example 1 & lt; / Name & gt; & Lt; Price & gt; 12 !! & Lt; / Pricing & gt; & Lt; Image & gt; Inventory_images / 127.jpg & lt; / Image & gt; & Lt; Date & gt; March 08, 2013 & lt; / Date & gt; & Lt; / Data & gt; and this code (Flash AS3) will display the image of the product in the flash.
stop (); Import Flash.Display.Loader; Import flash.events.Event; Import flash.net.URLRequest; Var xmlLoader: URL loader; Var xml: XML; Var xml list: XMLList; Var uRequest = new URLRequest ("PATH-TO-MY-XML-FILE"); XmlLoader = New URL loader (URIEVEST); XmlLoader.addEventListener (event.complete, on XML load); Var imgLoader: Loader; Function On XML Load (e: Event) {xml = new e.target.data); ImgLoader = new loader (); ImgLoader.contentLoaderInfo.addEventListener (Event.Complete, On-Emago Loaded); ImgLoader.load (new URLRequest (xml.Data.Image.text () [0])); } IMG loaded at the event (E: event) {ADBIL (IMGLODER); ImgLoader.height = 300; ImgLoader.width = 300; } Can anyone help me with this?
Thanks in advance.
So if I correctly understand your question, loading the image and displaying the part If you want to display your text, then you can just use TextFields like this: XML load at the function (e: event) {xml = new XML (e.target .data); Var tf: textfield = new textfield (); Tf.text = xml.Name.text () [0]; // or whatever part you addchild (tf); //, you want to move the TF}} Flex labels will also work ...
Edit: I also think For example, you can use a dynamic textfield called 'myTextField', for example, and then your code:
var myString: string = 'load'; Function On XML Load (e: Event) {xml = new e.target.data); MyTextField.text = "" + xml.Name.text () [0]; }
Comments
Post a Comment