<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>ASWebCreations.com</title>
	<atom:link href="http://aswebcreations.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://aswebcreations.com</link>
	<description>Web Application Development</description>
	<pubDate>Sun, 28 Mar 2010 22:54:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flash Media Portal</title>
		<link>http://aswebcreations.com/?p=711</link>
		<comments>http://aswebcreations.com/?p=711#comments</comments>
		<pubDate>Wed, 23 Dec 2009 16:04:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=711</guid>
		<description><![CDATA[I&#8217;m currently developing my first Wordpress plug-in which will be called &#8220;Flash Media Portal&#8221;. Its purpose will be to allow easy management and creation of any type of Flash application registered with the Flash Media Portal. These applications could be slide shows, Flash galleries, video players, music players and so on. Once registered with the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently developing my first Wordpress plug-in which will be called &#8220;Flash Media Portal&#8221;. Its purpose will be to allow easy management and creation of any type of Flash application registered with the Flash Media Portal. These applications could be slide shows, Flash galleries, video players, music players and so on. Once registered with the Flash Media Portal these application will be available to manage from within the Flash Media Portal. The Flash Media Portal provides a complex and intuitive Flash CMS in which you can select the application you want to work with. You can then create a file and add your assets (can upload from within the Flash Media Portal). Set any options available with the application selected. Save your work and then include in your post a simple img tag with the ID specified. The Flash Media Portal replace the img tag with the selected application and pass to it all relevant data for displaying. You can also manage easily which of your user can use the Flash Media Portal, by role and/or by name. You can also upload to your server any new available application directly from within the Flash Media Portal. </p>
<p>This is intended to allow me to create and publish easily new Flash application for Wordpress and any other CMS which the Flash Media Portal will be adapted for (Joomla and Drupal will be next). But of course if you are a Flash developer and are interested in publishing your Flash application via the Flash Media Portal just contact me. The advantage is obvious, all you have to do is create the Flash application and the Flash Media Portal will provide the rest and this on every CMS the Flash Media Portal will be adapted for. </p>
<p>Important to notice of course, the Flash Media Portal and every application it will provide will be free of charge.</p>
<p>Time for some screen shots! The Flash Media Portal is really on its last stage of development.</p>
<p>The Flash Media Portal will be accessible via the Media tab on the Wordpress CMS:<br />
<img alt="Flash Media Portal Welcome" src="http://aswebcreations.com/FMLDemo/welcomewindow.jpg" title="Welcome" width="500" height="264" /></p>
<p>You will be able to easily manage which user can use the Flash Media Portal, either by role or by name:<br />
<img alt="Manage your user easily with the Flash Media Portal" src="http://aswebcreations.com/FMLDemo/manageusers.jpg" title="User Manager" width="500" height="267" /></p>
<p>Upload new asset on the fly within the Flash Media Portal (server upload size restriction apply):<br />
<img alt="Upload easily your asset" src="http://aswebcreations.com/FMLDemo/upload.jpg" title="Upload" width="500" height="258" /></p>
<p>Once you selected the Flash application you want to work with you access the create screen. There you give a specific ID to your file and some usual options like size. Note that the html you&#8217;ll need to include in your post is created for you at the bottom of the create window:<br />
<img alt="Create easily new files for the Flash Media portal" src="http://aswebcreations.com/FMLDemo/create.jpg" title="Create" width="500" height="267" /></p>
<p>you can also of course load all previously saved work:<br />
<img alt="loading previously saved work" src="http://aswebcreations.com/FMLDemo/load.jpg" title="Load" width="500" height="278" /></p>
<p>once you created a file you can then access the manager window where you can add new assets, load, set options for each assets or for the application itself and so on. you can also preview your assets before using them:<br />
<img alt="preview your assets before using them" src="http://aswebcreations.com/FMLDemo/managerwindow.jpg" title="Preview" width="500" height="260" /></p>
<p>That&#8217;s all for this little overview of the Flash Media Portal. Don&#8217;t hesitate to contact me if you are interested in this plug-in.</p>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=711</wfw:commentRss>
		</item>
		<item>
		<title>Simple Cursor Class</title>
		<link>http://aswebcreations.com/?p=674</link>
		<comments>http://aswebcreations.com/?p=674#comments</comments>
		<pubDate>Wed, 09 Sep 2009 19:55:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=674</guid>
		<description><![CDATA[This is a very simple and easy to use cursor class. It provides simply a DisplayObject that you can use to replace the default mouse pointer. You then change the cursor type by setting its mode property. You can also alter its global size by using its sizeFactor property. Here is a simple demo:






]]></description>
			<content:encoded><![CDATA[<p>This is a very simple and easy to use cursor class. It provides simply a DisplayObject that you can use to replace the default mouse pointer. You then change the cursor type by setting its mode property. You can also alter its global size by using its sizeFactor property. Here is a simple demo:</p>
<p><object width="500" height="500" data="http://aswebcreations.com/classes/WC_demo.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/classes/WC_demo.swf" /></object></p>
<div style="background: url(http://aswebcreations.com/wp-content/themes/pixeled/images/bg-trans.png) repeat;text-margin-left:10px;">
<p style="margin:10px;"><object width="525" height="60" data="download.swf?target=cursorclass" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="FlashVars" value="cursorclass" /><param name="src" value="download.swf?target=cursorclass" /><param name="flashvars" value="cursorclass" /></object></p>
<p style="margin:10px;"><a href="http://aswebcreations.com/wp-content/uploads/2009/10/africa1.jpg"><br />
</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=674</wfw:commentRss>
		</item>
		<item>
		<title>Creating a Reflection with AS3.</title>
		<link>http://aswebcreations.com/?p=607</link>
		<comments>http://aswebcreations.com/?p=607#comments</comments>
		<pubDate>Sat, 15 Aug 2009 19:48:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=607</guid>
		<description><![CDATA[Creating a Reflection Effect.
Many people have read the simple reflection tutorial for AS2 that I wrote a while ago. Many also had a lot of questions about how to make this more dynamic, with more objects and so on. Rather than answering case after case, I decided to write a new tutorial exploring the reflection [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Creating a Reflection Effect.</strong></p>
<p><strong></strong>Many people have read the <a href="http://www.actionscript.org/resources/articles/760/1/Simple-reflection-effect-with-AS2/Page1.html" target="_blank">simple reflection tutorial for AS2</a> that I wrote a while ago. Many also had a lot of questions about how to make this more dynamic, with more objects and so on. Rather than answering case after case, I decided to write a new tutorial exploring the reflection concept deeper. I then eventually created a new easy-to-use class. Of course this tutorial is for AS3 but the basic principles that I will show are applicable to AS2 as well. <strong></strong></p>
<p><strong></strong>So let&#8217;s start by showing the basic principles behind a simple reflection in Flash. So let&#8217;s say we have an object that we want to add a reflection effect to:</p>
<p><object width="400" height="400" data="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_1.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_1.swf" /></object></p>
<p>Step number 1 is to create a copy of the object:</p>
<p><object width="400" height="400" data="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_2.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_2.swf" /></object></p>
<p>Step number 2 is to flip the copy. Here the reflection will be at the bottom so we flip the copy vertically:</p>
<p><object width="400" height="400" data="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_3.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_3.swf" /></object></p>
<p>Step number 3 is to create a gradient:</p>
<p><object width="400" height="400" data="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_4.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_4.swf" /></object></p>
<p>Step number 4 is to set one color of the gradient to transparent:</p>
<p><object width="400" height="400" data="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_5.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_5.swf" /></object></p>
<p>Finally set the gradient on top of the flipped copy and set the gradient as a mask for the flipped copy:</p>
<p><object width="400" height="400" data="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_6.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_6.swf" /></object></p>
<p>So to resume creating a reflection involves a few steps: Create a copy, flip the copy, create a gradient, set one color of the gradient transparent, and then set the gradient as a mask for the flipped copy. Now to translate that into code all we need to do is write a code that does all these steps for us.</p>
<p>It&#8217;s important also to notice that the way the reflection looks is completely dependent on the way the gradient is made. The second color of the gradient is fully transparent but what happens if I make the first one 50% transparent?</p>
<p><object width="400" height="400" data="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_7.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_7.swf" /></object></p>
<p>What happens if I move the gradient up?</p>
<p><object width="400" height="400" data="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_8.swf" type="application/x-shockwave-flash"><param name="src" value="http://aswebcreations.com/AS3Reflection/AS3ReflectionTutorial/draw_step_8.swf" /></object></p>
<p>So the gradient is the centerpiece of a nice reflection effect. We can move it, set different transparencies for its colors; we could also put the gradient at an angle to get interesting effect and so on. So now it&#8217;s time to apply what we learned and get into some coding.</p>
<p>previous - <a href="http://aswebcreations.com/?p=607">1</a> - <a href="http://aswebcreations.com/?p=621">2</a> - <a href="http://aswebcreations.com/?p=629">3</a> - <a href="http://aswebcreations.com/?p=633">4</a> - <a href="http://aswebcreations.com/?p=634">5</a> - <a href="http://aswebcreations.com/?p=636">6</a> - <a href="http://aswebcreations.com/?p=639">7</a> - <a href="http://aswebcreations.com/?p=642">8</a> - <a href="http://aswebcreations.com/?p=645">9</a> - <a href="http://aswebcreations.com/?p=649">10</a> - <a href="http://www.aswebcreations.com/?p=652">11</a> - <a href="http://aswebcreations.com/?p=621">next</a></p>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=607</wfw:commentRss>
		</item>
		<item>
		<title>ShaderExtended</title>
		<link>http://aswebcreations.com/?p=459</link>
		<comments>http://aswebcreations.com/?p=459#comments</comments>
		<pubDate>Mon, 01 Jun 2009 20:15:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=459</guid>
		<description><![CDATA[

The ShaderExtended class allows you to easily load and access a Pixel Bender Filter. Simply create an instance of the ShaderExtended class and pass a valid path to a Pixel Bender Filter. After completion of the filter loading an event is triggered and you can then start to set, get or animate your filter property. [...]]]></description>
			<content:encoded><![CDATA[<div style="background: url(http://aswebcreations.com/wp-content/themes/pixeled/images/bg-trans.png) repeat;text-margin-left:10px;">
<p style="margin:10px;"><object width="525" height="60" data="download.swf?target=ShaderExtended" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="FlashVars" value="ShaderExtended" /><param name="src" value="download.swf?target=ShaderExtended" /><param name="flashvars" value="ShaderExtended" /></object></div>
<p>The ShaderExtended class allows you to easily load and access a Pixel Bender Filter. Simply create an instance of the ShaderExtended class and pass a valid path to a Pixel Bender Filter. After completion of the filter loading an event is triggered and you can then start to set, get or animate your filter property. Relevant code on how to use this class is showed in this <a href="http://aswebcreations.com/?p=288" target="_self">tutorial</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=459</wfw:commentRss>
		</item>
		<item>
		<title>Dynamic Slide Show AS3 Complete Guide.</title>
		<link>http://aswebcreations.com/?p=244</link>
		<comments>http://aswebcreations.com/?p=244#comments</comments>
		<pubDate>Sat, 30 May 2009 22:55:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=244</guid>
		<description><![CDATA[This complete new tutorial is still in the process of being created. A few sections are already available with files to download, so be patient and don&#8217;t hesitate to already comment on the available sections or make requests for the incoming ones.
A Dynamic Slide Show is quite a simple application but the more dynamic you [...]]]></description>
			<content:encoded><![CDATA[<p>This complete new tutorial is still in the process of being created. A few sections are already available with files to download, so be patient and don&#8217;t hesitate to already comment on the available sections or make requests for the incoming ones.</p>
<p>A Dynamic Slide Show is quite a simple application but the more dynamic you want it, the more complex it gets. This tutorial will show you how to create a dynamic, flexible, and versatile slide show with AS3. The tutorial is divided in sections, each section covering a particular subject in the creation of a Slide Show. The sections are as follow:</p>
<p><a href="http://aswebcreations.com/?p=244" target="_self">1. Loading data (or why everybody uses XML?)</a><br />
<a href="http://aswebcreations.com/?p=249" target="_self">2. Loading Pictures (or How do I time this?)</a><br />
<a href="http://aswebcreations.com/?p=254" target="_self">3. Resizing and Autoresizing (or can the swf resizes itself?)</a><br />
<a href="http://aswebcreations.com/?p=569" target="_self">4. Adding Setup Options (or letting the user take charge)</a><br />
5. Adding Effects and Create Custom Effects (or Put The BitmapData Class to Work)<br />
6. Randomizing (or Adding Some Life)<br />
7. Adding Texts (or The Advantage of Classes)<br />
8. Adding Sound (or Turn That Off!)<br />
9. Cleaning Up (or Learn How To Take The Trash Out)<br />
10. CMS (or Live And Let Live)</p>
<p>Each new section will build upon the preceding one. The code will be presented in a document class format running in Flash CS3/4 making it easily adaptable for Flex users (might need to import some missing classes and set some additional stage properties). So let&#8217;s already start with our first section.</p>
<p><strong>Loading data (or why everybody uses XML?).</strong></p>
<p>Most application must load some kind of data when they start and a Dynamic Slide Show is not different, it must load at least the path of the pictures it&#8217;s going to display and maybe additional information like timing, URL paths and so on. This first section shows you how to load data via an XML object.</p>
<p><span class="style1">Why everybody uses XML?</span></p>
<p>XML as become a standard on the web for passing information from website to website, from web application to server side and reverse, and in many other cases. The reason is simple, with XML the data is (or is supposed to be) well organized, already sorted for you. XML nodes are supposed to describe the data they enclose making the work of the programmer easier.</p>
<p>So let&#8217;s start building our slide show, create a new Actionscript 3 document, set its width and height to 400, its frame rate to 30 and save. Now let&#8217;s create our document class, create a new Actionscript file and save it in the same folder than the Fla file you just created, give it for example a name of &#8220;LoadingData.as&#8221;. Now back to our Fla file, set the document class as &#8220;LoadingData&#8221; and save. From now we will be working with the document class only but leave the Fla open anyway as we will need it for compiling the swf. Let&#8217;s create a simple XML that we will load in our application:</p>
<p>&lt;SLIDE_SHOW&gt;</p>
<p>&lt;PICTURES&gt;</p>
<p>&lt;PICTURE_PATH&gt;&lt;/PICTURE_PATH&gt;</p>
<p>&lt;PICTURE_PATH&gt;&lt;/PICTURE_PATH&gt;</p>
<p>&lt;PICTURE_PATH&gt;&lt;/PICTURE_PATH&gt;</p>
<p>&lt;PICTURE_PATH&gt;&lt;/PICTURE_PATH&gt;</p>
<p>&lt;/PICTURES&gt;</p>
<p>&lt;/SLIDE_SHOW&gt;</p>
<p>SLIDE_SHOW is what we call a root tag, it encloses all the other tags and is required to form a valid XML object. PICTURES is the tag that we will use to pass our picture paths to the application, this tag will enclose all the picture paths. PICTURE_PATH is our final tag and we will add paths inside these tags to point to our pictures. We still did not setup a picture folder but let&#8217;s go ahead and pretend we did and add some paths into our XML:</p>
<p>&lt;SLIDE_SHOW&gt;</p>
<p>&lt;PICTURES&gt;</p>
<p>&lt;PICTURE_PATH&gt;mypicture1.jpg&lt;/PICTURE_PATH&gt;</p>
<p>&lt;PICTURE_PATH&gt;mypicture2.jpg&lt;/PICTURE_PATH&gt;</p>
<p>&lt;PICTURE_PATH&gt;mypicture3.jpg&lt;/PICTURE_PATH&gt;</p>
<p>&lt;PICTURE_PATH&gt;mypicture4.jpg&lt;/PICTURE_PATH&gt;</p>
<p>&lt;/PICTURES&gt;</p>
<p>&lt;/SLIDE_SHOW&gt;</p>
<p>Here now there&#8217;s something in our tags, let&#8217;s save this XML as &#8220;slide_show.xml&#8221; and save it in the same folder as our Fla and as files.</p>
<p>Now let&#8217;s write our document class. Open the actionscript file named &#8220;LoadingData.as&#8221;. A document class in AS3 must be enclosed in a package so let&#8217;s do that first:</p>
<p><code>package{<br />
}</code></p>
<p>Quite easy, now inside this package let&#8217;s declare our document class (its name must match the actionscript file name):</p>
<p><code>package {<br />
public class LoadingData<br />
{<br />
}<br />
}</code></p>
<p>A document class in AS3 must extend either MovieClip or Sprite, use MovieClip when you intend to use timeline based animation, use Sprite when you won&#8217;t use any timeline. We won&#8217;t use any timeline based animation here so let&#8217;s go ahead and extend Sprite. We import the Sprite class and extends it:</p>
<p><code>package {<br />
import flash.display.Sprite;<br />
public class LoadingData extends Sprite<br />
{<br />
}<br />
}</code></p>
<p>Finaly let&#8217;s create our constructor. A constructor is a function with the same name as the class, it never returns a value and will automatically run when the document class is called (when the application starts):</p>
<p><code>package {<br />
import flash.display.Sprite;<br />
public class LoadingData extends Sprite<br />
{<br />
public function LoadingData()<br />
{<br />
}<br />
}<br />
}</code></p>
<p>I will not describe again how to create a document class in the next sections so if you forget how to do this come back to this page and review the process. Now time to write code that actually does something! Loading our XML! We need to import a couple of classes to load our data, the URLRequest class, all the events class package (we&#8217;ll need those) events.*, the TextField class that we&#8217;ll use to show our XML, and the URLLoader class. We also declare a few member variables: A variable to hold our XML data &#8220;var picture_xml:XML;&#8221;, a variable to hold our URLRequest &#8220;var url_request:URLRequest;&#8221;, and a variable to hold our URLLoader &#8220;var url_loader:URLLoader;&#8221;:</p>
<p><code>package {<br />
import flash.display.Sprite;<br />
import flash.net.URLRequest;<br />
import flash.net.URLLoader;<br />
public class LoadingData extends Sprite<br />
{<br />
var picture_xml:XML<br />
var url_request:URLRequest;<br />
var url_loader:URLLoader;<br />
public function LoadingData()<br />
{<br />
}<br />
}<br />
}<br />
</code><br />
Now in our constructor we are going to instantiate our URLRequest, and URLLoader variables, write some code to initiate the loading and add a COMPLETE event to trigger a function when the XML data is fully loaded:</p>
<p><code>package {<br />
import flash.display.Sprite;<br />
import flash.net.URLRequest;<br />
import flash.net.URLLoader;<br />
import flash.events.*;<br />
import flash.text.TextField;<br />
public class LoadingData extends Sprite<br />
{<br />
var picture_xml:XML<br />
var url_request:URLRequest;<br />
var url_loader:URLLoader;<br />
public function LoadingData()<br />
{<br />
url_request = new URLRequest("slide_show.xml");<br />
url_loader = new URLLoader();<br />
url_loader.addEventListener(Event.COMPLETE, completeHandler);<br />
url_loader.load(url_request);<br />
}<br />
private function completeHandler(e:Event):void{<br />
picture_xml = new XML(url_loader.data);<br />
var txt:TextField = new TextField();<br />
txt.width = stage.stageWidth;<br />
txt.height = stage.stageHeight;<br />
txt.wordWrap = true;<br />
txt.text = picture_xml;<br />
addChild(txt);<br />
}<br />
}<br />
}</code></p>
<p>If everything went well you should like me see our XML displayed in our textfield. Now to be truly dynamic our slide show should be able to load different XMLs. For example you should be able to display two slide shows in the same html page with different pictures which means loading different XMLs. We can do so by using FlashVars. Back to our Fla file you can go ahead and hit &#8220;publish&#8221; to get an html file with the slide show embedded. Now we can modify this html and add FlashVars to pass to our slide show. Open the html file in your favorite html editor or notepad and look for this:</p>
<p><code>&lt;script language="JavaScript" type="text/javascript"&gt;<br />
AC_FL_RunContent(<br />
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',<br />
'width', '400',<br />
'height', '400',<br />
'src', 'loading',<br />
'quality', 'high',<br />
'pluginspage', 'http://www.adobe.com/go/getflashplayer',<br />
'align', 'middle',<br />
'play', 'true',<br />
'loop', 'true',<br />
'scale', 'showall',<br />
'wmode', 'window',<br />
'devicefont', 'false',<br />
'id', 'loading',<br />
'bgcolor', '#ffffff',<br />
'name', 'loading',<br />
'menu', 'true',<br />
'allowFullScreen', 'false',<br />
'allowScriptAccess','sameDomain',<br />
'movie', 'loading',<br />
'salign', ''<br />
); //end AC code</code></p>
<p>add between two lines this &#8216;FlashVars&#8217;, &#8216;xml=slide_show.xml&#8217;, so you should now have this:</p>
<p><code>&lt;script language="JavaScript" type="text/javascript"&gt;<br />
AC_FL_RunContent(<br />
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',<br />
'width', '400',<br />
'height', '400',<br />
'src', 'loading',<br />
'quality', 'high',<br />
'pluginspage', 'http://www.adobe.com/go/getflashplayer',<br />
'align', 'middle',<br />
'play', 'true',<br />
'loop', 'true',<br />
'scale', 'showall',<br />
'wmode', 'window',<br />
'devicefont', 'false',<br />
'id', 'loading',<br />
'bgcolor', '#ffffff',<br />
'name', 'loading',<br />
'menu', 'true',<br />
'allowFullScreen', 'false',<br />
'allowScriptAccess','sameDomain',<br />
'FlashVars', 'xml=slide_show.xml',<br />
'movie', 'loading',<br />
'salign', ''<br />
); //end AC code</code></p>
<p>Now look for this:</p>
<p><code>&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="400" height="400" id="loading" align="middle"&gt;<br />
&lt;param name="allowScriptAccess" value="sameDomain" /&gt;<br />
&lt;param name="allowFullScreen" value="false" /&gt;<br />
&lt;param name="movie" value="loading.swf" /&gt;&lt;param name="quality" value="high" /&gt;&lt;param name="bgcolor" value="#ffffff" /&gt;	&lt;embed src="loading.swf" quality="high" bgcolor="#ffffff" width="400" height="400"name="loading" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /&gt;<br />
&lt;/object&gt;</code></p>
<p>and add FlashVars at two places like this:<br />
<code><br />
&lt;object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="400" height="400" id="loading" align="middle"&gt;<br />
&lt;param name="allowScriptAccess" value="sameDomain" /&gt;<br />
&lt;param name="allowFullScreen" value="false" /&gt;<br />
&lt;param name="FlashVars" value="xml=slide_show.xml"&gt;<br />
&lt;param name="movie" value="loading.swf" /&gt;&lt;param name="quality" value="high" /&gt;&lt;param name="bgcolor" value="#ffffff" /&gt;	&lt;embed src="loading.swf" quality="high" bgcolor="#ffffff" width="400" height="400" <span class="style2">FlashVars=&#8221;xml=slide_show.xml&#8221;</span> name=&#8221;loading&#8221; align=&#8221;middle&#8221; allowScriptAccess=&#8221;sameDomain&#8221; allowFullScreen=&#8221;false&#8221; type=&#8221;application/x-shockwave-flash&#8221; pluginspage=&#8221;http://www.adobe.com/go/getflashplayer&#8221; /&gt;<br />
&lt;/object&gt;</code></p>
<p>Now let&#8217;s modify our document class to load our FlashVars prior to load our XML, we do this in the constructor:</p>
<p><code>var xml_path:String = "";<br />
xml_path = this.loaderInfo.parameters.xml || "slide_show.xml";<br />
url_request = new URLRequest(xml_path);</code></p>
<p>Now if you compile the application and run it in a browser you should be able to see our xml data and you should be able to pass different XMLs too. A little explanation about his line:</p>
<p><code>xml_path = this.loaderInfo.parameters.xml || "slide_show.xml";</code></p>
<p>This is a conditional that will allow us to keep developing our application in Flash CS3/4 since FlashVars is available only in a browser. The conditional first passes the FlashVars to the string variable and if the value is not available it then passes the string path which is the one we&#8217;ll use for developing. Now let&#8217;s go even further and load instead of an XML file, an XML object.</p>
<p>An XML object is not an XML file, an XML object is any valid XML formatted document or string that can be interpreted as XML. So another way to load XML data is to use a server side script like this PHP one called &#8220;simple.php&#8221;:</p>
<p><code>&lt;?<br />
$xml = "&lt;SLIDE_SHOW&gt;&lt;PICTURES&gt;&lt;PICTURE_PATH&gt;mypicture1.jpg&lt;/PICTURE_PATH&gt;&lt;PICTURE_PATH&gt;mypicture2.jpg&lt;/PICTURE_PATH&gt;";<br />
$xml .= "&lt;PICTURE_PATH&gt;mypicture3.jpg&lt;/PICTURE_PATH&gt;&lt;PICTURE_PATH&gt;mypicture4.jpg&lt;/PICTURE_PATH&gt;&lt;/PICTURES&gt;&lt;/SLIDE_SHOW&gt;";<br />
print($xml);<br />
?&gt;</code></p>
<p>Now we can modify the FlashVars to pass this &#8220;simple.php&#8221; instead of an XML file. Let&#8217;s do that and upload everything to a PHP enabled server and test it. If everything went well you should like me see our data. Now let&#8217;s go further in the server side script interaction, we could use our server side script to look inside a folder and pass as an XML object any picture we find, so let&#8217;s set up a folder with a few pictures on the server and create a new PHP script to grab any pictures it can find, this script is called &#8220;external.php&#8221; don&#8217;t forget to change the FlashVars when testing this:</p>
<p><code>&lt;?php<br />
$dir = opendir("assets/");<br />
print("&lt;SLIDE_SHOW&gt;&lt;PICTURES&gt;");<br />
while($file = readdir($dir)){<br />
if((substr(strtolower($file),-4)==".png") || (substr(strtolower($file),-4)==".jpg") || (substr(strtolower($file),-4)==".gif") ||<br />
(substr(strtolower($file),-5)==".jpeg")){<br />
print("&lt;PICTURE_PATH&gt;assets/".$file."&lt;/PICTURE_PATH&gt;");<br />
}<br />
}<br />
print("&lt;/PICTURES&gt;&lt;/SLIDE_SHOW&gt;");<br />
?&gt;</code></p>
<p>When you test this you get back an XMLobject with all pictures present in a given folder. We can also apply the same principle with a database, we could create a database to save the picture paths and give each picture a type so our php script will give us the right pictures for the right slide show. For example if there&#8217;s a slide show on an index page then we could have pictures in the database with the type &#8220;index&#8221; and for another slide show on the about page we could have type &#8216;about&#8217;. Let&#8217;s see this in action with this new PHP script called &#8220;database.php&#8221; and let&#8217;s pass the picture type directly as a query with the PHP script name like this:</p>
<p>xml=database.php?type=index</p>
<p>and here is the script:</p>
<p><code>&lt;?php<br />
$db = mysql_connect("yourid", "yourusername" , "yourpassword");<br />
mysql_select_db("yourdatabase",$db);<br />
$query = 'select PICTURE_PATH from PICTURES where TYPE='.$_REQUEST['type'].&#8217; &#8216;;<br />
$query_result = mysql_query($query);<br />
print(&#8221;&lt;SLIDE_SHOW&gt;&lt;PICTURES&gt;&#8221;);<br />
while ($row = mysql_fetch_array($query_result, MYSQL_ASSOC)) {<br />
print(&#8221;&lt;PICTURE_PATH&gt;&#8221;.$row['PICTURE_PATH'].&#8221;&lt;/PICTURE_PATH&gt;&#8221;);<br />
}<br />
print(&#8221;&lt;/PICTURES&gt;&lt;/SLIDE_SHOW&gt;&#8221;);<br />
?&gt;</code></p>
<p>As you saw loading data is a bigger subject than one might think, anyway we covered the most standard situations with the database loading being the most flexible in my opinion since we&#8217;ll be able to link this easily to a CMS (sure why not?). Now it&#8217;s time to laod some pictures!</p>
<div style="background: url(http://aswebcreations.com/wp-content/themes/pixeled/images/bg-trans.png) repeat;text-margin-left:10px;">
<p style="margin:10px;"><object width="525" height="60" data="download.swf?target=DSS1" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="FlashVars" value="DSS1" /><param name="src" value="download.swf?target=DSS1" /><param name="flashvars" value="DSS1" /></object></div>
<div>previous - <a href="http://aswebcreations.com/?p=244">1</a> - <a href="http://aswebcreations.com/?p=249">2</a> - <a href="http://aswebcreations.com/?p=254">3</a> - <a href="http://aswebcreations.com/?p=569">4</a> - 5 - 6 - 7 - 8 - 9 - 10 - <a href="http://aswebcreations.com/?p=249">next</a></div>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=244</wfw:commentRss>
		</item>
		<item>
		<title>Drawing shapes with AS3</title>
		<link>http://aswebcreations.com/?p=514</link>
		<comments>http://aswebcreations.com/?p=514#comments</comments>
		<pubDate>Sat, 30 May 2009 21:41:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=514</guid>
		<description><![CDATA[Drawing any shapes with AS3 is very easy. In this tutorial I will show you how to draw a basic shape and then how to apply this knowledge into a dynamic application.
1. Open your Flash CS3 software, select &#8220;new&#8221;, &#8220;Flash File (Actionscript 3) &#8220;, click &#8220;Ok&#8221;, then go to &#8220;Modify&#8221;, &#8220;Document&#8221;, enter 300 for the [...]]]></description>
			<content:encoded><![CDATA[<p>Drawing any shapes with AS3 is very easy. In this tutorial I will show you how to draw a basic shape and then how to apply this knowledge into a dynamic application.</p>
<p>1. Open your Flash CS3 software, select &#8220;new&#8221;, &#8220;Flash File (Actionscript 3) &#8220;, click &#8220;Ok&#8221;, then go to &#8220;Modify&#8221;, &#8220;Document&#8221;, enter 300 for the width and height and enter 30 for the frame rate.</p>
<p>2. Open the &#8220;Actions&#8221; panel.</p>
<p>3. Copy and Paste this code:</p>
<p><code>var square:Sprite = new Sprite();<br />
addChild(square);<br />
square.graphics.lineStyle(3,0x00ff00);<br />
square.graphics.beginFill(0x0000FF);<br />
square.graphics.drawRect(0,0,100,100);<br />
square.graphics.endFill();<br />
square.x = stage.stageWidth/2-square.width/2;<br />
square.y = stage.stageHeight/2-square.height/2;</code></p>
<p>4. Hit &#8220;Ctrl+Enter&#8221;    or go to &#8220;Control&#8221;, &#8220;Test Movie&#8221; to test our Flash movie. You should see this:</p>
<p><object width="300" height="300" data="tutorials/new_drawing_shape_tutorial/shape_tutorial.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="src" value="tutorials/new_drawing_shape_tutorial/shape_tutorial.swf" /></object></p>
<p>Here is what the code does:</p>
<p><code>var square:Sprite = new Sprite();</code></p>
<p>We create a sprite object which is pretty much like a MovieClip but without a timeline.</p>
<p><code>addChild(square);</code></p>
<p>We add our sprite to the display list which means we tell Flash that we want this sprite to be displayed.</p>
<p><code>square.graphics.lineStyle(3,0x00ff00);</code></p>
<p>We assign a graphics object to our sprite (If you worked with Java that might seem pretty familiar). Then we assign a line style to the graphic object.</p>
<p><code>square.graphics.beginFill(0x0000FF);</code></p>
<p>We assign a fill color to our graphic object.</p>
<p><code>square.graphics.drawRect(0,0,100,100);</code></p>
<p>We draw a rectangle using the drawRect() method.</p>
<p><code>square.graphics.endFill();</code></p>
<p>We tell Flash we are done drawing. (the other two lines of code are for positioning).</p>
<p>Now since there are many platforms and many ways to write AS3 code, I&#8217;m going to try to make this tutorial as versatile as possible so here is a document class version that you can use with a Flex Actionscript project or simply by using the document class box in the Flash CS3 environment. So copy and paste the following code in Notepad for example and save it as simple_shape.as:</p>
<p><code>package{<br />
import flash.display.Sprite;<br />
public class simple_shape extends Sprite{<br />
var square:Sprite;<br />
public function simple_shape(){<br />
square = new Sprite();<br />
addChild(square);<br />
square.graphics.lineStyle(3,0x00ff00);<br />
square.graphics.beginFill(0x0000FF);<br />
square.graphics.drawRect(0,0,100,100);<br />
square.graphics.endFill();<br />
square.x = stage.stageWidth/2-square.width/2;<br />
square.y = stage.stageHeight/2-square.height/2;<br />
}}<br />
}</code></p>
<p>Now in Flex, set this file as the document class, and in Flash CS3 write &#8220;simple_shape&#8221; in the document class box. Run the example.</p>
<p>Now starting from a document class, it&#8217;s easy enough to create a real class out of it so I&#8217;ll leave that up to you.</p>
<p>We can as easily create a rounded rectangle:</p>
<p><code>var square:Sprite = new Sprite();<br />
addChild(square);<br />
square.graphics.lineStyle(3,0x00ff00);<br />
square.graphics.beginFill(0x0000FF);<br />
square.graphics.drawRoundRect(0,0,100,100,20);<br />
square.graphics.endFill();<br />
square.x = stage.stageWidth/2-square.width/2;<br />
square.y = stage.stageHeight/2-square.height/2;</code></p>
<p>Document Class (simple_rounded_shape.as):</p>
<p><code>package{<br />
import flash.display.Sprite;<br />
public class simple_rounded_shape extends Sprite{<br />
var square:Sprite;<br />
public function simple_rounded_shape(){<br />
square = new Sprite();<br />
addChild(square);<br />
square.graphics.lineStyle(3,0x00ff00);<br />
square.graphics.beginFill(0x0000FF);<br />
square.graphics.drawRoundRect(0,0,100,100,20);<br />
square.graphics.endFill();<br />
square.x = stage.stageWidth/2-square.width/2;<br />
square.y = stage.stageHeight/2-square.height/2;<br />
}}<br />
}</code></p>
<p>And here is the result:</p>
<p><object width="300" height="300" data="tutorials/new_drawing_shape_tutorial/shape_rounded_tutorial.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="src" value="tutorials/new_drawing_shape_tutorial/shape_rounded_tutorial.swf" /></object></p>
<p>You can of course get a total control on how the shape is drawn with the good old moveTo() and lineTo() methods:</p>
<p><code>var square:Sprite = new Sprite();<br />
addChild(square);<br />
square.graphics.lineStyle(3,0x00ff00);<br />
square.graphics.beginFill(0x0000FF);<br />
drawShape(square);<br />
square.graphics.endFill();<br />
square.x = stage.stageWidth/2-square.width/2;<br />
square.y = stage.stageHeight/2-square.height/2;<br />
function drawShape(sprite:Sprite):void{<br />
sprite.graphics.lineStyle(3,0x00ff00);<br />
sprite.graphics.beginFill(0x0000FF);<br />
sprite.graphics.moveTo(0,0);<br />
sprite.graphics.lineTo(100,0);<br />
sprite.graphics.lineTo(100,100);<br />
sprite.graphics.lineTo(0,100);<br />
sprite.graphics.lineTo(0,0);<br />
sprite.graphics.endFill();<br />
}</code></p>
<p>Document Class (simple_lineTo_shape.as):</p>
<p><code>package{<br />
import flash.display.Sprite;<br />
public class simple_lineTo_shape extends Sprite{<br />
var square:Sprite;<br />
public function simple_lineTo_shape(){<br />
square = new Sprite();<br />
addChild(square);<br />
square.graphics.lineStyle(3,0x00ff00);<br />
square.graphics.beginFill(0x0000FF);<br />
drawShape(square);<br />
square.graphics.endFill();<br />
square.x = stage.stageWidth/2-square.width/2;<br />
square.y = stage.stageHeight/2-square.height/2;<br />
}<br />
private function drawShape(sprite:Sprite):void{<br />
sprite.graphics.lineStyle(3,0x00ff00);<br />
sprite.graphics.beginFill(0x0000FF);<br />
sprite.graphics.moveTo(0,0);<br />
sprite.graphics.lineTo(100,0);<br />
sprite.graphics.lineTo(100,100);<br />
sprite.graphics.lineTo(0,100);<br />
sprite.graphics.lineTo(0,0);<br />
sprite.graphics.endFill();<br />
}}<br />
}</code></p>
<p>MoveTo() and lineTo() methods were already part of AS2 and I covered how to use them in details in this <a href="http://aswebcreations.com/?p=180">AS2 tutorial</a>. These are actually the methods that we will need most of the time if we want to create a dynamic shape. Let&#8217;s see that in the next page.</p>
<div>previous - <a href="http://aswebcreations.com/?p=514">1</a> - <a href="http://aswebcreations.com/?p=516">2</a> - <a href="http://aswebcreations.com/?p=516" target="_self">next</a></div>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=514</wfw:commentRss>
		</item>
		<item>
		<title>Introduction to Pixel Bender and Shader for Flash Player 10</title>
		<link>http://aswebcreations.com/?p=117</link>
		<comments>http://aswebcreations.com/?p=117#comments</comments>
		<pubDate>Sat, 30 May 2009 18:34:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=117</guid>
		<description><![CDATA[Flash Player 10 came with a set of new classes to load and use Pixel Bender files in our Flash applications. In this tutorial we&#8217;ll take a look at Pixel bender syntax and how to write your own Pixel Bender files. We will also see how to load Pixel Bender files in Flash and use [...]]]></description>
			<content:encoded><![CDATA[<p>Flash Player 10 came with a set of new classes to load and use Pixel Bender files in our Flash applications. In this tutorial we&#8217;ll take a look at Pixel bender syntax and how to write your own Pixel Bender files. We will also see how to load Pixel Bender files in Flash and use them in different ways.</p>
<p>First if you still did not download the Pixel Bender Toolkit you should do so <a href="http://labs.adobe.com/technologies/pixelbender/">here</a>. The Pixel Bender Toolkit comes with a set of Pixel Bender filters so feel free to study them to get a better understanding of Pixel Bender syntax. You can also search the web to find additional Pixel Bender filters.</p>
<p>In this tutorial we&#8217;ll create some simple filters with the Pixel Bender Toolkit and later on we&#8217;ll use some existing ones so let&#8217;s get started.</p>
<p>Start the Pixel Bender toolkit and choose &#8220;New Kernel&#8221;, a complete new working kernel file is automatically created for you. You can already run this filter, you&#8217;ll probably be prompted to load a picture and after doing so, the filter will be running. Of course the only thing this filter is doing so far is copy each pixels from the base image into the output image so that&#8217;s not that useful but let&#8217;s take a look anyway. First you have the kernel description:</p>
<p><code>kernel NewFilter<br />
&lt;<br />
namespace : "Your Namespace";<br />
vendor : "Your Vendor";<br />
version : 1;<br />
description : "your description";<br />
&gt;</code></p>
<p>You can give a name to your filter here as well as other information like the version of this filter, a description and so on. Next:</p>
<p><code>input image4 src;<br />
output pixel4 dst;</code></p>
<p>You specify an input of type image4 (4 channels) and a name &#8220;src&#8221;. The filter will use this input as a base. You also specify an output of type pixel4 (4 channels) and a name &#8220;dst&#8221;. The filter will pass the result of its calculation to this ouput. Then:</p>
<p><code>void evaluatePixel(){<br />
dst = sampleNearest(src,outCoord());<br />
}</code></p>
<p>This function (evaluatePixel) will run once for each element (pixel) in your input data. The sampleNearest method is returning a pixel value and this pixel value is assigned to the &#8220;dst&#8221; output. The sampleNearest method takes a source (in our case an image4 source), and a set of coordinate (outCoord() returns the coordinates of the current element or pixel). If you pass an image4 you get back a pixel4 value, if you were to pass an image3, you would get a pixel3 and so on. The number determines how many values you get or have to set for example:<br />
<code><br />
float myfloat = 1.0;//one value<br />
float2 myotherfoat = float2(1.0,1.0);//two values<br />
float3 mythreefoat = float3(1.0,1.0,1.0);//three values<br />
float4 myfourfoat = float4(1.0,1.0,1.0,1.0);//four values</code></p>
<p>Casting is possible of course if type are compatible like from int to float for example. Obviously if you try to pass a pixel 3 to an image4 you&#8217;ll get yourself an error so just be aware of that. Let&#8217;s modify our code so our output looks different:</p>
<p><code>dst = pixel4(sin(float4(sampleNearest(src,outCoord()))));</code></p>
<p>You should get a slight alteration of your picture lightness. You probably know the sin method already and what it does. Here we casted our sampleNearest result into a float4 (so we did cast from pixel4 to float4) so we could apply the sin method, then of course we did cast back to pixel4 so we could assign the result into our output. Already you can experiment with the numerous math methods and see what result you get. try this one for example:</p>
<p><code>dst = pixel4(sqrt(float4(sampleNearest(src,outCoord()))));</code></p>
<p>Moreover we could separate each pixels and apply some calculation on each one of them:</p>
<p><code>pixel4 temp = sampleNearest(src,outCoord());<br />
dst = temp;</code></p>
<p>Back to the beginning but here we have our pixels stored in a variable so we can access them individually so let&#8217;s do that now:</p>
<p><code>pixel4 temp = sampleNearest(src,outCoord());<br />
temp.r = 0.0;<br />
dst = temp;</code></p>
<p>Here we basically turned off the red channel so all red is gone from our picture. You could apply numerous math operation on these pixels and get some amazing result. Of course your level in math will determine your ability to create complex filters but this is for you to discover. Now it&#8217;s time to take a look at what we can do with Pixel Bender filters in Flash and as we go we&#8217;ll look at more Pixel Bender code of course.</p>
<div align="center">previous - <a href="http://aswebcreations.com/?p=117">1</a> - <a href="http://aswebcreations.com/?p=285">2</a>  - <a href="http://aswebcreations.com/?p=288">3</a> - <a href="http://aswebcreations.com/?p=285">next</a></div>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=117</wfw:commentRss>
		</item>
		<item>
		<title>Reflection effect with AS2 in 4 easy steps</title>
		<link>http://aswebcreations.com/?p=530</link>
		<comments>http://aswebcreations.com/?p=530#comments</comments>
		<pubDate>Fri, 29 May 2009 22:16:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=530</guid>
		<description><![CDATA[A discreet reflection effect can add a nice &#8220;touch&#8221; when displaying pictures, graphics and such. In this tutorial you will learn not only how to create this effect but also how it works and how to modify it as you please, so let&#8217;s get started!
Open your Flash software, select &#8220;new&#8221;, &#8220;Flash document&#8221;, click &#8220;Ok&#8221;, then [...]]]></description>
			<content:encoded><![CDATA[<p>A discreet reflection effect can add a nice &#8220;touch&#8221; when displaying pictures, graphics and such. In this tutorial you will learn not only how to create this effect but also how it works and how to modify it as you please, so let&#8217;s get started!</p>
<p>Open your Flash software, select &#8220;new&#8221;, &#8220;Flash document&#8221;, click &#8220;Ok&#8221;, then go to &#8220;Modify&#8221;, &#8220;Document&#8221;, enter 400 for the width and heigth and enter 30 for the frame rate.<br />
Open the &#8220;Actions&#8221; panel.</p>
<p><strong>First Step:</strong></p>
<p>Of  course to apply a reflection we first need a picture or graphic to  apply the reflection to.<br />
In this first step we just load dynamically a picture:</p>
<p><code>this.createEmptyMovieClip("image_mc", 1);<br />
var mclListener:Object = new Object();<br />
mclListener.onLoadInit = function(target_mc:MovieClip) {<br />
target_mc._x = (Stage.width/2)-(target_mc._width/2);<br />
target_mc._y = 0;<br />
};<br />
var image_mcl:MovieClipLoader = new MovieClipLoader();<br />
image_mcl.addListener(mclListener);<br />
image_mcl.loadClip("none.jpg", image_mc);//replace this by any picture you have</code></p>
<p>Hit &#8220;Ctrl+Enter&#8221; or go to &#8220;Control&#8221;, &#8220;Test Movie&#8221; to test our Flash movie. You should see this:</p>
<p>
  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="400" id="reflection" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="tutorials/reflection/reflectionStep1.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="tutorials/reflection/reflectionStep1.swf" quality="high" bgcolor="#ffffff" width="400" height="400" name="reflection" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br />
  </object>
</p>
<p>That&#8217;s a nice looking picture. Here is what the code does:</p>
<p><code>this.createEmptyMovieClip("image_mc", 1);</code></p>
<p>We create a movieclip and give it a name of &#8220;image_mc&#8221; and a depth of 1.</p>
<p><code>var mclListener:Object = new Object();</code></p>
<p>We create a object that we will use to check (listening) if the picture is loaded.</p>
<p><code>mclListener.onLoadInit = function(target_mc:MovieClip) {<br />
target_mc._x = (Stage.width/2)-(target_mc._width/2);<br />
target_mc._y = 0;<br />
};</code></p>
<p>When the picture is fully loaded the onLoadInit function will trigger and set the referenced movieclip (image_mc) to the middle of the screen horizontally.</p>
<p><code>var image_mcl:MovieClipLoader = new MovieClipLoader();<br />
image_mcl.addListener(mclListener);<br />
image_mcl.loadClip("none.jpg", image_mc);//replace this by any picture you have</code></p>
<p>We create a MovieClipLoader object, then set our listener object, then load the picture in the image_mc. Note: replace &#8220;none.jpg&#8221; by any picture you want, be aware that this code does not re size pictures.</p>
<p><strong>Step Two:</strong></p>
<p>To create the reflection effect we need to copy the existing movieclip, flip the image and place it below the existing movieclip. To do this, we are going to create a custom function, pass the existing movieclip as parameter and call the function from within the onLoadInit function we already used. In this new function we will use the bitmapData class to copy our existing movieclip so first we need to import the bitmapData class.</p>
<p>Before any other code, insert this to import the bitmapData class:</p>
<p><code>import flash.display.BitmapData; </code></p>
<p>inside the onLoadInit function insert this new line:</p>
<p><code>mclListener.onLoadInit = function(target_mc:MovieClip) {<br />
target_mc._x = (Stage.width/2)-(target_mc._width/2);<br />
target_mc._y = 0;<br />
reflect(target_mc);// new line used to call our new function<br />
};</code></p>
<p>Now time to create our new function:</p>
<p><code>function reflect(target_mc:MovieClip):Void{<br />
var myBitmapData:BitmapData = new BitmapData(target_mc._width, target_mc._height, false, 0x00CCCCCC);<br />
var mc_1:MovieClip = this.createEmptyMovieClip("reflect_mc", 2);<br />
mc_1.attachBitmap(myBitmapData, 3);<br />
myBitmapData.draw(target_mc);<br />
reflect_mc._yscale = -100;<br />
reflect_mc._y= target_mc._y+target_mc._height*2+20;<br />
reflect_mc._x = target_mc._x;<br />
}</code></p>
<p>And here is the complete code:</p>
<p><code>import flash.display.BitmapData;<br />
this.createEmptyMovieClip("image_mc", 1);<br />
var mclListener:Object = new Object();<br />
mclListener.onLoadInit = function(target_mc:MovieClip) {<br />
target_mc._x = (Stage.width/2)-(target_mc._width/2);<br />
target_mc._y = 0;<br />
reflect(target_mc);<br />
};<br />
var image_mcl:MovieClipLoader = new MovieClipLoader();<br />
image_mcl.addListener(mclListener);<br />
image_mcl.loadClip("none.jpg", image_mc);<br />
function reflect(target_mc:MovieClip):Void{<br />
var myBitmapData:BitmapData = new BitmapData(target_mc._width, target_mc._height, false, 0x00CCCCCC);<br />
var mc_1:MovieClip = this.createEmptyMovieClip("reflect_mc", 2);<br />
mc_1.attachBitmap(myBitmapData, 3);<br />
myBitmapData.draw(target_mc);<br />
reflect_mc._yscale = -100;<br />
reflect_mc._y= target_mc._y+target_mc._height*2+20;<br />
reflect_mc._x = target_mc._x; }</code></p>
<p>Hit &#8220;Ctrl+Enter&#8221; or go to &#8220;Control&#8221;, &#8220;Test Movie&#8221; to test our Flash movie. You should see this:</p>
<p>
  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="400" id="reflection" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="tutorials/reflection/reflectionStep2.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="tutorials/reflection/reflectionStep2.swf" quality="high" bgcolor="#ffffff" width="400" height="400" name="reflection" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br />
  </object>
</p>
<p>Now there&#8217;s a flipped copy of our picture below. Here is what the code does:</p>
<p><code>var myBitmapData:BitmapData = new BitmapData(target_mc._width, target_mc._height, false, 0x00CCCCCC);</code></p>
<p>We create a new instance of the BitmapData class and pass it the image_mc size as parameters which determines the size of the bitmap.</p>
<p><code>var mc_1:MovieClip = this.createEmptyMovieClip("reflect_mc", 2);</code></p>
<p>We create an empty movieClip.</p>
<p><code>mc_1.attachBitmap(myBitmapData, 3);</code></p>
<p>We attach the bitmap to the empty movieclip.</p>
<p><code>myBitmapData.draw(target_mc);</code></p>
<p>We draw the image_mc to the bitmap.</p>
<p><code>reflect_mc._yscale = -100;<br />
reflect_mc._y= target_mc._y+target_mc._height*2+20;<br />
reflect_mc._x = target_mc._x;</code></p>
<p>Then we flip the newly created movieclip and position it below the image_mc.</p>
<p>Still two steps to go, we are almost there.</p>
<div align="center">previous - <a href="http://aswebcreations.com/?p=530">1</a> - <a href="http://aswebcreations.com/?p=533">2</a>  - <a href="http://aswebcreations.com/?p=533">next</a></div>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=530</wfw:commentRss>
		</item>
		<item>
		<title>Easing Explained for AS2 and AS3</title>
		<link>http://aswebcreations.com/?p=226</link>
		<comments>http://aswebcreations.com/?p=226#comments</comments>
		<pubDate>Mon, 25 May 2009 22:21:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=226</guid>
		<description><![CDATA[In this tutorial I will explain how easing works in relationship to the Tween class either in AS3 and AS2 and how you can easily modify existing easing classes to fit your needs or create your own easing methods. To understand this tutorial you should at least know how to use a tween in AS3 [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I will explain how easing works in relationship to the Tween class either in AS3 and AS2 and how you can easily modify existing easing classes to fit your needs or create your own easing methods. To understand this tutorial you should at least know how to use a tween in AS3 or AS2 and have also a basic understanding of classes.<br />
So here is a basic tween (AS3):</p>
<p><code>var Xtween:Tween = new Tween(square,"x",Back.easeIn,square.x,square.x+100,1,true);</code></p>
<p>We create an instance of the Tween class: <code>var Xtween:Tween = new Tween();</code><br />
We pass a reference to an object: <code>var Xtween:Tween = new Tween(square,</code><br />
We tell which property of the object we want to tween: <code>var Xtween:Tween = new Tween(square,"x",</code><br />
We pass an easing function: <code>var Xtween:Tween = new Tween(square,"x",Back.easeIn,</code><br />
We pass a starting value: <code>var Xtween:Tween = new Tween(square,"x",Back.easeIn,square.x,</code><br />
We pass an ending value: <code>var Xtween:Tween = new Tween(square,"x",Back.easeIn,square.x,square.x+100,</code><br />
We pass a duration: <code>var Xtween:Tween = new Tween(square,"x",Back.easeIn,square.x,square.x+100,1,</code><br />
And finaly we tell if the duration will be expressed in seconds or in frames: <code>var Xtween:Tween = new Tween(square,"x",Back.easeIn,square.x,square.x+100,1,true);</code></p>
<p>So already one word about the two last parameters, duration and type (seconds/frames), no matter what you choose, the tween will still use frames as a basis for its calculations. You can check that out easily by setting a frame rate to 1 and then run a Tween using seconds &#8230; not pretty right? So the frame rate matters even if you use seconds.<br />
The Tween takes all the parameters and calculates how many frames it will need to go from the initial value (here square.x) to the final value (square.x+100), it then call the easing function this exact number of frames. So if the tween needs 30 frames to reach the final value, it will call the easing function 30 times. The Tween will call the easing<br />
function with 4 parameters: First: The initial time (starting at zero of course) , second: The initial value of the property being tweened (in our example square.x) , third: The final value needed (100) , fourth: The total duration of the tween. The Tween expects to receive a number from the easing function each time it calls it. Fairly simple, let&#8217;s create our own easing function to see this in action:</p>
<p><code>var Ytween:Tween = new Tween(square,"y",crazyTween,square.y,square.y+100,1,true);<br />
function crazyTween(TimeOrigin:Number,InitialValue:Number,FinalValue:Number,FinalTime:Number):Number{<br />
if(TimeOrigin/FinalTime<1){<br />
return FinalValue+Math.random()*200;<br />
}else{return InitialValue+FinalValue;}<br />
}<br />
</code><br />
That&#8217;s right, we can pass our own easing function as long as we return a number! Try this awesome easing function and see, the tween uses it! If you trace all this you&#8217;ll see that the only value changng from call to call is the first one, the initial time. On a 30 frames tween, the initial time will go from 0 to 30, 30 being the duration time. Now you see why the useless crazyTween function was still able to end up at the right place. Now if we want to apply a linear motion, all we need is to divide the amount needed (in our example 100) by the number of frames needed and add that to the initial value:<br />
<code>var Ytween:Tween = new Tween(square,"y",normalTween,square.y,square.y+100,1,true);<br />
var increase:Number = 100/30;<br />
function normalTween(TimeOrigin:Number,InitialValue:Number,FinalValue:Number,FinalTime:Number):Number{<br />
increase += 100/30;<br />
return InitialValue+increase;<br />
}<br />
</code><br />
A perfect linear tween if you have a framerate of 30, now how do we translate so that no matter the number of frames needed it will always end up right?</p>
<p>Remember, the only value changing in the call to the easing function is the initial time. It&#8217;s gonna start with zero and end up being exactly the duration time so if we divide it by the duration time we get a ratio that we can use to calculate the amount we need to add to the initial value:<br />
TimeOrigin/FinalTime this is our ratio. So FinalValue*(TimeOrigin/FinalTime) will give us the right amount we need to add each time but of course we need to add it to the initial value so the final formula is: InitialValue+FinalValue*(TimeOrigin/FinalTime) let&#8217;s try:</p>
<p><code>var Ytween:Tween = new Tween(square,"y",normalTween,square.y,square.y+100,1,true);<br />
function normalTween(TimeOrigin:Number,InitialValue:Number,FinalValue:Number,FinalTime:Number):Number{<br />
return InitialValue+FinalValue*(TimeOrigin/FinalTime)<br />
}</code></p>
<p>Of course we always think about moving objects with tweens but look at this:</p>
<p><code>var theNumber:Number = 0;<br />
var Ytween:Tween = new Tween(this,"theNumber",normalTween,0,300,1,true);<br />
function normalTween(TimeOrigin:Number,InitialValue:Number,FinalValue:Number,FinalTime:Number):Number{<br />
trace(InitialValue+FinalValue*(TimeOrigin/FinalTime))<br />
return InitialValue+FinalValue*(TimeOrigin/FinalTime)<br />
}<br />
</code><br />
That&#8217;s right, we are tweening a simple variable!</p>
<p>Now before we move deeper into easing functions I want to point out the default easing method that can be found in the tween class. This default easing method is a linear easing exactly like the one we created and the tween class will run it if no easing function is provided so :</p>
<p><code>var Ytween:Tween = new Tween(this,"theNumber",null,0,300,1,true);</code></p>
<p>Will force the tween class to run its internal easing method. Note that this internal easing method is equivalent to the None easing class with AS2 and the Linear easing class with AS3.</p>
<div align="center">previous - <a href="http://aswebcreations.com/?p=226">1</a> - <a href="http://aswebcreations.com/?p=228">2</a>  - <a href="http://aswebcreations.com/?p=228">next</a></div>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=226</wfw:commentRss>
		</item>
		<item>
		<title>GlobalTimer Class</title>
		<link>http://aswebcreations.com/?p=266</link>
		<comments>http://aswebcreations.com/?p=266#comments</comments>
		<pubDate>Thu, 14 May 2009 23:51:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://aswebcreations.com/?p=266</guid>
		<description><![CDATA[



We use the GlobalTimer Class in all our projects. The GlobalTimer Class makes the creation of timers and the registration of functions/methods with the timer very easy. We&#8217;ll show you here some key features.
import GlobalTimer;
var my_timer:GlobalTimer = new GlobalTimer();
my_timer.register(my_function);
function my_function():void{
trace("hello");
}
As soon as you register a function with the GlobalTimer, the GlobalTimer starts (or not if [...]]]></description>
			<content:encoded><![CDATA[<div style="background: url(http://aswebcreations.com/wp-content/themes/pixeled/images/bg-trans.png) repeat;text-margin-left:10px;">
<p style="margin:10px;"><object width="525" height="60" data="download.swf?target=GlobalTimer" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="FlashVars" value="GlobalTimer" /><param name="src" value="download.swf?target=GlobalTimer" /><embed src="download.swf?target=GlobalTimer" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" FlashVars="GlobalTimer" width="525" height="60" wmode="transparent"></embed></object></p>
</div>
<p></p>
<p>We use the GlobalTimer Class in all our projects. The GlobalTimer Class makes the creation of timers and the registration of functions/methods with the timer very easy. We&#8217;ll show you here some key features.</p>
<p><code>import GlobalTimer;<br />
var my_timer:GlobalTimer = new GlobalTimer();<br />
my_timer.register(my_function);<br />
function my_function():void{<br />
trace("hello");<br />
}</code></p>
<p>As soon as you register a function with the GlobalTimer, the GlobalTimer starts (or not if you pass false as argument) with default values (10 milliseconds). You can of course pass other values at instantiation time or by accessing the timer regular properties (Timer class). Unregister the function and the timer stops:</p>
<p><code>my_timer.unregister(my_function);</code></p>
<p>You can register as many function as you want:</p>
<p><code>my_timer.register(my_function);<br />
my_timer.register(my_function2);</code></p>
<p>This will cause the GlobalTimer to run the two functions. By default, passing the same function twice is prevented:</p>
<p><code>my_timer.register(my_function);<br />
my_timer.register(my_function);//no results</code></p>
<p>Unregistering a function will not stop the timer if other functions are still registered. You can of course stop the timer anytime using normal Timer properties and methods (Timer class). There&#8217;s many other useful methods that you can discover on your own. Enjoy and leave us a comment.</p>
<p>Aswebcreations.com team.</p>
]]></content:encoded>
			<wfw:commentRss>http://aswebcreations.com/?feed=rss2&amp;p=266</wfw:commentRss>
		</item>
	</channel>
</rss>
