Created
September 13, 2011 00:54
-
-
Save nodename/1212884 to your computer and use it in GitHub Desktop.
Load and test the Tuple<Point, Point, Point> class written to a swf by nodename/ClassGenerationTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Loader; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.geom.Point; | |
import flash.net.URLRequest; | |
import flash.system.ApplicationDomain; | |
import flash.system.LoaderContext; | |
import flash.utils.describeType; | |
public class LoadAndTestCreatedClass extends Sprite | |
{ | |
private var _loader:Loader; | |
public function LoadAndTestCreatedClass() | |
{ | |
var url:String = "MyGeneratedClasses.swf"; | |
var request:URLRequest = new URLRequest(url); | |
_loader = new Loader(); | |
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain); | |
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedHandler); | |
_loader.load(request, loaderContext); | |
} | |
private function loadedHandler(event:Event):void | |
{ | |
const p0:Point = new Point(0, 3); | |
const p1:Point = new Point(4, 0); | |
const p2:Point = new Point(4, 3); | |
const p3:Point = new Point(-4, -3); | |
const pointTuple:Object = makeTuple(p0, p1, p2, p3); | |
trace(describeType(pointTuple)); | |
trace(pointTuple); | |
trace(pointTuple.fourth); | |
} | |
private function makeTuple(x:*, y:*, z:*, w:*):Object | |
{ | |
const types:Array = [ (x as Object).constructor, (y as Object).constructor, (z as Object).constructor, (w as Object).constructor ]; | |
const tupleClassName:String = "Tuple<Point, Point, Point, Point>"; | |
const clazz:Class = ApplicationDomain.currentDomain.getDefinition("com.classes.generated" + "::" + tupleClassName) as Class; | |
return new clazz(x, y, z, w); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment