{"id":1870,"date":"2012-05-22T06:54:51","date_gmt":"2012-05-22T10:54:51","guid":{"rendered":"http:\/\/www.searchenginegenie.com\/web-design-blog\/?p=1870"},"modified":"2012-05-22T06:59:49","modified_gmt":"2012-05-22T10:59:49","slug":"smoky-trailer-in-flash-action-script","status":"publish","type":"post","link":"https:\/\/www.searchenginegenie.com\/web-design-blog\/smoky-trailer-in-flash-action-script\/","title":{"rendered":"Smoky Trailer in Flash Action script"},"content":{"rendered":"<p><strong>Final Preview:<\/strong><\/p>\n<p><object id=\"test\" width=\"550\" height=\"400\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"src\" value=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/05\/realistic-bitmap-smoke-trailer.swf\" \/><embed id=\"test\"width=\"550\" height=\"400\" type=\"application\/x-shockwave-flash\" src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/05\/realistic-bitmap-smoke-trailer.swf\" \/><\/object><\/p>\n<p>Step-1 Open a new document in flash. Set the stage color as black.<\/p>\n<p>Step-2 Create four buttons for smoke colors transformation in Layer-1. Give the instance name for each button. Here\u00a0 I gave one_btn, two_btn, three_btn and four_btn.<\/p>\n<p>Step-3 Type the following Action Script in Layer-2.<\/p>\n<div style=\"background-color:#f6f8f9; width: 750px; height: 1195px; padding-left: 12px; padding-top: 12px; border:#CCC solid 0.01em;\">\n\/\/import bitmap class<br \/>\nimport flash.display.BitmapData;<br \/>\nvar currentBitmap:String = &#8220;smoke_yellow_blue.png&#8221;;<br \/>\nfunction doTrail(container:MovieClip, targetX:Number, targetY:Number, type:String):Void<br \/>\n{<br \/>\n\/\/attach bitmap from the library with the linked name &#8220;adobe_flash&#8221;<br \/>\nvar myBmp:BitmapData = BitmapData.loadBitmap(currentBitmap);<br \/>\n\/\/create the &#8220;main_holder&#8221; movieclip that will hold our bitmap<br \/>\nvar _particle = container.createEmptyMovieClip(&#8220;main_holder&#8221;+container.getNextHighestDepth(), container.getNextHighestDepth());<\/p>\n<p>\/\/create an &#8220;internal_holder&#8221; movieclip inside &#8220;main_holder&#8221; that we&#8217;ll use to center the bitmap data<br \/>\nvar internal_holder:MovieClip = _particle.createEmptyMovieClip(&#8220;internal_holder&#8221;, _particle.getNextHighestDepth());<br \/>\n\/\/set &#8220;internal_holder&#8221; x and y position based on bitmap size<br \/>\ninternal_holder._x = -myBmp.width\/2;<br \/>\ninternal_holder._y = -myBmp.height\/2;<\/p>\n<p>\/\/finally, attach the bitmapData &#8220;myBmp&#8221; to the movieclip &#8220;internal_holder&#8221;<br \/>\ninternal_holder.attachBitmap(myBmp, internal_holder.getNextHighestDepth());<\/p>\n<p>\/\/set the particle&#8217;s x &amp; y position based on the target x &amp; y. Offset the particle by a few pixels<br \/>\n_particle._x = targetX + random(4)-8;<br \/>\n_particle._y = targetY + random(4)-8;<br \/>\n\/\/randomly rotate the particle 360 degrees<br \/>\n_particle._rotation = random(360);<br \/>\n\/\/give the particle a random scale, between 50% and 100%<br \/>\nvar randomScale = random(50)+50;<br \/>\n_particle._xscale = randomScale;<br \/>\n_particle._yscale = randomScale;<br \/>\n\/\/give each particle its own speed<br \/>\n_particle.speed = random(5)+3;<br \/>\n\/\/make it move<br \/>\n_particle.onEnterFrame = function ()<br \/>\n{<br \/>\nthis._xscale += this.speed;<br \/>\nthis._yscale += this.speed;<br \/>\nthis._alpha -= this.speed;<br \/>\n\/\/check if particle is invisible, and remove it<br \/>\nif(this._alpha &lt;= 0)<br \/>\n{<br \/>\ndelete this.onEnterFrame;<br \/>\nremoveMovieClip(this);<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n_root.onEnterFrame = function():Void<br \/>\n{<br \/>\ndoTrail(_root, _xmouse, _ymouse, currentBitmap);<br \/>\n}<br \/>\n\/\/*** Control Buttons***\/\/<br \/>\none_btn.onRelease = function(){<br \/>\ncurrentBitmap = &#8220;clear.png&#8221;;<br \/>\n}<br \/>\ntwo_btn.onRelease = function(){<br \/>\ncurrentBitmap = &#8220;smoke_clear.png&#8221;;<br \/>\n}<br \/>\nthree_btn.onRelease = function(){<br \/>\ncurrentBitmap = &#8220;smoke_yellow_blue.png&#8221;;<br \/>\n}<br \/>\nfour_btn.onRelease = function(){<br \/>\ncurrentBitmap = &#8220;smoke_yellow_orange.png&#8221;;<br \/>\n}\n<\/p><\/div>\n<p><\/p>\n<p>Step-4 Import smoke effect images to library. Images name should be same as in library and script. Go to library panel and right click on each image. \u00a0Choose Properties \u00e0 Linkage. Check the \u201cExport for Action script\u201d option.<\/p>\n<p>Run the program.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Final Preview: Step-1 Open a new document in flash. Set the stage color as black. Step-2 Create four buttons for smoke colors transformation in Layer-1. Give the instance name for each button. Here\u00a0 I gave one_btn, two_btn, three_btn and four_btn. Step-3 Type the following Action Script in Layer-2. \/\/import bitmap class import flash.display.BitmapData; var currentBitmap:String [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,5],"tags":[156,155,154],"class_list":["post-1870","post","type-post","status-publish","format-standard","hentry","category-flash","category-web-design","category-web-design-tips","tag-bitmap-trailer-in-flash","tag-mouse-attachment-image-flash","tag-mouse-trailer-in-flash"],"_links":{"self":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/1870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/comments?post=1870"}],"version-history":[{"count":29,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/1870\/revisions"}],"predecessor-version":[{"id":4153,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/1870\/revisions\/4153"}],"wp:attachment":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/media?parent=1870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/categories?post=1870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/tags?post=1870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}