My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 24: how to get array length in arracollection
1 person starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  ----
Closed:  Dec 2009


 
Reported by abidr...@gmail.com, Sep 29, 2009
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="init()" xmlns:local="*">
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.FaultEvent;
			import mx.utils.ArrayUtil;
			import mx.collections.ArrayCollection;
			import mx.rpc.events.ResultEvent;
			import mx.containers.HBox;
			import mx.utils.ObjectUtil;
			import com.roguedevelopment.objecthandles.SelectionManager;
			import mx.controls.Alert;
			import com.roguedevelopment.objecthandles.ObjectHandleEvent;
			import com.zavoo.svg.nodes.SVGRoot;
			import com.zavoo.svg.SVGViewer;
			import mx.controls.Image;
			import com.roguedevelopment.objecthandles.ObjectHandles;			
			import com.zavoo.svg.SvgPaths;
			import com.zavoo.svg.SvgPath;
			
			import flash.net.URLLoader;
			import flash.net.URLRequest;
			import flash.events.Event;
			import flash.display.Graphics;

			public var paths:SvgPaths;
			
			public var canvas:Sprite;
			
			[Bindable]
	     	private var svgImage:Array = 
	     	[
	     	 {img:"assets/coloredtoucan.svg"},
	     	 {img:"assets/eleven_below_single.svg"},
	     	 {img:"assets/spring_tree_final.svg"},
	     	 {img:"assets/eleven_below_single.svg"},
	     	];
			
			[Bindable] public var myx:Number = 0;
			[Bindable] public var galleries:ArrayCollection = new ArrayCollection();
			
			
			private function httpServicesvg_result(event:ResultEvent):void
			{
			    var result:ArrayCollection = event.result.galleries.gallery is
ArrayCollection ? event.result.galleries.gallery as ArrayCollection
			        : new ArrayCollection(ArrayUtil.toArray(event.result.gallery));
			    galleries = result;
		    	mySvgImage();
			}
			
			public function mySvgImage():void
			{
				Alert.show(ObjectUtil.toString(galleries));
				
				var n:int = galleries.source.length;
				for (var i:int = 0; i < n; i++)
				{
					canvas = new Sprite();
					this.rawChildren.addChild(canvas);
					var loader:URLLoader = new URLLoader();
					var request:URLRequest = new URLRequest(galleries.source[i].img);
					loader.load(request);
					loader.addEventListener(Event.COMPLETE, onLoadComplete);
				}	
			}
			 public function init():void
			{
				httpServicesvg.url= "assetsXml.xml";	
				httpServicesvg.send();
				httpServicesvg.method="GET";
				httpServicesvg.addEventListener(ResultEvent.RESULT, httpServicesvg_result);
				
				
				/*var n:int = svgImage.length;
				for (var i:int = 0; i < n; i++)
				{
					
					canvas = new Sprite();
					this.rawChildren.addChild(canvas);
					var loader:URLLoader = new URLLoader();
					var request:URLRequest = new URLRequest(svgImage[i].img);
					loader.load(request);
					loader.addEventListener(Event.COMPLETE, onLoadComplete);
				}	*/
			} 
			
			
			private var index:int = 0;
			
			private var localX:int = 10;
			private var localY:int = 10;
			
			private function onLoadComplete(event:Event):void 
			{
			    var loader:URLLoader = URLLoader(event.target);
			    paths = new SvgPaths(loader.data);		    
			    var svgv:SVGViewer = new SVGViewer();
			    svgv.xml = new XML(loader.data);
			    svgv.myWidth(50);
				svgv.myHeight(50);
			   	svgv.addEventListener(MouseEvent.CLICK, onVectorGraphicSelect);
			   	svgv.x = localX;
			   	svgv.y = localY;
				
				mygen.addChild(svgv);	
			
				localX += 60;
				if(localX >180)
				{
					localY += 60;
					localX = 10;
				}
				
			}
			
			private function onVectorGraphicSelect(event:MouseEvent):void 
			{
				 var svgv:SVGViewer = new SVGViewer();
				 svgv.xml = (event.currentTarget as SVGViewer).xml;
				 svgv.myHeight(150);
	    	 	 svgv.myWidth(150);
	    	 
	    	 	 if(svgv != null)
				 {
				    var oh1:ObjectHandles = new ObjectHandles();
				    oh1.allowHMove=true;
					oh1.allowHResize=true;
					oh1.allowVMove=true;
					oh1.allowVResize=true;
					oh1.allowRotate=true;
					oh1.mouseChildren=true;
				    oh1.width=150;
				    oh1.height=150;
				   
oh1.addEventListener(ObjectHandleEvent.OBJECT_RESIZED_EVENT,getNewWidthHeight);
				    
				    oh1.addChild(svgv);
				    mygenw.addChild(oh1);
				 }
		 
			}
			
			public var newWidth:Number;
			public var newHeight:Number;
			
			public function getNewWidthHeight(e:ObjectHandleEvent):void{
			
			 var svgv:SVGViewer =  e.currentTarget.getChildAt(0) as SVGViewer;
			 var seleObject:ObjectHandles= e.currentTarget as ObjectHandles;	
			 newWidth =  (e.currentTarget as ObjectHandles).width;
	    	 newHeight =  (e.currentTarget as ObjectHandles).height;
	    	 
	    	 svgv.myHeight(newHeight);
	    	 svgv.myWidth(newWidth);
	    	}
	    	
	    	private function httpService_fault(evt:FaultEvent):void {
                var title:String = evt.type + " (" + evt.fault.faultCode + ")";
                var text:String = evt.fault.faultString;
                //alert = Alert.show(text, title);
               // xmlListColl.removeAll();
            }
			
						
		]]>
	</mx:Script>
	<mx:HTTPService id="httpServicesvg" resultFormat="e4x"
fault="httpService_fault(event);"/>
	<mx:Canvas id="mygen" width="100%" height="100%">
	</mx:Canvas>
	<mx:Canvas id="mygenw" width="50%" height="50%" y="200"
borderStyle="solid" borderColor="#ff00ff"/>
		
	
</mx:Application>

svg.rar
1.5 MB   Download
Dec 22, 2009
Project Member #1 marc.hug...@gmail.com
I'm unsure of what this issue is about.
Status: Invalid

Powered by Google Project Hosting