{"id":440,"date":"2009-11-16T12:02:12","date_gmt":"2009-11-16T19:02:12","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2417"},"modified":"2009-11-16T12:02:12","modified_gmt":"2009-11-16T19:02:12","slug":"obfuscated-slider","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=440","title":{"rendered":"Obfuscated Slider"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar slider:MovieClip = makeSlider();\r\nslider.addEventListener(Event.CHANGE, function(evt:Event):void{\r\n\ttrace(evt.currentTarget.percent);\t\t\t\t\t\t\t\t\t\r\n});\r\n\r\nfunction makeSlider():MovieClip{\r\n\tvar slider:MovieClip = MovieClip(addChild(new MovieClip()));\r\n\tvar circle:Sprite = Sprite(slider.addChild(new Sprite()));\r\n\twith (circle.graphics) beginFill(0x000000), drawCircle(0,0,10);\r\n\tvar line:Shape = Shape(slider.addChild(new Shape()));\r\n\twith (line.graphics) lineStyle(0,0x000000), lineTo(0, 100);\r\n\tslider.x = slider.y = 100;\r\n\tcircle.addEventListener(MouseEvent.MOUSE_DOWN, function(evt:Event):void{ evt.currentTarget.startDrag(false, new Rectangle(0,0,0,100)), slider.addEventListener(Event.ENTER_FRAME, onChange) });\r\n\tvar stopIt:Function = function(){ stopDrag(), slider.removeEventListener(Event.ENTER_FRAME, onChange) };\r\n\tstage.addEventListener(Event.MOUSE_LEAVE, stopIt);\r\n\tstage.addEventListener(MouseEvent.MOUSE_UP, stopIt);\r\n\treturn slider;\r\n}\r\nfunction onChange(evt:Event):void { evt.currentTarget.percent = evt.currentTarget.getChildAt(0).y \/ 100, evt.currentTarget.dispatchEvent(new Event(Event.CHANGE)) }\r\n<\/pre>\n<p>This is a pretty nasty implementation of a basic slider. Just felt like writing some obfuscated code today&#8230; It could probably be made even more confusing with some additional tweaks&#8230;<br \/>\n<a href=\"http:\/\/wonderfl.net\/code\/f5edfe8f3b1902d49234077d7dcd3b612f101d24\" target=\"blank\"><br \/>\nHave a look at the swf over at wonderfl&#8230;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>var slider:MovieClip = makeSlider(); slider.addEventListener(Event.CHANGE, function(evt:Event):void{ trace(evt.currentTarget.percent); }); function makeSlider():MovieClip{ var slider:MovieClip = MovieClip(addChild(new MovieClip())); var circle:Sprite = Sprite(slider.addChild(new Sprite())); with (circle.graphics) beginFill(0x000000), drawCircle(0,0,10); var line:Shape = Shape(slider.addChild(new Shape())); with (line.graphics) lineStyle(0,0&#215;000000), lineTo(0, 100); slider.x = slider.y = 100; circle.addEventListener(MouseEvent.MOUSE_DOWN, function(evt:Event):void{ evt.currentTarget.startDrag(false, new Rectangle(0,0,0,100)), slider.addEventListener(Event.ENTER_FRAME, onChange) }); var stopIt:Function = function(){ stopDrag(), slider.removeEventListener(Event.ENTER_FRAME, onChange) }; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[98],"tags":[3,14,4],"class_list":["post-440","post","type-post","status-publish","format-standard","hentry","category-ui","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/440","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=440"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/440\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}