flash - Parsing XML with AS3 -
This is my entire script because I can not seem to know where the problem is.
The symptom is that where I add a child (book), the appropriate place for this can not be linked properly with the thumb and sequentially, and, to my surprise, the only one The way I can get them to reach is by writing a faulty trace statement, which somehow pops them in the top left corner. Any suggestions would be greatly appreciated! Thanks!
var rowsW: number; Var my_xW: number; Var my_yW: number; Var my_thumb_widthW: number; Var my_thumb_heightW: number; Var my_imagesW: XMLList; Var my_totalW: number; Var Container_mcw: Movieclip; Var preloaders_mcw: movieclip; Var book: textfield = new textfield (); Var Author: Textfield = New TextField (); Var Publisher: TextField = New TextField (); Book.selectable = true; Var x_counterW: number = 0; Var y_counterW: number = 0; Var my_tweensW: array = []; Var container_mc_tvw: middle; Var myXMLLoaderW: URLLoader = new URL loader (); MyXMLLoaderW.load (new URLRequest ("WORKS.xml")); MyXMLLoaderW.addEventListener (Event.Complete, Process XMLW); CreateContainerW (); CallThumbsW (); Function Process XMLW (E: Event): Zero {var myXMLW: XML = New XML (e.target.data); RowsW = myXMLW @ ROWS; My_xW = myXMLW @ XPOSITION; My_yW = myXMLW @ YPOSITION; My_thumb_widthW = myXMLW @ WIDTH; My_thumb_heightW = myXMLW @ HEIGHT; My_imagesW = myXMLW.IMAGE; My_totalW = my_imagesW.length (); MyXMLLoaderW.removeEventListener (Event.Complete, Process XMLW); MyXMLLoaderW = Faucet; } Function vs. Container W (): Zero {container_mcw = new movie clip (); Container_mcw X = my_xW; Container_mcw Y = my_yW; AddChild (container_mcW); Preloaders_mcW = new movie clip (); Preloaders_mcW.x = Container_mcwx; Preloaders_mcW.y = Container_mcw.a; AddChild (preloaders_mcW); } Function callThumbsW (): void {for (var i: number = 0; i & lt; my_totalW; i ++) {var thumb_urlW = my_imagesW [i]. @ THUMB; Book.text = my_imagesW [i] @ TITLE; Author.text = my_imagesW [i]. @thore; Publisher.text = my_imagesW [i] @publisher; Var thumb_loaderW = new loader (); Thumb_loaderW.load (new URLRequest (thumb_urlW)); Thumb_loaderW.contentLoaderInfo.addEventListener (Event.COMPLETE, thumbLoadedW); Thumb_loaderW.name = i; Book.x = (40) * x_counterW; Book.y = (my_thumb_heightW + 40) * y_counterW; Thumb_loaderW.x = (my_thumb_widthW + 10) * x_counterW; Thumb_loaderW.y = (my_thumb_heightW + 10) * y_counterW; Container_mcW.addChild (book); Container_mcW.addChild (author); Container_mcW.addChild (publisher); Trace ("my x is equal to" (book.x)); If (y_counterW + 1 & rowsW) {y_counterW ++; } And {y_counterW = 0; X_counterW ++; } Var preloader_pbW: progress bar = new progress bar (); Preloader_pbW.source = thumb_loaderW.contentLoaderInfo; Preloader_pbW.x = thumb_loaderW.x; Preloader_pbW.y = thumb_loaderW.y; Preloader_pbW.width = my_thumb_widthW; Preloader_pbW.height = my_thumb_heightW; Preloaders_mcW.addChild (preloader_pbW); Preloader_pbW.addEventListener (Event.Complete, PW); }} Function thumbLoadedW (E: Event): Zero {var my_thumbW: Loader = Loader (e.target.loader); Container_mcW.addChild (my_thumbW); My_tweensW [number (my_thumbW.name)] = new tween (my_thumbW, "alpha", strong. End, 0,1,0.5, true); My_thumbW.contentLoaderInfo.removeEventListener (Event.Complete, Thumb LoadedW); } Functioned PW (E: Event): Zero {var my_pbW: progress bar = Progress bar (e.target); Preloaders_mcW.removeChild (my_pbW); My_pbW.removeEventListener (event.complete, donePW); } I do not think you are loading your XML properly. You should use a URL loader, not load the loader to load the XML. Then you will need to wait for the event. The complex is triggered for parsing data and adding your text fields. Sephiroth ():
import flash.net URLLoader import flash.net.URLRequest import flash.xml.exml import flash. Event * Import Flash. Terror * Var mainXML: XML; Var loader: URL loader = new URL loader (); Loader.addEventListener (complete on event.complete); Loader.load (new URLRequest ("http://www.sefiroth.it/tutorials/flashPHP/E4X/files/test.xml")); Function expiration (EVT: Event) {Main XML = New XML (Loader Data) Trace ("XML Loaded, Starting Using E4 X Syntax"); }
Well, now you have edited your question on a large scale, yes, it is clear that you are already there, I am trying to parse you in XML, To see it, you will try to view / maintain the loader.data before trying to parse it in the XML object. It seems that you are probably getting some data, which you are not expecting.
Comments
Post a Comment