<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>digitaldogbyte.com &#187; ActionScript</title>
	<atom:link href="http://www.digitaldogbyte.com/tag/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digitaldogbyte.com</link>
	<description>powered by kilobits n' bytes</description>
	<lastBuildDate>Sat, 16 Jul 2011 03:01:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Dynamically attaching library objects in ActionScript 3.0</title>
		<link>http://www.digitaldogbyte.com/2008/07/02/dynamically-attaching-library-objects-in-actionscript-30/</link>
		<comments>http://www.digitaldogbyte.com/2008/07/02/dynamically-attaching-library-objects-in-actionscript-30/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 21:39:47 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[dynamically attach]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=6</guid>
		<description><![CDATA[There are some small differences in syntax when dynamically attaching library objects in ActionScript 2.0 and ActionScript 3.0. In this post, I will provide a very simplified example in both ActionScript 2.0 and ActionScript 3.0. ActionScript 2.0 Example: You will need to make sure the library object that you are trying to attach has been [...]]]></description>
			<content:encoded><![CDATA[<p>There are some small differences in syntax when dynamically attaching library objects in ActionScript 2.0 and ActionScript 3.0.</p>
<p>In this post, I will provide a very simplified example in both ActionScript 2.0 and ActionScript 3.0.</p>
<p><strong>ActionScript 2.0 Example:</strong></p>
<p>You will need to make sure the library object that you are trying to attach has been configured, to do this you need to right click on the object in the library, next select properties and then check the &#8220;Export for ActionScript&#8221; and &#8220;Export in first frame&#8221; options. Make sure to enter an Identifier name for the library object; the Identifier name is used to reference the library object in when you try to use it in the ActionScript code.</p>
<p>In this example we will use &#8220;myClip&#8221; as the Identifier name.</p>
<p><img src="/images/dynamic_attach/as2_export.jpg" /></p>
<p>Below is the ActionScript 2.0 code that will dynamically create 5 instances of the myClip object.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> numberOfClips<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #6699cc; font-weight: bold;">var</span> xStart<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #6699cc; font-weight: bold;">var</span> yStart<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #6699cc; font-weight: bold;">var</span> xVal<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = xStart<span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #6699cc; font-weight: bold;">var</span> xOffset<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">&lt;</span>numberofclips<span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
<span style="color: #000000;">&#123;</span> 
     <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>attachMovie<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;myClip&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;myClip&quot;</span><span style="color: #000066; font-weight: bold;">+</span>i<span style="color: #000066; font-weight: bold;">,</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>getNextHighestDepth<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> 
     <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;myClip&quot;</span><span style="color: #000066; font-weight: bold;">+</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>_y = yStart<span style="color: #000066; font-weight: bold;">;</span> 
     <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;myClip&quot;</span><span style="color: #000066; font-weight: bold;">+</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>_x = xVal<span style="color: #000066; font-weight: bold;">;</span> 
     xVal = <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;myClip&quot;</span><span style="color: #000066; font-weight: bold;">+</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>_x <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;myClip&quot;</span><span style="color: #000066; font-weight: bold;">+</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>_width <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>xOffset<span style="color: #000066; font-weight: bold;">;</span> 
     <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;myClip&quot;</span><span style="color: #000066; font-weight: bold;">+</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>label_txt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = i<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><strong>ActionScript 3.0 Example:</strong></p>
<p>You will need to make sure the library object that you are trying to attach has been configured, to do this you need to right click on the object in the library, next select properties and then check the &#8220;Export for ActionScript&#8221; and &#8220;Export in first frame&#8221; options. Make sure to enter an Class name for the library object; the Class name is used to reference the library object in when you try to use it in the ActionScript code. You don&#8217;t need to worry about the Base class, Flash will set a default Base class.</p>
<p><em>If you are attempting to attach a custom class that you created, you will need to use the Class name of the your custom class; you may also need to set the Base class if your custom class is derived from another custom class that you have created. </em></p>
<p><img src="/images/dynamic_attach/as3_export.jpg" /></p>
<p>When you check the &#8220;Export for ActionScript&#8221; option, you will likely get a warning telling you that there is no class file found; for this basic example you can just click OK.</p>
<p><img src="/images/dynamic_attach/as3_export_class_warning.jpg" /></p>
<p>Below is the ActionScript 3.0 code that will dynamically create 5 instances of the myClip object.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> numberOfClips<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">5</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #6699cc; font-weight: bold;">var</span> xStart<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #6699cc; font-weight: bold;">var</span> yStart<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #6699cc; font-weight: bold;">var</span> xVal<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = xStart<span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #6699cc; font-weight: bold;">var</span> xOffset<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">2</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Number</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">&lt;</span>numberofclips<span style="color: #000066; font-weight: bold;">;</span>i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span> 
<span style="color: #000000;">&#123;</span> 
     <span style="color: #6699cc; font-weight: bold;">var</span> mc<span style="color: #000066; font-weight: bold;">:</span>myClip = <span style="color: #0033ff; font-weight: bold;">new</span> myClip<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> 
     mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span> = <span style="color: #990000;">&quot;myClip&quot;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000;">&#40;</span>i<span style="color: #000066; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> 
     <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span> <span style="color: #000000;">&#40;</span>mc<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> 
     mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = yStart<span style="color: #000066; font-weight: bold;">;</span> 
     mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = xVal<span style="color: #000066; font-weight: bold;">;</span> 
     xVal = mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> mc<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>xOffset<span style="color: #000066; font-weight: bold;">;</span> 
     mc<span style="color: #000066; font-weight: bold;">.</span>label_txt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> 
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Here are the <a href="/downloads/dynamic_attach_example.zip">example source files</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2008/07/02/dynamically-attaching-library-objects-in-actionscript-30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UML &amp; ActionScript 3.0 Code Generation</title>
		<link>http://www.digitaldogbyte.com/2008/02/18/uml-actionscript-30-code-generation/</link>
		<comments>http://www.digitaldogbyte.com/2008/02/18/uml-actionscript-30-code-generation/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 03:34:01 +0000</pubDate>
		<dc:creator>Herm Wong</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[code generation]]></category>
		<category><![CDATA[UML]]></category>

		<guid isPermaLink="false">http://www.digitaldogbyte.com/?p=3</guid>
		<description><![CDATA[I&#8217;m currently architecting an ActionScript 3.0 Framework that will take advantage of OOP principles &#38; a MVC design pattern. In an attempt to automate as much of the work as possible, I started looking for tools that could generate AS3.0 code from UML diagrams. I found an excellent blog post by Sean Moore, with a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently architecting an ActionScript 3.0 Framework that will take advantage of OOP principles &amp; a MVC design pattern.</p>
<p>In an attempt to automate as much of the work as possible, I started looking for tools that could generate AS3.0 code from UML diagrams. I found an excellent <a href="http://seantheflashguy.com/blog/2007/11/20/actionscript-30-uml-and-code-generation-tools/" target="_blank" title="ActionScript 3.0 UML and Code Generation Tools">blog post</a> by Sean Moore, with a listing of several UML diagramming tools with AS3.0 code generation.</p>
<p>I decided to use <a href="http://staruml.sourceforge.net/en/download.php" target="_blank" title="Download StarUML">StarUML</a>, which was mentioned in one of the comments. To enable AS3.0 code generation in StarUML, you will need to <a href="http://www.flashfocus.nl/forum/showthread.php?t=37074" title="Download AS3.zip">download the AS3.zip</a> file &amp; then copy the contents of the AS3.zip file to this directory location C:\Program Files\StarUML\modules\staruml-generator\templates\.</p>
<p>The template.cot file is a JavaScript file that StarUML uses to generate the AS3.0 code. I noticed that the AS3.0 code being generated did not include the package namespace of the parent class or the implemented interfaces, so I modified the template.cot file so that it generates the import statements of the missing namespaces. My colleague also made some revisions to the template.cot file so that it would not include the access control modifiers for the operations created in the interface AS files.</p>
<p>To install the modified template.cot file you can simply overwrite the C:\Program Files\StarUML\modules\staruml-generator\templates\AS3 folder with the contents of this <a href="http://www.digitaldogbyte.com/downloads/AS3.zip" title="Modified AS3.zip">AS3.zip</a> file.</p>
<p>Here are the steps that you&#8217;ll need to follow to generate the AS3.0 code once you have the AS3.zip contents installed.</p>
<p>1. When you start StarUML, it will ask you for the approach you wish to use. Leave it as Default Approach and press OK.</p>
<p><img src="/images/staruml_as3/staruml_as3_01.jpg" /></p>
<p>2. Once you have created your UML diagrams and want to generate the AS3.0 code, go to the Tools menu and select &#8220;StartUML Generator &#8230;&#8221;.</p>
<p><img src="/images/staruml_as3/staruml_as3_02.jpg" /></p>
<p>3. You will be presented with a dialog asking for the template type that StarUML should use for code generation; check the AS3.0 template and click Next.</p>
<p><img src="/images/staruml_as3/staruml_as3_03.jpg" /></p>
<p>4. Select the destination directory that StarUML will place the generated AS3.0 code and then press Next.</p>
<p><img src="/images/staruml_as3/staruml_as3_04.jpg" /></p>
<p>5. Press the Generate button to begin the code generation.</p>
<p><img src="/images/staruml_as3/staruml_as3_05.jpg" /></p>
<p>6. Presto! Code generation complete. Click on Finish and then go to the destination folder that you specified in Step 4 to view your results.</p>
<p><img src="/images/staruml_as3/staruml_as3_06.jpg" /></p>
<p>Here is a <a href="/downloads/staruml_as3_example.zip" title="StarUML Sample Files">sample project</a> that I created that you can use as a starting reference point.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitaldogbyte.com/2008/02/18/uml-actionscript-30-code-generation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

