{"id":1908,"date":"2012-07-27T02:49:47","date_gmt":"2012-07-27T06:49:47","guid":{"rendered":"http:\/\/www.searchenginegenie.com\/web-design-blog\/?p=1908"},"modified":"2012-09-08T03:04:00","modified_gmt":"2012-09-08T07:04:00","slug":"watercolor-painting-sketch-pad-program","status":"publish","type":"post","link":"https:\/\/www.searchenginegenie.com\/web-design-blog\/watercolor-painting-sketch-pad-program\/","title":{"rendered":"Watercolor Painting Sketch Pad Program"},"content":{"rendered":"<p><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=7,0,19,0\" width=\"380\" height=\"200\"><param name=\"movie\" value=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/watercolor-painting1.swf\" \/><param name=\"quality\" value=\"high\" \/><embed src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/watercolor-painting1.swf\" quality=\"high\" pluginspage=\"http:\/\/www.macromedia.com\/go\/getflashplayer\" type=\"application\/x-shockwave-flash\" width=\"380\" height=\"200\"><\/embed><\/object><\/p>\n<h2>Here is a canvas texture to paint on<\/h2>\n<p><a name=\"imageclose-1909\"><div class=\"lb-album\"><a href=\"#image-1909\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/1-300x157.jpg\"  ><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1909\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1909\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/1.jpg\" alt=\"image-1909\">\r\n                   <\/div><\/a><\/p>\n<h2>Step 1 : Document Setup<\/h2>\n<p>Open Adobe Flash and Modify the Document Properties.<br \/>\n<strong>Modify &gt; Document<\/strong><\/p>\n<p><a name=\"imageclose-1910\"><div class=\"lb-album\"><a href=\"#image-1910\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/2-300x22.jpg\"  class=\"alignnone size-medium wp-image-1910\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1910\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1910\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/2.jpg\" alt=\"image-1910\">\r\n                   <\/div><\/a><\/p>\n<h2>Step 2 : Import and Create Background Object<\/h2>\n<p>Import the supplied canvas.jpg onto the Stage.<br \/>\n<strong>File &gt; Import &gt; Import to Stage&#8230; <\/strong><\/p>\n<p>Convert the image on Stage to a MovieClip with a Linkage Identifier.<br \/>\n<strong>Modify &gt; Convert to Symbol<\/strong><br \/>\n<strong>Name:<\/strong> canvas_mc<br \/>\n<strong>Check:<\/strong> &#8216;Export for ActionScript&#8217;<\/p>\n<p><a name=\"imageclose-1911\"><div class=\"lb-album\"><a href=\"#image-1911\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/3-300x298.jpg\"  class=\"alignnone size-medium wp-image-1911\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1911\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1911\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/3.jpg\" alt=\"image-1911\">\r\n                   <\/div><\/a><\/p>\n<p>Giving the MovieClip a Linkage Identifier allows us to reference the MovieClip with Actionscript. You will see in next step.<\/p>\n<h2>Step 3 : Attaching a MovieClip with ActionScript<\/h2>\n<p>Leave the MovieClip instance currently on Stage.<\/p>\n<p>&nbsp;<\/p>\n<p>Select Frame 1 on the Timeline and open the ActionScript Window.<br \/>\n<strong>Window &gt; Actions<\/strong><\/p>\n<p>Enter the following code:<\/p>\n<p><a name=\"imageclose-1912\"><div class=\"lb-album\"><a href=\"#image-1912\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/4-300x28.jpg\"  class=\"alignnone size-medium wp-image-1912\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1912\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1912\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/4.jpg\" alt=\"image-1912\">\r\n                   <\/div><\/a><\/p>\n<p><strong>Line 1<\/strong>: Attaches an instance of the Canvas to the stage at level 2.<br \/>\n<strong>Line 2<\/strong>: Makes the new canvas 50% transparent. This will make the &#8216;paint&#8217; appear as if it were on canvas.<\/p>\n<h2>Step 4 : Create a MovieClip to contain the painting.<\/h2>\n<p>Enter the following code:<\/p>\n<p><a name=\"imageclose-1913\"><div class=\"lb-album\"><a href=\"#image-1913\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/5-300x28.jpg\"  class=\"alignnone size-medium wp-image-1913\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1913\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1913\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/5.jpg\" alt=\"image-1913\">\r\n                   <\/div><\/a><\/p>\n<h2>Step 5 : Creating the Paint Brush Listener for the Mouse.<\/h2>\n<p>Enter the following code:<\/p>\n<p><a name=\"imageclose-1914\"><div class=\"lb-album\"><a href=\"#image-1914\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/6-300x108.jpg\"  class=\"alignnone size-medium wp-image-1914\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1914\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1914\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/6.jpg\" alt=\"image-1914\">\r\n                   <\/div><\/a><\/p>\n<p><strong>Line 6<\/strong>: Create an Object to attach our brush functions.<br \/>\n<strong>Line 7<\/strong>: Define a onMouseDown method for the brush object. This method is activated whenever the mouse button is pressed down. aka. User wants to start painting.<br \/>\n<strong>Line 8<\/strong>: Define a Boolean variable to track when the user is painting.<br \/>\n<strong>Line 9<\/strong>: Move the brush to the mouse position.<br \/>\n<strong>Line 10<\/strong>: Draw a 1 pixel line to the right. We do this so that dots can be painted. Without this line the paint will not show up if a user simply clicks.<br \/>\n<strong>Line 11<\/strong>: End the method definition.<\/p>\n<p><a name=\"imageclose-1915\"><div class=\"lb-album\"><a href=\"#image-1915\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/71-300x79.jpg\"  class=\"alignnone size-medium wp-image-1916\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1915\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1915\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/71.jpg\" alt=\"image-1915\">\r\n                   <\/div><\/a><\/p>\n<p><strong>Line 12<\/strong>: Define a onMouseMove method for the brush object. This method is activated whenever the mouse is moving.<br \/>\n<strong>Line 13<\/strong>: If the mouse button is down then isPainting will be true. <strong>Line 14<\/strong>: If true, then we draw a line to the current mouse position. If false, then do nothing.<br \/>\n<strong>Line 15-16<\/strong>: End the If statement and onMouseMove method.<\/p>\n<p><a name=\"imageclose-1916\"><div class=\"lb-album\"><a href=\"#image-1916\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/8-300x61.jpg\"  class=\"alignnone size-medium wp-image-1917\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1916\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1916\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/8.jpg\" alt=\"image-1916\">\r\n                   <\/div><\/a><\/p>\n<p><strong>Line 17<\/strong>: Define a onMouseUp method for the brush object. This method is activated whenever the mouse button is released. aka. User wants to stop painting.<br \/>\n<strong>Line 18<\/strong>: Set the isPainting variable to false. Now the onMouseMove method stops drawing a line to the Mouse position. When the user presses down on the Mouse the isPainting variable toggles back to true.<br \/>\n<strong>Line 19<\/strong>: End the onMouseUp method.<br \/>\n<strong>Line 20<\/strong>: Attach theBrush Object to the Mouse as a Listener. Basically, this lets Flash know to listen to what the Mouse is doing and execute the methods we defined.<\/p>\n<h2>Step 6 : Define the Paint attributes and randomize for effect.<\/h2>\n<p>Enter the following code:<\/p>\n<p><a name=\"imageclose-1917\"><div class=\"lb-album\"><a href=\"#image-1917\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/9-300x63.jpg\"  class=\"alignnone size-medium wp-image-1918\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1917\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1917\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/9.jpg\" alt=\"image-1917\">\r\n                   <\/div><\/a><\/p>\n<p><strong>Line 22<\/strong>: Attach an onEnterFrame function to our painting MovieClip. This will execute every frame or 30 times a second.<br \/>\n<strong>Line 23<\/strong>: Generate a random number between 2 &amp; 12. This will be the width of our paint line for that frame in time.<br \/>\n<strong>Line 24<\/strong>: Set the style of our painting line.<br \/>\n1st parameter, <em>ranWidth<\/em> : is the width of the line.<br \/>\n2nd parameter, <em>0x0066CC<\/em> : is the RBG color of the line.<br \/>\n3rd parameter, <em>100<\/em> : is the alpha (transparency) of the line.<br \/>\n<strong>Line 25<\/strong>: End the onEnterFrame function.<\/p>\n<h2>Step 7 : Adding the Clear painting button.<\/h2>\n<p>Create a button, name the instance &#8216;clear_btn&#8217; and enter the following code in Frame 1 of the Main Timeline:<\/p>\n<p><a name=\"imageclose-1918\"><div class=\"lb-album\"><a href=\"#image-1918\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/10.jpg\"  class=\"alignnone size-full wp-image-1919\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-1918\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-1918\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2012\/07\/10.jpg\" alt=\"image-1918\">\r\n                   <\/div><\/a><\/p>\n<p>Save and test out your simple painting program. From here you can begin to add features, such as more colors, different canvas options, brush sizes, etc.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a canvas texture to paint on Step 1 : Document Setup Open Adobe Flash and Modify the Document Properties. Modify &gt; Document Step 2 : Import and Create Background Object Import the supplied canvas.jpg onto the Stage. File &gt; Import &gt; Import to Stage&#8230; Convert the image on Stage to a MovieClip with [&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],"tags":[29,39],"class_list":["post-1908","post","type-post","status-publish","format-standard","hentry","category-flash","tag-flash-2","tag-flash-action-script"],"_links":{"self":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/1908","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=1908"}],"version-history":[{"count":9,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/1908\/revisions"}],"predecessor-version":[{"id":2475,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/1908\/revisions\/2475"}],"wp:attachment":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/media?parent=1908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/categories?post=1908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/tags?post=1908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}