{"id":190,"date":"2009-02-15T18:07:15","date_gmt":"2009-02-16T01:07:15","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=788"},"modified":"2009-02-15T18:07:15","modified_gmt":"2009-02-16T01:07:15","slug":"simple-blendmode-nav","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=190","title":{"rendered":"Simple BlendMode Nav"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">stage.frameRate=30;\r\nvar nav:Sprite = Sprite(addChild(new Sprite()));\r\nnav.x=nav.y=150;\r\n\r\nvar cover:Sprite;\r\nvar coverDest:Number=0;\r\nvar spacing:int=4;\r\nvar btnNum:int=6;\r\n\r\nbuildNav();\r\n\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\n\r\nfunction onLoop(evt:Event):void {\r\n\tcover.x += (coverDest - cover.x) \/4;\r\n}\r\n\r\nfunction buildNav():void {\r\n\tfor (var i:int = 0; i&lt;btnNum; i++) {\r\n\t\tvar b:Sprite=makeBox(50,50);\r\n\t\tb.x = i * (b.width + spacing);\r\n\t\tb.buttonMode=true;\r\n\t\tb.addEventListener(MouseEvent.CLICK, onClick);\r\n\t}\r\n\tcover=makeBox(54, 60);\r\n\tcover.blendMode=BlendMode.INVERT;\r\n}\r\n\r\nfunction onClick(evt:MouseEvent):void {\r\n\tcoverDest=evt.currentTarget.x;\r\n}\r\n\r\nfunction makeBox(w:Number, h:Number) {\r\n\tvar b:Sprite = new Sprite();\r\n\twith (b.graphics) {\r\n\t\tbeginFill(0x000000),drawRect(-w\/2,-h\/2,w,h);\r\n\t}\r\n\tnav.addChild(b);\r\n\treturn b;\r\n}\r\n<\/pre>\n<p>This is something I do in my intermediate flash classes&#8230; the only difference is that we do the graphics in the flash IDE during class time instead of drawing them with ActionScript.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>stage.frameRate=30; var nav:Sprite = Sprite(addChild(new Sprite())); nav.x=nav.y=150; var cover:Sprite; var coverDest:Number=0; var spacing:int=4; var btnNum:int=6; buildNav(); addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { cover.x += (coverDest &#8211; cover.x) \/4; } function buildNav():void { for (var i:int = 0; i&lt;btnNum; i++) { var b:Sprite=makeBox(50,50); b.x = i * (b.width + spacing); b.buttonMode=true; b.addEventListener(MouseEvent.CLICK, onClick); } cover=makeBox(54, 60); cover.blendMode=BlendMode.INVERT; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[3,4],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-motion","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=190"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/190\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}