Archive for the 'Actionscript 3' Category
PaperCube without Flex and only pure AS3
Because of that comment were i was asked if the papercube will be run without Flex but also with XML-files, so i looked what is the difference between Flex Datahandling and pure AS3-Datahandling with XML. There is no big difference. Of course the Main-Classes (Document-Classes) can’t extend the UIComponent-Class and must extend the MovieClip-Class to be visible on Stage. The main difference is to handle the XML-Data. The refactored class looks like this.
package net.borishorn.pv3d.data
{
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
import net.borishorn.pv3d.events.PaperEvent;
public class PaperData extends Sprite
{
public var sides:XMLList;
public function PaperData()
{
getData();
}
private function getData():void
{
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, resultHandler);
loader.load(new URLRequest("xml/papercube.xml"));
}
private function resultHandler(event:Event):void
{
try
{
sides = new XMLList(event.target.data);
sides = sides.children();
dispatchEvent( new Event(PaperEvent.XML_DATA_LOADED, true, false));
}catch (e:TypeError)
{
trace("There was something wrong");
trace(e.message);
}
}
}
}
The whole package will be found here
No comments
