AS3 Write and Save XML File
import flash.net.FileReference;
public function saveXmlHandler(event:Event):void
{
var designType:String = "cover or inside page";
var pageType:String = "Hard or Soft";
var pageSize:String= "A4 ,SL, B5, DVD, A5, A4, Lands";
var ImageData:String = "image data";
var designBackground:String = "Back Image";
var TypeR:String = "Rectangle";
var pointsR:String = "x,y,w,h";
var TypeC:String = "Circle";
var pointsC:String = "r,c";
var FooterPoints:String = "x,y,w,h";
var FooterImage:String = "image data";
//<?xml version="1.0" encoding="UTF-8"?>
var xm:XML =<SharakuDesign>
<DesignType>designType </ DesignType >
<PageType>pageType</ PageType >
<PageSize>pageSize</ PageSize >
<DesignIcon>
ImageData
</DesignIcon >
<DesignBackGround>
designBackground
</DesignBackGround>
<Object>
<type> TypeR</type>
<Points> pointsR</Points>
</Object>
<Object>
<type> TypeC</type>
<Points > pointsC</Points >
</Object>
<Object>
<type> TypeC</type>
<Points> pointsC</Points>
</Object>
<Footer>
<Points> FooterPoints</Points>
<Data> FooterImage </Data>
</Footer>
</SharakuDesign >;
xm.xmlDecl = <?xml version="1.0" encoding="UTF-8"?>;
//var ba:ByteArray = new ByteArray();
//ba.writeUTFBytes(xm);
var fr:FileReference = new FileReference();
fr.addEventListener(Event.SELECT, _onRefSelect);
fr.addEventListener(Event.CANCEL, _onRefCancel);
fr.save(xm, "Saraku.xml");
}
Great tutorial, but what if I want to put custom information using an input text? I tried something like:
ReplyDeletevar designType:string = t1.text;
"t1" is my input text in the interface, but it didn't work.
thanks
actually i don't know what is your other facts. please debug your code, check the value tl at debug time.
ReplyDeletethanks
This comment has been removed by the author.
ReplyDelete