{"id":207,"date":"2008-01-01T00:00:00","date_gmt":"2009-03-02T07:00:49","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=874"},"modified":"2008-01-01T00:00:00","modified_gmt":"2009-03-02T07:00:49","slug":"sine-cosine-walk","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=207","title":{"rendered":"Sine Cosine Walk"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nstage.frameRate = 30;\r\nvar footA:MovieClip = makeFoot(0);\r\nvar footB:MovieClip = makeFoot(Math.PI);\r\n\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\t graphics.clear();\r\n\t graphics.lineStyle(0,0x000000);\r\n\t graphics.moveTo(footA.x, footA.y);\r\n\t graphics.curveTo(footA.x + 20, footA.y - 50, 200, 100);\r\n\t graphics.curveTo(footB.x + 20, footB.y - 50, footB.x, footB.y);\r\n}\r\n\r\nfunction makeFoot(startAngle:Number):MovieClip {\r\n\tvar mc:MovieClip = MovieClip(addChild(new MovieClip()));\r\n\twith(mc.graphics) beginFill(0x000000), curveTo(10,-10, 20, 0);\r\n\tmc.x = 200;\r\n\tmc.y = 200;\r\n\tmc.sx = mc.x;\r\n\tmc.sy = mc.y;\r\n\tmc.t = startAngle;\r\n\tmc.r = 50;\r\n\tmc.addEventListener(Event.ENTER_FRAME, onRunFoot);\r\n\treturn mc;\r\n}\r\nfunction onRunFoot(evt:Event):void {\r\n\tvar mc:MovieClip = MovieClip(evt.currentTarget);\r\n     with(mc){\r\n\t\tx = sx + r * Math.cos(t); \r\n\t\ty = Math.min(sy, sy + r * Math.sin(t));\r\n\t\trotation = sy - y;\r\n\t\tt += .15;\r\n\t }\r\n}\r\n<\/pre>\n<p>This is a funny looking snippet that creates a very primitive walk cycle with the Graphics class and sine and cosine.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>stage.frameRate = 30; var footA:MovieClip = makeFoot(0); var footB:MovieClip = makeFoot(Math.PI); addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { graphics.clear(); graphics.lineStyle(0,0&#215;000000); graphics.moveTo(footA.x, footA.y); graphics.curveTo(footA.x + 20, footA.y &#8211; 50, 200, 100); graphics.curveTo(footB.x + 20, footB.y &#8211; 50, footB.x, footB.y); } function makeFoot(startAngle:Number):MovieClip { var mc:MovieClip = MovieClip(addChild(new MovieClip())); with(mc.graphics) beginFill(0x000000), curveTo(10,-10, 20, 0); mc.x = 200; mc.y = [&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-207","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\/207","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=207"}],"version-history":[{"count":1,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":558,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/207\/revisions\/558"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}