Flash/Actionscript 3 - import/embed XML file for export? -
how import or embed xml file can export 100% independent swf? project reads external xml file text fields , images. when export swf, none of images/text show unless have xml file in same directory. want 100% independent swf without need xml.
here have far, code tutorial:
var imagearray:array = new array(); var painterarray:array = new array(); var titlearray:array = new array(); var datearray:array = new array(); //loader event xml var loader:urlloader = new urlloader(); loader.addeventlistener(event.complete, onloaded); var xml:xml; loader.load(new urlrequest("mday.xml")); function onloaded(e:event):void { //load xml xml=new xml(e.target.data); var il:xmllist=xml.images; listlength=il.length(); //fill array xml populatearray(); } function populatearray():void { //takes properties defined in xml , stores them arrays var i:number; (i = 0; < listlength; i++) { imagearray[i]=xml.images[i].pic; titlearray[i]=xml.images[i].title; painterarray[i]=xml.images[i].painter; datearray[i]=xml.images[i].date; } }
the attached keyframe, not in separate class.
thanks.
so instead of loading in external xml file have variable contains of xml data:
var imagearray:array = new array(); var painterarray:array = new array(); var titlearray:array = new array(); var datearray:array = new array(); //assign xml xml variable. here example xml data var xml:xml = <gallery> <image name="school">image1.jpg</image> <image name="garden">image2.jpg</image> <image name="shop">image3.jpg</image> </gallery>; load();//call load function function load():void { var il:xmllist=xml.images; listlength=il.length(); //fill array xml populatearray(); } function populatearray():void { //takes properties defined in xml , stores them arrays var i:number; (i = 0; < listlength; i++) { imagearray[i]=xml.images[i].pic; titlearray[i]=xml.images[i].title; painterarray[i]=xml.images[i].painter; datearray[i]=xml.images[i].date; } }
Comments
Post a Comment