{"id":443,"date":"2009-11-25T10:05:58","date_gmt":"2009-11-25T17:05:58","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2435"},"modified":"2009-11-25T10:05:58","modified_gmt":"2009-11-25T17:05:58","slug":"fp10-3d-logo","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=443","title":{"rendered":"Fp10 3d Logo"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar container:Sprite = new Sprite();\r\ncontainer.x = stage.stageWidth \/ 2;\r\ncontainer.y = stage.stageHeight \/ 2;\r\naddChild(container);\r\n\r\nvar redBox:Sprite = new Sprite();\r\nredBox.graphics.beginFill(0xFF0000);\r\nredBox.graphics.drawRect(-50,-250,100,500);\r\nredBox.rotationZ = 10;\r\ncontainer.addChild(redBox);\r\n\r\nvar logos:Array = &#x5B;]\r\nvar elements:Array = &#x5B;];\r\nelements.push({element:redBox, z:0});\r\n\r\n\/\/ add the logos\r\nfor (var i:int = 0; i&lt;6; i++){\r\n\tvar logoContainer:MovieClip = new MovieClip();\r\n\tvar logoText:TextField = new TextField();\r\n\tlogoText.defaultTextFormat = new TextFormat(&quot;_sans&quot;, 50);\r\n\tlogoText.text = &quot;LOGO&quot;;\r\n\tlogoText.autoSize = &quot;left&quot;;\r\n\tlogoText.selectable= false;\r\n\t\r\n\tlogoText.x = -logoText.width \/ 2;\r\n\tlogoText.y = -logoText.height \/ 2;\r\n\tlogoContainer.addChild(logoText);\r\n\tlogoText.backgroundColor = 0xFFFFFF;\r\n\t\r\n\tcontainer.addChild(logoContainer);\r\n\tlogos.push(logoContainer);\r\n\telements.push({element:logoContainer, z:0});\r\n}\r\n\r\nvar ang:Number = -Math.PI \/ 2;\r\nvar rotationSpeed:Number = 0.05;\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\t\r\n\t var dx:Number = (mouseY - stage.stageHeight \/ 2) \/ 10;\r\n\t var dy:Number = (mouseX - stage.stageWidth \/ 2) \/ 10;\r\n\t container.rotationX += (dx - container.rotationX) \/ 4;\r\n\t container.rotationY += (dy - container.rotationY) \/ 4;\r\n\t \r\n\t ang += rotationSpeed;\r\n     for (var i:int = 0; i&lt;logos.length; i++){\r\n\t\t var logo:Sprite = logos&#x5B;i];\r\n\t\t logo.x = 150 * Math.cos(ang + i);\r\n\t     logo.z = 150 * Math.sin(ang + i);\r\n\t\t logo.alpha = 1 - logo.z \/ 200;\r\n\t\t logo.rotationY = -Math.atan2(logo.z, logo.x)  \/ Math.PI * 180  - 90;\r\n\t }\r\n\t \r\n\t \/\/ z-sort\r\n\t for (i = 0; i&lt;elements.length; i++){\r\n\t\t  elements&#x5B;i].z = elements&#x5B;i].element.transform.getRelativeMatrix3D(this).position.z;\r\n\t }\r\n\t \r\n\telements.sortOn(&quot;z&quot;, Array.NUMERIC | Array.DESCENDING);\r\n\tfor (i = 0; i&lt;elements.length; i++) {\r\n\t\tcontainer.addChild(elements&#x5B;i].element);\r\n\t}\r\n}\r\n<\/pre>\n<p>A student of mine was having trouble creating a 3D logo for a client. I created this snippet to help explain how some of the fp10 3D stuff works&#8230;. z-sorting etc&#8230; The code could be optimized a bit&#8230; but it works nicely&#8230;<\/p>\n<p><a data-asruffle-linked=\"true\" href=\"http:\/\/www.actionsnippet.com\/swfs\/logothing.html\" target=\"blank\"><br \/>\nHave a look at the swf&#8230;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/logo3d.gif\" \/><\/a> <span class=\"asruffle-link\" data-swf=\"{&quot;url&quot;:&quot;https:\\\/\\\/actionsnippet.com\\\/swfs\\\/logothing.swf&quot;,&quot;title&quot;:&quot;logothing&quot;,&quot;width&quot;:800,&quot;height&quot;:600,&quot;missing&quot;:false,&quot;allowScriptAccess&quot;:false,&quot;backgroundColor&quot;:&quot;#ffffff&quot;}\"><button type=\"button\" hidden aria-expanded=\"false\">Play demo<span class=\"screen-reader-text\">: logothing<\/span><\/button><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>var container:Sprite = new Sprite(); container.x = stage.stageWidth \/ 2; container.y = stage.stageHeight \/ 2; addChild(container); var redBox:Sprite = new Sprite(); redBox.graphics.beginFill(0xFF0000); redBox.graphics.drawRect(-50,-250,100,500); redBox.rotationZ = 10; container.addChild(redBox); var logos:Array = &#x5B;] var elements:Array = &#x5B;]; elements.push({element:redBox, z:0}); \/\/ add the logos for (var i:int = 0; i&lt;6; i++){ var logoContainer:MovieClip = new MovieClip(); var logoText:TextField [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,94,13],"tags":[3,14,4,126],"class_list":["post-443","post","type-post","status-publish","format-standard","hentry","category-3d","category-misc","category-motion","tag-actionscript","tag-as3","tag-flash","tag-fp10"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/443","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=443"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/443\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}