Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx"
- width="640" height="420">
- <fx:Script>
- <![CDATA[
- private var file:File;
- private var fileStream:FileStream;
- private var xml:XML;
- private var xmlList:XMLList;
- private var total:int;
- protected function load(event:MouseEvent):void
- {
- file = new File();
- file.addEventListener(Event.SELECT, file_select);
- file.browseForOpen("Please select a file...", [new FileFilter("XML", "*.xml")]);
- }
- protected function file_select(event:Event):void
- {
- fileStream = new FileStream();
- fileStream.open(file, FileMode.READ);
- xml = new XML(fileStream.readUTFBytes(fileStream.bytesAvailable));
- xmlList = xml.SubTexture;
- total = xmlList.length();
- fileStream.close();
- var strings:Vector.<String> = new Vector.<String>();
- for (var i:int = 0; i < total; i++) {
- strings.push("public static var " + xmlList[i].@name.split(".")[0] + ":Rectangle = new Rectangle(" + xmlList[i].@x + " , " + xmlList[i].@y + " , " + xmlList[i].@width + " , " + xmlList[i].@height + ");");
- ta.appendText(strings[i] + "\n");
- }
- }
- ]]>
- </fx:Script>
- <fx:Declarations>
- <!-- Place non-visual elements (e.g., services, value objects) here -->
- </fx:Declarations>
- <s:TextArea id="ta" left="10" right="10" top="40" bottom="10"/>
- <s:Button x="10" y="10" label="Load File" click="load(event)"/>
- </s:WindowedApplication>
Advertisement