Flash/AS3 Classes

gpShapes - Basic Shapes

The following example displays the shape types of the gpShapes Class. The configuration file is loaded with the gpUrlLoader Class. The gpConfig class is used to retrieve the specific XMLList and convert it to an object.


    import flash.events.*;
    import com.grasshopper.utils.*;
	
	var config:gpConfig;
	
	var ldr:gpUrlLoader = new gpUrlLoader();
	ldr.addEventListener(Event.COMPLETE, xmlLoaded);
	ldr.addEventListener(gpUrlLoader.LOADERROR, ioError);
	ldr.init('config.xml', 'xml');

	function xmlLoaded(event:Event):void {
		var xl:XML = ldr.getXML();
		config = new gpConfig(xl);
		var configItem:Object = config.getChildByAttributeObject('pLayout', 'pStyles', 'cType', 'shape1');
		var myShape:gpShapes = new gpShapes();
		myShape.createShape(configItem);
		addChild(myShape);
		myShape.x = 100;
		myShape.y = 100; 
	}	
	
	function ioError(e:Event):void {
		trace('Error loading file');
	}	

For documentation about the gpShapes AS3 Class, view the blog post.