SWFAddress, if You Aren’t Using it for All Your Flash, Start to
We’ve been using SWFAddress for a while now, and while I was cleaning old project files out of Flex I came across my first Flex Test using it. It’s simple, and in fact, SWFAddress has been improved a bunch since this test was made (mostly involving SEO, and fallback links + Google Analytics). Now we’re using it for running our entire navigation schemes for all Flash sites, mini-sites, components, and even in our pitches.
Check out my example (click anywhere to move the box, then use the back/forward buttons for undo/redo).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | package { import com.asual.swfaddress.SWFAddress; import com.asual.swfaddress.SWFAddressEvent; import flash.display.Shape; import flash.display.Sprite; import flash.events.MouseEvent; public class SWFAddress_test extends Sprite { private var _square:Shape; public function SWFAddress_test() { SWFAddress.addEventListener(SWFAddressEvent.INIT, init); } private function init(evt:SWFAddressEvent):void { SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleSWFAddressChange); stage.addEventListener(MouseEvent.CLICK, gotoAddress); _square = new Shape(); _square.graphics.beginFill(0x0); _square.graphics.drawRect(0,0,50,50); this.addChild(_square); } private function handleSWFAddressChange(evt:SWFAddressEvent):void { trace(evt.path); var address:Array = evt.path.split("/", 3); var xLoc:Number = Number(address[1]); if(!isNaN(xLoc)) moveSquare(xLoc); } private function gotoAddress(evt:MouseEvent):void { SWFAddress.setValue(this.mouseX.toString()); } private function moveSquare(loc:Number):void { _square.x = loc; } } } |
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
