<?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>ria-coder.com &#187; flash cs4</title>
	<atom:link href="http://ria-coder.com/blog/tag/flash-cs4/feed" rel="self" type="application/rss+xml" />
	<link>http://ria-coder.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 21 Apr 2010 19:35:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Converting GIF to SWF using Flash CS4</title>
		<link>http://ria-coder.com/blog/converting-gif-to-swf-using-flash-cs4</link>
		<comments>http://ria-coder.com/blog/converting-gif-to-swf-using-flash-cs4#comments</comments>
		<pubDate>Wed, 16 Dec 2009 21:34:32 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[flash cs4]]></category>
		<category><![CDATA[gif]]></category>
		<category><![CDATA[swf]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=509</guid>
		<description><![CDATA[A typical ballache... You want to use one of the cool loaders from http://ajaxload.info/ in your Flash/Flex apps, but it only generates a GIF file...]]></description>
			<content:encoded><![CDATA[<p>A typical ballache&#8230; You want to use one of the cool loaders from <a title="AjaxLoad" href="http://ajaxload.info/">http://ajaxload.info/</a> in your Flash/Flex apps, but it only generates a GIF file&#8230; So you&#8217;ll scour the net for a GIF2SWF application and you&#8217;ll undoubtedly come across a few, but you don&#8217;t have to look any further than Flash CS4 &#8211; surprisingly!</p>
<p>All you have to do is open a GIF file in Flash CS4 and it&#8217;ll automatically pull it apart and convert it to frames, which can then be converted to a SWF file <img src='http://ria-coder.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope it helps you at some point!</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/converting-gif-to-swf-using-flash-cs4/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating XML-based menus with Flash CS4 and Flex</title>
		<link>http://ria-coder.com/blog/creating-xml-based-menus-with-flash-cs4-and-flex</link>
		<comments>http://ria-coder.com/blog/creating-xml-based-menus-with-flash-cs4-and-flex#comments</comments>
		<pubDate>Tue, 17 Mar 2009 20:49:56 +0000</pubDate>
		<dc:creator>Danny Kopping</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Lessons]]></category>
		<category><![CDATA[flash cs4]]></category>
		<category><![CDATA[flex component kit]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml menu]]></category>

		<guid isPermaLink="false">http://ria-coder.com/blog/?p=174</guid>
		<description><![CDATA[In this tutorial, i'll be showing you how to use the Flex Component Kit, XML, Flash CS4 and Flex 3 to build an extensible, aesthetically pleasing and interactive menu system.]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, i&#8217;ll be showing you how to use the <em>Flex Component Kit</em>, XML, Flash CS4 and Flex 3 to build an extensible, aesthetically pleasing and interactive menu system. Each ingredient in this tutorial is of equal important (with the exception of XML which can easily be replaced with JSON, CSV, etc).</p>
<p>First, a preview of what i will be covering in this tutorial:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_menu_251353970"
			class="flashmovie"
			width="300"
			height="400">
	<param name="movie" value="http://ria-coder.com/temp/wp-content/uploads/2009/03/menu.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://ria-coder.com/temp/wp-content/uploads/2009/03/menu.swf"
			name="fm_menu_251353970"
			width="300"
			height="400">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>In the SWF file above, an XML file is being processed and <em>x</em> amount of menu items are being created at runtime according to the XML specification of the menu. In the SWF above, i&#8217;m using the following XML file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;menu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;The Dark Side Of The Moon&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Wish You Were Here&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Delicate Sound Of Thunder&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;The Division Bell&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Pulse&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/menu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Click <a title="Project Files" href="http://ria-coder.com/blog/wp-content/uploads/2009/03/xml-menu.zip" target="_blank">here</a> to download the exercise files for this tutorial.<br />
You will also need to download and install the <strong><em>Flex Component Kit</em></strong><em> </em>from <a title="Flex Component Kit" href="https://www.adobe.com/cfusion/entitlement/index.cfm?e=flex_skins" target="_blank">here</a>.</p>
<p>Alright, so let&#8217;s dive right in.</p>
<p>So what are we exactly trying to achieve here? We&#8217;re trying to:</p>
<ol>
<li>take a symbol that we have created in Flash CS4 and export it</li>
<li>import the symbol into Flex</li>
<li>create an XML-based menu with instances of the symbol</li>
</ol>
<h3>Step 1</h3>
<p>Open the <em>flash </em>folder in the exercise files and open the <strong>MenuItem.fla</strong> file inside of Flash CS4. (Note: There is nothing Flash CS4-specific in this file, so if you&#8217;d like a version of the FLA that&#8217;ll work with CS3, pop me an email)</p>
<p>On the stage you will find one symbol &#8211; the <strong>MenuItem</strong> symbol. In the Library, there is a <strong>MenuItem</strong> symbol that has been exported for Flex, the <strong>FlexComponentBase</strong> and two other symbols that are used inside the <strong>MenuItem</strong> symbol.<a href="http://ria-coder.com/temp/wp-content/uploads/2009/03/flex-component.png"><img class="size-medium wp-image-190 alignright" title="flex-component" src="http://ria-coder.com/blog/wp-content/uploads/2009/03/flex-component-300x180.png" alt="flex-component" width="300" height="180" /></a></p>
<p>All that the <strong>MenuItem</strong> symbol is is a MovieClip with a little animation, a little masking, a dynamic text field and a background MovieClip. The reason why i made the background its own symbol is because you may want to do a color transform tween or something once you roll over the <strong>MenuItem</strong> symbol. I have not done this in the tutorial, but nonetheless &#8211; give it a go if you feel the need.</p>
<p>Once you have installed the <em>Flex Component Kit</em>, you will see that two new items are available in the <strong>Commands</strong> menu: <em>Convert Symbol to Flex Component </em>and <em>Convert Symbol to Flex Container</em>. Once you have created a symbol inside of Flash, you will select it and select the <em>Convert Symbol to Flex Component</em> from the <strong>Commands</strong> menu. This will do all the heavy lifting that is required to make it compatible with Flex.</p>
<p>There are a couple of things to note before you export the symbol:</p>
<p>Firstly, you will need to export your symbol for ActionScript by right-clicking the symbol in the library and selecting <strong>Properties</strong>. Check the box next to <em>Export for ActionScript</em>. Next, choose a name for your symbol to be used in Flex. I have chosen <strong>MenuItem</strong> as the <em>Class</em>, and i have chosen <strong>MenuItemClass</strong> as the <em>Base</em> <em>Class</em>.</p>
<p><a href="http://ria-coder.com/temp/wp-content/uploads/2009/03/document-class.png"><img class="size-medium wp-image-186 alignleft" style="margin: 5px;" title="document-class" src="http://ria-coder.com/blog/wp-content/uploads/2009/03/document-class-228x300.png" alt="document-class" width="228" height="300" /></a>I will be coming back to this in a moment. For the moment, you can set the <em>Base Class</em> value to <strong>mx.flash.UIMovieClip</strong> &#8211; this class is a modified implementation of the usual <strong>MovieClip</strong> class you use in Flash, and will make your symbol compatible with Flex. Now select the <em>Convert Symbol to Flex Component </em>option from the <strong>Commands </strong>menu.</p>
<h3>Step 2</h3>
<p>Now we&#8217;re going to import the newly prepared Flash symbol for Flex. Flex makes use of <strong>.SWC </strong>files when importing external libraries, so we&#8217;re going to export our Flash symbol to a <strong>.SWC</strong> file. We do this by publishing the FLA. Go over to Flash and hit <strong>Shift+F12</strong>, or select <strong>Publish </strong>from File-&gt;Publish. This will export our symbol as a SWC file, as well as a SWF file. We will not be using the SWF file.</p>
<p>Now, go over to Flex and import the project in the exercise files. Go to File-&gt;Import-&gt;Flex Project, and navigate to the path where you exported the exercise files.</p>
<p style="text-align: center;"><a href="http://ria-coder.com/temp/wp-content/uploads/2009/03/create-project.png"><img class="size-medium wp-image-185 aligncenter" title="create-project" src="http://ria-coder.com/blog/wp-content/uploads/2009/03/create-project-300x259.png" alt="create-project" width="300" height="259" /></a></p>
<p>Create the Flex project and then go to the <strong>Project</strong> menu, and select <strong>Properties</strong>. Find the <strong>Flex Build Path</strong> option and select the <strong>Library Path</strong> tab. In this tab, click on the <strong>Add SWC</strong> button. Navigate to the <em>flash</em> folder in the project and find the SWC file you have recently published.</p>
<p><a href="http://ria-coder.com/temp/wp-content/uploads/2009/03/build-path.png"><img class="aligncenter size-medium wp-image-189" title="build-path" src="http://ria-coder.com/blog/wp-content/uploads/2009/03/build-path-284x300.png" alt="build-path" width="284" height="300" /></a></p>
<p>Now you&#8217;re ready to use your symbol inside of Flex! Remember the name of the class you specified in your symbol linkage in Flash? I used <strong>MenuItem</strong>. Go over to your main application file in Flex, open a new MXML tag and start typing <strong>MenuItem</strong>. You will see that Flex picks up your Flash symbol in the MXML declaration. Now we&#8217;re ready for some real action.</p>
<h3>Step 3</h3>
<p>As you can see from my Flex example, i am loading in an XML file called <strong>structure.xml</strong>. This XML file contains a very basic structure &#8211; it&#8217;s merely 5 items, each with <em>label</em> attributes &#8211; and all relating to one of the greatest bands i&#8217;ve had the pleasure of listening to&#8230; <strong>Pink Floyd <img src='http://ria-coder.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </strong></p>
<p>If you open up the <em>flash </em>folder of the project, you will find a <strong>MenuItemClass.as</strong> file. This will act as the base class for your Flash symbol. Go back to Flash CS4, right click on your symbol in the library and click <strong>Properties</strong>. Now set the <em>Base Class</em> value to <strong>MenuItemClass.as</strong>. Here&#8217;s an explanation of the <strong>MenuItemClass.as </strong>file:</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
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>flash<span style="color: #000066; font-weight: bold;">.</span>UIMovieClip<span style="color: #000066; font-weight: bold;">;</span>	<span style="color: #009900; font-style: italic;">// UIMovieClip extends the functionality of the standard flash.display.MovieClip class, so you can use play(), gotoAndStop(), etc to control your Flash symbol's timeline like you normally would in Flash</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MenuItemClass <span style="color: #0033ff; font-weight: bold;">extends</span> UIMovieClip
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MenuItemClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>		<span style="color: #009900; font-style: italic;">// Inheret the super-class' properties and functions</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">// Setter function for the label dynamic textfield</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">set</span> label<span style="color: #000000;">&#40;</span>label<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			textField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = label<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">// Getter function for the label dynamic textfield</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> label<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> textField<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Once you have changed your Flash symbol in Flash CS4, remember to re-publish it so that the SWC will be updated in Flex.</p>
<p>Here&#8217;s an explanation of the logic in the <strong>Menu.mxml</strong> file:</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: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> items<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XMLList</span> = menuXML<span style="color: #000066; font-weight: bold;">..</span>item<span style="color: #000066; font-weight: bold;">;</span>		<span style="color: #009900; font-style: italic;">// Search for all items in the XML</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> item<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> <span style="color: #0033ff; font-weight: bold;">in</span> items<span style="color: #000000;">&#41;</span>		<span style="color: #009900; font-style: italic;">// Loop through all items</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> menuItem<span style="color: #000066; font-weight: bold;">:</span>MenuItem = <span style="color: #0033ff; font-weight: bold;">new</span> MenuItem<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>	<span style="color: #009900; font-style: italic;">// Create new instance of the Flash symbol we imported</span>
		menuItem<span style="color: #000066; font-weight: bold;">.</span>label = item<span style="color: #000066; font-weight: bold;">.</span>@label<span style="color: #000066; font-weight: bold;">;</span>		<span style="color: #009900; font-style: italic;">// Set the text property of the dynamic text field to the label of the current item in the XML</span>
		menuItem<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span> = <span style="color: #000000; font-weight:bold;">45</span><span style="color: #000066; font-weight: bold;">;</span>
		menuItem<span style="color: #000066; font-weight: bold;">.</span>xml = item<span style="color: #000066; font-weight: bold;">;</span>		<span style="color: #009900; font-style: italic;">// Add the XML of the current item to the xml property of the menuItem variable. Note: this can be named anything since MenuItem's superclass is UIMovieClip which is a dynamic class. You could use menuItem.myBigToe = item if you liked</span>
		<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>menuItem<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>		<span style="color: #009900; font-style: italic;">// Add the item to the stage</span>
&nbsp;
		menuItem<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span> showDetails<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And that&#8217;s it! That&#8217;s how you can use Flash symbols inside of Flex.</p>
]]></content:encoded>
			<wfw:commentRss>http://ria-coder.com/blog/creating-xml-based-menus-with-flash-cs4-and-flex/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

