In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

show SVG

Get Adobe Flash player
by aaharu 30 Jan 2010

    Tags

    SVG
    Embed
/**
 * Copyright aaharu ( http://wonderfl.net/user/aaharu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/y45k
 */

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import frocessing.shape.FShapeSVG;

	[SWF(backgroundColor = "0xFFFFFF", frameRate = "30")]
	public class TestSVG extends Sprite {
		private var sp:Sprite;
		private var mouseDown:Boolean;
		private var mouseDownX:Number;
		private var mouseDownY:Number;
		
		public function TestSVG() {
			
			var svg:XML = <svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   version="1.1"
   width="210mm"
   height="297mm"
   id="svg2"
   inkscape:version="0.47 r22583"
   sodipodi:docname="test.svg">
  <g
     id="layer1"
     transform="matrix(0.68300694,0,0,0.79920794,-71.691894,-119.4578)">
    <path
       d="m 202.85714,163.79075 c -7.16887,-3.12398 -12.8359,-2.85714 -20,-2.85714 -0.95238,0 -2.1837,-0.67343 -2.85714,0 -0.67344,0.67344 0.42592,2.00531 0,2.85714 0.89729,6.13202 -4.64125,1.01765 -5.71429,2.85715 -17.56877,30.1179 -17.14285,21.88232 -17.14285,37.14285 0,1.90477 -0.60234,3.90727 0,5.71429 0.42591,1.27775 2.2548,1.65247 2.85714,2.85714 0.42592,0.85184 0,1.90476 0,2.85715 0.95238,0.95238 2.11003,1.73647 2.85714,2.85714 1.18129,1.77192 2.18371,3.69398 2.85715,5.71428 0.30117,0.90351 -0.6948,2.20577 0,2.85715 14.77159,13.84837 30.08432,27.12826 45.71428,40 0.73517,0.60543 1.90476,0 2.85714,0 22.85715,0 45.71429,0 68.57143,0 0.95238,0 2.55598,-0.90351 2.85715,0 4.6754,14.02621 8.22127,28.42428 11.42857,42.85714 0.6198,2.78911 2.80166,8.0111 0,8.57143 C 245.2386,328.45732 192.8536,343.81653 140,340.93361 c -32.35736,-1.76495 0.91226,-32.34083 5.71429,-37.14286"
       id="path2816"
       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
    <path
       d="m 324.28571,183.79075 c 0.82555,16.49025 0.1963,28.69473 4.26268,44.03017 0.25087,0.94611 1.70121,1.29324 1.88018,2.25555 0.15177,0.81606 -1.67059,-0.91518 -1.78383,-1.73747 -0.16761,-1.21698 -0.0749,-4.00446 1.05837,-3.53017 2.37545,0.99419 3.23887,4.00431 4.8583,6.00647 2.69427,9.32976 5.35371,18.70029 8.33075,27.94259 0.44624,1.38536 1.22452,2.66091 1.56692,4.07551 5.32652,22.00603 -3.28694,-8.37131 2.0033,9.80417 3.26269,8.3385 7.40834,16.51322 9.65718,25.22871 0.58716,2.2756 0.67518,4.65476 1.16067,6.95419 3.53806,16.75735 -0.96951,-8.04307 1.8225,7.80457 -0.55434,5.00365 1.30112,9.6732 2.30666,14.47355 0.24079,1.14953 0.14243,2.38459 0.57637,3.47596 0.10571,0.26586 0.59219,-0.009 0.85079,0.1134 1.32152,0.62549 2.56376,1.40631 3.84565,2.10947 0,0 -1.38058,2.50145 -1.38058,2.50145 l 0,0 c -1.1661,-0.64723 -5.25265,-2.43027 -6.13504,-4.2601 -0.47943,-0.9942 -0.30747,-2.18767 -0.53412,-3.26791 -1.01653,-4.84494 -2.88176,-9.61452 -2.34456,-14.65591 -2.2807,-13.28038 1.51974,8.10823 -1.82706,-7.83159 -0.45136,-2.14969 -0.50139,-4.37846 -1.04915,-6.50563 -2.2554,-8.7587 -6.45497,-16.9592 -9.6955,-25.35165 -0.4461,-1.57333 -0.89221,-3.14665 -1.33832,-4.71998 -0.19565,-1.61695 -0.20131,-3.26842 -0.58695,-4.85085 -0.36471,-1.49652 -1.17457,-2.85138 -1.64737,-4.31735 -2.962,-9.18408 -5.60548,-18.49756 -8.27639,-27.77169 1.24885,-13.38372 0.82085,-4.43461 -0.5119,-2.5237 -2.41678,3.4652 -4.37991,3.62491 -5.61793,-0.91049 -4.06064,-14.8758 -3.53423,-29.0314 -4.30876,-44.54127 0,0 2.85714,0 2.85714,0 z"
       id="path2818"
       style="fill:#008080" />
    <path
       d="m 365.17196,334.04019 c 26.55886,-39.39128 16.70356,-23.95324 43.50705,-67.41213 4.68257,-7.59227 9.184,-15.29613 13.92531,-22.85186 0.98436,-1.56866 2.52134,-2.80508 3.24458,-4.50995 3.07744,-7.25432 6.56882,-21.02705 8.64065,-28.61023 0.50118,-2.83589 1.23065,-5.64079 1.50353,-8.50767 4.50609,-2.9562 -0.80172,-1.92025 -0.81016,-2.93519 -0.0182,-2.1881 2.89675,-8.08294 3.66457,-9.96661 0,0 1.32287,0.5393 1.32287,0.5393 l 0,0 c -0.54783,1.3436 -2.44627,6.11735 -3.2842,7.81478 -0.13946,0.2825 -0.56371,0.45293 -0.55123,0.76772 0.0153,0.38636 0.52172,0.60624 0.62052,0.98007 1.14885,4.34698 -0.18169,6.57715 -1.08786,11.68421 -2.28474,8.35769 -5.47366,21.09883 -8.85936,29.06834 -0.70984,1.6709 -2.21918,2.88079 -3.18399,4.41862 -4.74284,7.55966 -9.24696,15.26671 -13.93183,22.86243 -26.86575,43.55823 -16.96765,28.05633 -43.6358,67.58787 0,0 -1.08465,-0.9297 -1.08465,-0.9297 z"
       id="path2820"
       style="fill:#008080" />
    <path
       d="m 604.28572,199.50504 c -75.71429,-41.42857 -117.14286,-7.14286 -128.57143,11.42857 -11.42857,18.57143 -30,87.14286 -12.85714,114.28572 17.14285,27.14285 95.71428,34.28571 108.57142,27.14285 12.85715,-7.14285 40,-42.85714 32.85715,-51.42857 -7.14286,-8.57143 -7.14286,-8.57143 -7.14286,-8.57143"
       id="path2822"
       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
    <path
       d="m 564.28572,279.50504 c 67.14285,8.57143 67.14285,8.57143 67.14285,8.57143 l -7.14285,71.42857"
       id="path2824"
       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
  </g>
</svg>;
			var shapeData:FShapeSVG = new FShapeSVG(svg);
			sp = shapeData.toSprite();
			mouseDown = false;
			stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
			stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
		}
		
		private function onMouseDown(e:MouseEvent):void {
			mouseDownX = e.stageX;
			mouseDownY = e.stageY;
			sp.x = e.stageX - sp.width / 2;
			sp.y = e.stageY - sp.height / 2;
			sp.alpha = 0.2;
			mouseDown = true;
			addChild(sp);
		}
		
		private function onMouseMove(e:MouseEvent):void {
			if(mouseDown) {
				sp.width = Math.abs(mouseDownX - e.stageX) * 2;
				sp.height = Math.abs(mouseDownY - e.stageY) * 2;
				sp.x = mouseDownX - sp.width / 2;
				sp.y = mouseDownY - sp.height / 2;
			}
		}
		
		private function onMouseUp(e:MouseEvent):void {
			sp.alpha = 1;
			mouseDown = false;
		}
	}
}