<?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>Hemanth Sharma - Tech Blog &#187; Action Script 3.0</title>
	<atom:link href="http://www.hsharma.com/tech/category/action-script-3-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hsharma.com/tech</link>
	<description></description>
	<lastBuildDate>Fri, 23 Jul 2010 13:44:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Multiscreen Game/App &#8211; Part 2: Understanding</title>
		<link>http://www.hsharma.com/tech/articles/multiscreen-gameapp-part-2-understanding/</link>
		<comments>http://www.hsharma.com/tech/articles/multiscreen-gameapp-part-2-understanding/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 11:10:52 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Professional]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[builder]]></category>
		<category><![CDATA[multi]]></category>
		<category><![CDATA[multiscreen]]></category>
		<category><![CDATA[professional]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=1392</guid>
		<description><![CDATA[Setting Up
Please refer to my previous post on how to extract the provided files, setting them up in Flash Professional and Flash Builder. Once you are done setting up, you may proceed reading this article to understand the code constructs.
Prerequisites

You need to have Adobe Flash Professional CS5 installed.
You need to have Adobe Flash Builder 4 [...]]]></description>
			<content:encoded><![CDATA[<h3>Setting Up</h3>
<p>Please refer to my <a href="http://www.hsharma.com/tech/articles/multiscreen-gameapp-part-1-setting-up/" rel='nofollow'><strong>previous post</strong></a> on how to extract the provided files, setting them up in Flash Professional and Flash Builder. Once you are done setting up, you may proceed reading this article to understand the code constructs.</p>
<h3>Prerequisites</h3>
<ul>
<li>You need to have Adobe Flash Professional CS5 installed.</li>
<li>You need to have Adobe Flash Builder 4 installed.</li>
<li>You need the application files (.fla and .as) that I have shared  below.</li>
</ul>
<h3>Download</h3>
<p style="text-align: center;"><a href="http://www.hsharma.com/tech/downloads/MultiscrTemplate.zip" target="_blank" rel='nofollow'><img title="Multiscreen Template" src="http://www.hsharma.com/tech/examples/download_btns/multiscrTemplate.jpg" alt="Multiscreen Template" width="180" height="40" /></a><br />
(42 downloads)</p>
<h3><span id="more-1392"></span>Preview</h3>
<p>This is how your app will behave in multiple screens (only visually).  I will also go through how you can manage to detect the type of  controls/player for handling input events. For a detailed post on how it  behaves on multiscreen, visit my blog post &#8211; <a title="One Code, Multi  Screen" href="http://bit.ly/onecode" target="_blank" rel='nofollow'><strong>One Code, Multiscreen</strong></a>.</p>
<p style="text-align: center;"><strong>Portrait  Version</strong></p>
<p style="text-align: center;"><img title="Portrait Version" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_portrait.jpg" alt="Portrait Version" width="240" height="339" /></p>
<p style="text-align: center;"><strong>Landscape  Version</strong></p>
<p style="text-align: center;"><img title="Landscape Version" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_landscape.jpg" alt="Landscape Version" width="370" height="179" /></p>
<p><a name="logic"></a></p>
<h3>Application Logic &#8211; Logic.as</h3>
<p>The game&#8217;s logic is written in <strong>Template.Logic</strong> class. This is how it   looks: -</p>
<pre class="brush: as3; wrap-lines: false">package Template {
	import com.hsharma.Game;

	import flash.display.MovieClip;

	public class Logic extends MovieClip {
		private var game:Game;

		public function Logic() {
			super();

			game = new Game(this, Canvas, Title, LevelNum, MainMenu, Controls);
		}

		public function initGame():void {
			// GAME CODE

		}
	}
}
</pre>
<p>As you can see, it is just a simple class that has a constructor instantiating a new object of type <strong><code>Game</code></strong>. Will come to that later. It later has a function <strong><code>initGame()</code></strong> that is supposed to contain the game&#8217;s logic and behavior.<br />
<a name="game"></a></p>
<h3>Generic Multiscreen Layout &#8211; Game.as</h3>
<p>Let&#8217;s look at the class <strong><code>com.hsharma.Game</code></strong> before we run through the parts of <strong>Logic.as</strong> that we missed.</p>
<pre class="brush: as3; highlight: [69, 73]">package com.hsharma {
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Point;

	public class Game extends MovieClip {
		private var _gameClass:*;
		private var _stage:Stage;
		private var _canvas:MovieClip;
		private var _title:MovieClip;
		private var _module_1:MovieClip;
		private var _module_2:MovieClip;
		private var _menu:MovieClip;

		private var title_ratio:Point;
		private var mainmenu_ratio:Point;
		private var module_ratio:Point;
		private var screen:String;

		public function Game(myClass:*, myCanvas:MovieClip, myTitle:MovieClip, myMenu:MovieClip, Module1:MovieClip, Module2:MovieClip) {
			super();

			_gameClass = myClass;
			_stage = myClass.stage;
			_canvas = myCanvas;
			_title = myTitle;
			_module_1 = Module1;
			_module_2 = Module2;
			_menu = myMenu;

			_stage.align = StageAlign.TOP_LEFT;
			_stage.scaleMode = StageScaleMode.NO_SCALE;

			title_ratio = new Point(_title.width, _title.height);
			mainmenu_ratio = new Point(_menu.width, _menu.height);
			module_ratio = new Point(_module_1.width, _module_1.height);

			resizeGame(null);
			_stage.addEventListener(Event.RESIZE, resizeGame);

			showSplash();
		}

		private function showSplash():void {
			screen = "splash";
			_title.visible = false;
			_menu.visible = false;
			_module_1.visible = false;
			_module_2.visible = false;

			_canvas.setChildIndex(_canvas.Splash, _canvas.numChildren-1);

			// SETUP GREENSOCK TWEENLITE CLASS AND USE THE BELOW LINE TO FADE IN THE SPLASH SCREEN AFTER 3 SECONDS DELAY
			// TweenLite.to(_canvas.Splash, 1, {delay: 3, alpha: 0, onStart:initGame, onComplete:hideSplash});

			initGame();
			hideSplash();
		}

		private function hideSplash():void {
			// UNCOMMENT THE BELOW LINE ONCE YOU HAVE THE FADE IN ENABLED FOR SPLASH SCREEN
			// _canvas.Splash.visible = false;
		}

		private function resizeGame(event:Event):void {
			// INTELLIGENT LAYOUT LOGIC GOES HERE
		}

		private function initGame():void {
			// RESET VISIBILITY OF VISUAL ELEMENTS

			screen = "game";
			_gameClass.initGame();
		}
	}
}
</pre>
<p>In the above code, lines 69 and 73 are bunches of lines of code that I have specifically removed for now to reduce confusion. We shall also look into that later.</p>
<h3>Passing Game&#8217;s Visual Elements to the Generic Layout Class</h3>
<p>Now, look at the 2 important lines in <a href="#logic" rel='nofollow'><strong>Logic.as</strong></a> -</p>
<pre class="brush: as3; first-line: 2">import com.hsharma.Game;</pre>
<pre class="brush: as3; first-line: 12">game = new Game(this, Canvas, Title, LevelNum, MainMenu, Controls);
</pre>
<p>I have imported the generic <a href="#game" rel='nofollow' rel='nofollow' rel='nofollow'><strong><code>Game</code></strong></a> class and instantiated an object <strong><code>game</code></strong> passing some objects to the constructor of the <strong><code>Game</code></strong> class. First object that I pass is the class reference to <a href="#logic" rel='nofollow' rel='nofollow'><strong><code>Template.Logic</code></strong></a> (<strong>Logic</strong> class of any game that I write) &#8211; <strong><code>this</code></strong>. The other objects that I pass are the visual elements (MovieClips) that are explained in the Part 1 of this tutorial, namely: -</p>
<ul>
<li><strong>Canvas</strong> &#8211; (Center) This is a <strong>MovieClip</strong> &#8220;<strong>Canvas</strong>&#8221;   that I use to put in all the elements that my game or app requires to   have.</li>
<li><strong>Title</strong> &#8211; (Left Top) This is a <strong>MovieClip</strong> &#8220;<strong>Title</strong>&#8221;   that will contain my app/game&#8217;s logo/icon with the title text if   required.</li>
<li><strong>LevelNum</strong> &#8211; (Right Top) This is a <strong>MovieClip</strong> &#8220;<strong>LevelNum</strong>&#8221; that will depict the  current level of the game.</li>
<li><strong>MainMenu</strong> &#8211; (Left Bottom) This is a small <strong>MovieClip</strong> &#8220;<strong>MainMenu</strong>&#8221; consisting of 4 <strong>Buttons</strong> (Restart Level,  Help/Instructions, Close/Exit and About).</li>
<li><strong>Controls </strong>- (Right Bottom) This is a <strong>MovieClip</strong> &#8220;<strong>Controls</strong>&#8221; that contains the Up and Down arrow buttons used to control the game&#8217;s behavior (rather, play the game).</li>
</ul>
<p>This step is to make sure my generic <strong><code>Game</code></strong> class knows the visual elements of the game that I am writing, so it can arrange them according to any screen size. Important point to note is, any game that I write, ideally will be a replica of <a href="#logic" rel='nofollow' rel='nofollow'><strong><code>Template.Logic</code></strong></a> class. It might be <strong><code>CrazyGems.Logic</code></strong> class that will contain the game behavior of Crazy Gems. This class also will instantiate the <a href="#game" rel='nofollow' rel='nofollow' rel='nofollow'><strong><code>com.hsharma.Game</code></strong></a> class object in its constructor, so the class <a href="#game" rel='nofollow' rel='nofollow' rel='nofollow'><strong><code>com.hsharma.Game</code></strong></a> knows the visual elements of the game Crazy Gems and handles the layout.</p>
<h3>Multiple Projects using Game Class</h3>
<p>With a little bit of tweaking of Project properties in Flash Builder, we can setup more than one <strong>.fla</strong> (more than one game) use the same <a href="#game" rel='nofollow' rel='nofollow' rel='nofollow'><strong><code>com.hsharma.Game</code></strong></a> class for the layout handling, so I don&#8217;t need to rewrite the multiscreen layout logic separately for each game.</p>
<p>Here is a typical structure of 3 example games that use the same class <strong><code>com.hsharma.Game</code></strong> for laying out the visuals for multiscreen.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1408" title="Multiple Projects Using MultiscrTemplate" src="http://www.hsharma.com/tech/wp-content/uploads/2010/07/multiscreen_template_007.jpg" alt="Multiple Projects Using MultiscrTemplate" width="228" height="549" /></p>
<p>Observe the color coding in the image above. <span style="color: #0000ff;"><strong>Blue</strong></span> files represent the Logic and UI (.fla) for the game <strong>Crazy Gems</strong>. <span style="color: #008000;"><strong>Green</strong></span> files represent Logic, UI (.fla) and other game-specific classes for the game <strong>Crazy Maze</strong>. <span style="color: #ff9900;"><strong>Wheat/Cream</strong></span> colored files represent the <strong>Template</strong> files that I have shared with this article and their UI (.fla).</p>
<p>Finally, the <span style="color: #ff0000;"><strong>Red</strong></span> files represent the <strong><code>com.hsharma.Game</code></strong> class and also the <strong><code>greensock</code></strong> package used for tweening. These two packages/classes are used across in all 3 games to avoid duplicates of code. So, I fix one bug in the multiscreen layout class <strong><code>com.hsharma.Game</code></strong>, it gets fixed for all the games referring to them.</p>
<h3>Multiscreen Layout</h3>
<p>Now that we pass the visual elements of our games/apps to the generic <a href="#game" rel='nofollow' rel='nofollow' rel='nofollow'><strong><code>Game</code></strong></a> class, as you might have seen the output, the commented line 69 in the above code, function <strong><code>resizeGame()</code></strong>, actually has these lines of code shown below (again, minimal code shown). Rest of the code exists in the actual file shared with this article.</p>
<pre class="brush: as3; wrap-lines: false; highlight: [2, 18];">if (_stage.stageWidth &gt; _stage.stageHeight) {
	// RESIZE ALL ELEMENTS (CODE NOT SHOWN HERE)

	if (_canvas.x &lt; 50) {
		_title.visible = false;
		_menu.visible = false;
		_module_1.visible = false;
		_module_2.visible = false;
	} else {
		if (screen != "splash") {
			_title.visible = true;
			_menu.visible = true;
			_module_1.visible = true;
			_module_2.visible = true;
		}
	}
} else {
	// RESIZE ALL ELEMENTS (CODE NOT SHOWN HERE)

	if (_canvas.y &lt; 50) {
		_title.visible = false;
		_menu.visible = false;
		_module_1.visible = false;
		_module_2.visible = false;
	} else {
		if (screen != "splash") {
			_title.visible = true;
			_menu.visible = true;
			_module_1.visible = true;
			_module_2.visible = true;
		}
	}
}
</pre>
<p>In the above code, line 2 and 18 are places where I have mimicked the <strong>Constraint Based Layouts</strong> available in the Flex framework. In the <a href="#game" rel='nofollow' rel='nofollow' rel='nofollow'><strong><code>Game</code></strong></a> class above, you can observe the lines 41 &amp; 42.</p>
<pre class="brush: as3; first-line: 41;">resizeGame(null);
_stage.addEventListener(Event.RESIZE, resizeGame);
</pre>
<p>This is where I call the function <strong><code>resizeGame()</code></strong>. As the screen is re-sized, during the game play, this function re-sizes and lays out the visual elements according to the screen. That&#8217;s all there is to it.</p>
<h3>Device Capabilities</h3>
<p>For the most part, games rely on some important device capabilities, like the input methods.</p>
<p>It is always a good idea to look for support of a specific support (e.g., Accelerometer) and then initiate the objects relating to that. Example below: -</p>
<pre class="brush: as3">import flash.sensors.Accelerometer;
if (Accelerometer.isSupported) {
	var acc_obj:Accelerometer = new Accelerometer();
} else {
	stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
}
</pre>
<p>One more tip on determining if the game is being played from the browser or as a desktop AIR app is shown below: -</p>
<pre class="brush: as3">import flash.system.Capabilities;
if (Capabilities.playerType == "Desktop") {
	// PLAYED ON THE DESKTOP
} else {
	// PLAYED ON THE WEB BROWSER
}
</pre>
<h3>Minimum Size Constraint</h3>
<p>When running the game/app on the desktop as a standalone app, the user might resize the window way less than recommended. To avoid this, we need to constrain the minimum allowed size of the app window.</p>
<ul>
<li>To do this, change the Publish Settings in your Flash Professional CS5 to player &#8211; <strong>Adobe AIR 2</strong>.</li>
<li>Click on the &#8220;<strong>Settings</strong>&#8221; button beside <strong>Adobe AIR 2</strong>.</li>
<li>Application &amp; Installer Settings open up. Here, choose the <strong>Advanced</strong> tab.</li>
<li>Specify the <strong>Minimum Width</strong> and <strong>Minimum Height</strong> properties so the user is restricted from resizing below the values specified.</li>
</ul>
<h3>Conclusion</h3>
<p>Do note that this is just one method of coding a multiscreen application. There are several methods out there. Please feel free to experiment. I shall also try and write more about other methods. Also, feel free to change the code that I shared to your convenience and improvise if necessary. The intention of this article is to form awareness of the ability to create multiscreen applications in ActionScript easily. Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/articles/multiscreen-gameapp-part-2-understanding/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multiscreen Game/App &#8211; Part 1: Setting Up</title>
		<link>http://www.hsharma.com/tech/articles/multiscreen-gameapp-part-1-setting-up/</link>
		<comments>http://www.hsharma.com/tech/articles/multiscreen-gameapp-part-1-setting-up/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 11:07:03 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[builder]]></category>
		<category><![CDATA[multi]]></category>
		<category><![CDATA[multiscreen]]></category>
		<category><![CDATA[professional]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=1362</guid>
		<description><![CDATA[Introduction
With my recent creation of multiscreen game (Crazy  Gems) in mind, I am presenting a basic template I created in Flash Professional for use in the games or apps you might be trying to create. The method that I am following is obviously not the only method you need to follow. This comes with my [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>With my recent creation of multiscreen game (<a href="../adobe/one-code-multi-screen/" target="_blank" rel='nofollow'>Crazy  Gems</a>) in mind, I am presenting a basic template I created in Flash Professional for use in the games or apps you might be trying to create. The method that I am following is obviously not the only method you need to follow. This comes with my experience and hard learning over time.</p>
<p>I will be using Adobe Flash Professional CS5 for the UI creation and later, Adobe Flash Builder for writing code and debugging. This article will first guide you to setup the provided Template files to give a fair idea of the implementation.</p>
<h3>Prerequisites</h3>
<ul>
<li>You need to have Adobe Flash Professional CS5 installed.</li>
<li>You need to have Adobe Flash Builder 4 installed.</li>
<li>You need the application files (.fla and .as) that I have shared below.</li>
</ul>
<h3>Download</h3>
<p style="text-align: center;"><a href="http://www.hsharma.com/tech/downloads/MultiscrTemplate.zip" target="_blank" rel='nofollow'><img class="alignnone" title="Multiscreen Template" src="http://www.hsharma.com/tech/examples/download_btns/multiscrTemplate.jpg" alt="Multiscreen Template" width="180" height="40" /></a><br />
(42 downloads)</p>
<h3><span id="more-1362"></span>Preview</h3>
<p>This is how your app will behave in multiple screens (only visually). I will also go through how you can manage to detect the type of controls/player for handling input events. For a detailed post on how it behaves on multiscreen, visit my blog post &#8211; <a title="One Code, Multi Screen" href="http://bit.ly/onecode" target="_blank" rel='nofollow'><strong>One Code, Multiscreen</strong></a>.</p>
<p style="text-align: center;"><strong>Portrait Version</strong></p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1369" title="Portrait Version" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_portrait.jpg" alt="Portrait Version" width="240" height="339" /></p>
<p style="text-align: center;"><strong>Landscape Version</strong></p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1370" title="Landscape Version" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_landscape.jpg" alt="Landscape Version" width="370" height="179" /></p>
<h3>Setting Up</h3>
<p>Once you have the required files extracted to a folder on your hard drive, make sure your folder structure matches the below one: -</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1366" title="Multiscreen Template Folder Structure" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_template_000.jpg" alt="Multiscreen Template Folder Structure" width="486" height="232" /></p>
<p>Let me explain the folder structure. The main UI file that contains all the images, graphics of my app/game and is supposed to contain all the sound/video/other assets is the <strong>.fla file</strong>.</p>
<p>The folder <strong>Template</strong> contains a <strong>Logic.as file</strong> that is my application&#8217;s class file (<strong>Document Class</strong>).</p>
<p>The <strong>com</strong> folder additionally contains 2 folders among which one (<strong>hsharma</strong>) is the one that contains the logic for multiscreen layout.</p>
<p>You should also see an empty folder called <strong><code>greensock</code></strong>. This is just an indication that you can dump other third party class files or packages here and use it in this template.</p>
<p>As explained before, we will have all our compile time assets inside the .fla and write the actionscript separately in the .as files.</p>
<h3>The .FLA File</h3>
<p>Go ahead and open the Template.fla file in Flash Professional. You should see a similar screen as shown below: -</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1367" title="Multiscreen Template FLA File" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_template_001.jpg" alt="Multiscreen Template Folder Structure" width="412" height="450" /></p>
<p>This image doesn&#8217;t depict the visuals in their actual dimensions; I have zoomed out to fit the screen. As you notice, here are the layers -</p>
<ul>
<li><strong>LevelNum</strong> &#8211; (Right Top) This layer contains a <strong>MovieClip</strong> &#8220;<strong>LevelNum</strong>&#8221; that has a gray rounded rectangle, with a static text &#8220;LEVEL&#8221; and a dynamic text that contains &#8220;00&#8243;. This will depict the current level of the game.</li>
<li><strong>Title</strong> &#8211; (Left Top) This layer contains a <strong>MovieClip</strong> &#8220;<strong>Title</strong>&#8221; that will contain my app/game&#8217;s logo/icon with the title text if required.</li>
<li><strong>MainMenu</strong> &#8211; (Left Bottom) This layer contains a small <strong>MovieClip</strong> &#8220;<strong>MainMenu</strong>&#8221; consisting of 4 <strong>Buttons</strong> (Restart Level, Help/Instructions, Close/Exit and About).</li>
<li><strong>Canvas</strong> &#8211; (Center) This is a <strong>MovieClip</strong> &#8220;<strong>Canvas</strong>&#8221; that I use to put in all the elements that my game or app requires to have. This makes it easy for me to control the main logic or behavior of my game. The blue rectangle that you see in the image above depicts the selected MovieClip &#8220;Canvas&#8221;. I also have placed another <strong>MovieClip</strong> &#8220;<strong>Controls</strong>&#8221; in the same layer (Right Bottom) that are the game controls (Up and Down arrow Buttons).</li>
</ul>
<h3>Using the Template</h3>
<p>I shall now explain a little more as to how you can use these project files and make the best use of it.</p>
<p>In the Properties panel of your .fla file, when no object is selected on stage, you should see a text field which accepts a <strong>Document Class</strong> name (as shown below). This is where I enter the package name and the class name. In this case, <strong><code>Template.Logic</code></strong>.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1381" title="Edit Document Class" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_template_003.jpg" alt="Edit Document Class" width="393" height="275" /></p>
<p>Clicking on the button beside the text field to open/edit the class  file, triggers a new panel that asks you for your choice of AS editor.  Choose <strong>Flash Builder</strong>.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1383" title="Choose AS Editor" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_template_004.jpg" alt="Choose AS Editor" width="440" height="141" /></p>
<p>Flash Builder should automatically open up and it now tries to create a new Project for the .fla file (Flash Project). You should see a new pop up in Flash Builder as shown below: -</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1382" title="New Flash Builder Project" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_template_005.jpg" alt="New Flash Builder Project" width="493" height="400" /></p>
<p>You may let the folder locations be default. In this case, the .fla remains in the folder where you extracted it. A new Flex Project and a folder will be created in your default Flash Builder Projects folder. Once finished, this is how your Flash Builder project structure should look like: -</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1384" title="Flash Builder Project Structure" src="http://www.hsharma.com/tech/wp-content/uploads/2010/06/multiscreen_template_006.jpg" alt="Flash Builder Project Structure" width="197" height="264" /></p>
<p>By default, Flash Builder generates a document class with the same name as the .fla file. In this example, it creates <span style="text-decoration: underline;"><strong>Template.as</strong></span> in the default package. You can go ahead and <strong>delete</strong> that since we are writing the code in the <strong>Template/Logic.as</strong> class.</p>
<h3>Conclusion</h3>
<p>You are now ready to start coding your game/app. You may test and run the swf by pressing Command+Enter (Mac) or Control+Enter (Win). You should see that the UI fits any screen orientation as you drag. I shall explain the specific code for resizing in the next part of this article. Hope you found this article helpful.</p>
<p style="text-align: right;"><a href="http://www.hsharma.com/tech/articles/multiscreen-gameapp-part-2-understanding/" rel='nofollow'><span style="color: #990000;"><strong>Part 2: Understanding Code &#8211; Coming soon&#8230;</strong></span></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/articles/multiscreen-gameapp-part-1-setting-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Source: One Code, Multi-Screen</title>
		<link>http://www.hsharma.com/tech/articles/source-one-code-multi-screen/</link>
		<comments>http://www.hsharma.com/tech/articles/source-one-code-multi-screen/#comments</comments>
		<pubDate>Tue, 04 May 2010 08:58:06 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Player]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[10.1]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[builder]]></category>
		<category><![CDATA[multiscreen]]></category>
		<category><![CDATA[platform]]></category>
		<category><![CDATA[Player]]></category>
		<category><![CDATA[professional]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=1260</guid>
		<description><![CDATA[Find below the source code of the game that I developed for my previous example, One Code, Multiple Screens.
Prerequisites

This requires Adobe Flash Professional CS5 and I haven&#8217;t planned on posting CS4 version as it needs compatibility  to Flash Player 10.1 and uses Accelerometer API that is currently  available only in CS5.
I have used [...]]]></description>
			<content:encoded><![CDATA[<p>Find below the source code of the game that I developed for my previous example, <a href="http://www.hsharma.com/tech/adobe/one-code-multi-screen/" target="_blank" rel='nofollow' rel='nofollow'><strong>One Code, Multiple Screens</strong rel='nofollow'></a>.</p>
<h3>Prerequisites</h3>
<ul>
<li>This requires <strong><a href="http://www.adobe.com/products/flash/" target="_blank" rel='nofollow'>Adobe Flash Professional CS5</a></strong> and I haven&#8217;t planned on posting CS4 version as it needs compatibility  to Flash Player 10.1 and uses Accelerometer API that is currently  available only in CS5.</li>
<li>I have used <a href="http://www.greensock.com/tweenlite/" target="_blank" rel='nofollow'>TweenLite</a> AS3 from <a href="http://www.greensock.com" target="_blank" rel='nofollow'>GreenSock</a> for some animations. I haven&#8217;t distributed it with the source files, so you might have to download your own license from <a href="http://www.greensock.com/tweenlite/" target="_blank" rel='nofollow'>www.greensock.com</a>.</li>
<li>I have not shared the font I used for original game. I have used Arial in this project instead.</li>
<li>If you haven&#8217;t followed my previous demo that showcases this game working on many different devices, please visit the post, <a href="../adobe/one-code-multi-screen/" target="_blank" rel='nofollow' rel='nofollow'><strong>One Code, Multiple Screens</strong rel='nofollow'></a>.</li>
</ul>
<h3>Download</h3>
<p style="text-align: center;"><a href="http://www.hsharma.com/tech/downloads/crazygems2_src.zip" target="_blank" rel='nofollow'><img class="alignnone size-full wp-image-1271" title="Download Source Archive" src="http://www.hsharma.com/tech/examples/download_btns/crazygemssrc.jpg" alt="Download Source Archive" / rel='nofollow'></a><br />
(76 downloads)</p>
<p style="text-align: center;"><a href="http://www.hsharma.com/tech/downloads/CrazyGems2_Src" target="_blank" rel='nofollow'></a></p>
<p><span id="more-1260"></span><br />
Once TweenLite class files are downloaded, copy the &#8220;greensock&#8221; folder to your project&#8217;s subfolder &#8220;com&#8221;, as shown below -</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1265" title="Source Structure" src="http://www.hsharma.com/tech/wp-content/uploads/2010/05/sourceStruct.jpg" alt="Source Structure" width="365" height="506" /></p>
<h3>Setting up &#8220;Flash Professional to Flash Builder&#8221; Workflow</h3>
<ol>
<li>Open the .fla file from the archive in Flash Professional CS5.</li>
<li>Click on the &#8220;Edit Class Definition&#8221; button beside the Document Class text box in the Properties Panel
<div style="text-align: center;"><img class="alignnone size-full wp-image-1261" title="Edit Class Definition" src="http://www.hsharma.com/tech/wp-content/uploads/2010/05/editClassDef.jpg" alt="Edit Class Definition" width="389" height="270" /></div>
</li>
<li>Flash Professional pops up a dialog asking where you would want to edit the Class Definition. Choose Flash Builder and click OK.
<div style="text-align: center;"><img class="alignnone size-full wp-image-1262" title="Edit ActionScript 3.0 Class" src="http://www.hsharma.com/tech/wp-content/uploads/2010/05/editASClass.jpg" alt="Edit ActionScript 3.0 Class" width="440" height="141" /></div>
</li>
<li>Flash Builder 4 should automatically open now. Flash Builder now creates a new project linking it to your Flash Professional CS5 .fla file.</li>
<li>Give it a project name you desire and specify a location for your Flash Builder Project and click Finish.
<div style="text-align: center;"><img class="alignnone size-full wp-image-1263" title="Create Flash Builder Project" src="http://www.hsharma.com/tech/wp-content/uploads/2010/05/createFlexProject.jpg" alt="Create Flash Builder Project" width="591" height="379" /></div>
</li>
<li>You should see a project structure in Flash Builder similar to the one shown below -
<div style="text-align: center;">
<p><img class="alignnone size-full wp-image-1264" title="Flash Builder Project Structure" src="http://www.hsharma.com/tech/wp-content/uploads/2010/05/fbProjectStruct.jpg" alt="Flash Builder Project Structure" width="227" height="272" /></p>
</div>
</li>
<li>You should also see Logic.as opened so you can start editing the class definition. Once done editing, to test the movie, follow the same shortcut key as Flash Professional CS5. Being in Flash Builder 4, press Ctrl+Enter (Win) or Cmd+Enter (Mac).</li>
<li>You may also delete CrazyGems.as under default package (the same folder as the .fla), since in this particular project, I have all my code in Logic.as.</li>
</ol>
<p>Do drop me a mail in case you find some trouble understanding the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/articles/source-one-code-multi-screen/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>One Code, Multi-Screen</title>
		<link>http://www.hsharma.com/tech/adobe/one-code-multi-screen/</link>
		<comments>http://www.hsharma.com/tech/adobe/one-code-multi-screen/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 08:54:45 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Player]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Video Tutorials]]></category>
		<category><![CDATA[10.1]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[multiscreen]]></category>
		<category><![CDATA[platform]]></category>
		<category><![CDATA[Player]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=1232</guid>
		<description><![CDATA[I happened to write a simple casual game a couple of weeks back for a purpose. The fact that I didn&#8217;t have to re-write any code for platform specific execution just amazed me. I decided to record a video showcasing the content on 3 different devices &#8211; Laptop running Snow Leopard, Touch Laptop running Windows [...]]]></description>
			<content:encoded><![CDATA[<p>I happened to write a simple <a href="http://www.hsharma.com/projects/crazygems2" target="_blank" rel='nofollow'>casual game</a> a couple of weeks back for a purpose. The fact that I didn&#8217;t have to re-write any code for platform specific execution just amazed me. I decided to record a video showcasing the content on 3 different devices &#8211; Laptop running Snow Leopard, Touch Laptop running Windows 7 and Google NexusOne (Android). All I had to do is host the content on a web server and access it from all these devices. I just had to make sure I installed <strong><a href="http://labs.adobe.com/technologies/flashplayer10/" target="_blank" rel='nofollow'>Adobe Flash Player 10.1</a></strong> since the game was built for that version of the player.</p>
<p>I call this game <a href="http://www.hsharma.com/projects/crazygems2" target="_blank" rel='nofollow'>Crazy Gems</a> and it is hosted on my website. The way the application is written, makes it run successfully on many different platforms irrespective of the screen sizes and some of the device capabilities that vary. The video below showcases the same game from the same server running on 3 different platforms. It also summarizes the fact that your content, if built well, could and would run successfully giving users seamless experience across *all* the platforms that <a href="http://labs.adobe.com/technologies/flashplayer10/" target="_blank" rel='nofollow'>Adobe Flash Player</a> runs on.</p>
<p style="text-align: center;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_gUY0GoNw_Dc&amp;hl=en_US&amp;fs=1&amp;_1400344449"
			class="flashmovie"
			width="640"
			height="385">
	<param name="movie" value="http://www.youtube.com/v/gUY0GoNw_Dc&amp;hl=en_US&amp;fs=1&amp;" />
	<param name="allowscriptaccess" value="always" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.youtube.com/v/gUY0GoNw_Dc&amp;hl=en_US&amp;fs=1&amp;"
			name="fm_gUY0GoNw_Dc&amp;hl=en_US&amp;fs=1&amp;_1400344449"
			width="640"
			height="385">
		<param name="allowscriptaccess" value="always" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-1232"></span></p>
<h3>More Information</h3>
<p>Find below some screen shots of the game running on different platforms -</p>
<table style="text-align: center;" cellspacing="0" cellpadding="5" width="100%" align="center">
<tbody>
<tr>
<td align="center" valign="top"><a href="http://www.hsharma.com/tech/wp-content/uploads/2010/04/ie.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-1233" title="Internet Explorer on Windows XP" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/ie-150x150.jpg" alt="Internet Explorer on Windows XP" width="150" height="150" /></a><br />
Internet Explorer<br />
on Windows XP</td>
<td align="center" valign="top"><a href="http://www.hsharma.com/tech/wp-content/uploads/2010/04/Firefox.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-1234" title="Firefox on Windows XP" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/Firefox-150x150.jpg" alt="Firefox on Windows XP" width="150" height="150" /></a><br />
Firefox<br />
on Windows XP</td>
<td align="center" valign="top"><a href="http://www.hsharma.com/tech/wp-content/uploads/2010/04/safari.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-1235" title="Safari on Windows XP" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/safari-150x150.jpg" alt="Safari on Windows XP" width="150" height="150" /></a><br />
Safari<br />
on Windows XP</td>
</tr>
<tr>
<td align="center" valign="top"><a href="http://www.hsharma.com/tech/wp-content/uploads/2010/04/safari_mac.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-1236" title="Safari on Snow Leopard" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/safari_mac-150x150.jpg" alt="Safari on Snow Leopard" width="150" height="150" /></a><br />
Safari<br />
on Snow Leopard</td>
<td align="center" valign="top"><a href="http://www.hsharma.com/tech/wp-content/uploads/2010/04/firefox_mac.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-1237" title="Firefox on Snow Leopard" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/firefox_mac-150x150.jpg" alt="Firefox on Snow Leopard" width="150" height="150" /></a><br />
Firefox<br />
on Snow Leopard</td>
<td align="center" valign="top"><a href="http://www.hsharma.com/tech/wp-content/uploads/2010/04/firefox_linux.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-1240" title="Firefox on Linux" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/firefox_linux-150x150.jpg" alt="Firefox on Linux" width="150" height="150" /></a><br />
Firefox<br />
on Linux</td>
</tr>
<tr>
<td align="center" valign="top"><a href="http://www.hsharma.com/tech/wp-content/uploads/2010/04/nexus_l.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-1241" title="NexusOne Landscape" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/nexus_l-150x150.jpg" alt="NexusOne Landscape" width="150" height="150" /></a><br />
Native Browser (Landscape)<br />
on Android (Google NexusOne)</td>
<td align="center" valign="top"><a href="http://www.hsharma.com/tech/wp-content/uploads/2010/04/nexus_p.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-1242" title="NexusOne Portrait" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/nexus_p-150x150.jpg" alt="NexusOne Portrait" width="150" height="150" /></a><br />
Native Browser (Portrait)<br />
on Android (Google NexusOne)</td>
<td align="center" valign="top"></td>
</tr>
</tbody>
</table>
<p>A similar experiment was carried out by <a href="http://blogs.adobe.com/cantrell/" target="_blank" rel='nofollow'>Christian Cantrell</a> running Adobe AIR also on many different platforms. <a href="http://blogs.adobe.com/cantrell/archives/2010/04/one_application_five_screens.html" target="_blank" rel='nofollow'>Check it out here</a>.</p>
<h3>Flash Professional CS5 to Flash Builder 4 Workflow</h3>
<p>I majorly used this workflow, which really made my coding process faster and easier. I designed the game UI in Photoshop CS5 and imported assets, built the layout in Flash Professional CS5. Later coded the app in Flash Builder 4. It was a piece of cake to use the code hinting in Flash Pro CS5 and also code &amp; debug in Flash Builder 4.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1249" title="Crazy Gems Project Structure in Flash Builder 4" src="http://www.hsharma.com/tech/wp-content/uploads/2010/04/structure1.jpg" alt="Crazy Gems Project Structure in Flash Builder 4" width="238" height="255" /></p>
<p>According to the image above, the whole project structure was just one .fla file with one main ActionScript file. Making it run on different devices involves publishing for different platforms. This was just 2 in my case. Flash Player and AIR. I just had to change that in the Publish Settings of my Flash Professional CS5.</p>
<h3>Support for Accelerometer</h3>
<p>This game can also be played on devices supporting Accelerometer. To accomplish this, I used <strong><code>Accelerometer.isSupported</code></strong> API to determine if Accelerometer was supported on the platform that is running the game. If returned true, I create objects and write listeners. If returned false, I ignore the logic of using Accelerometer and instead, make use of touch/mouse controls and keyboard events.</p>
<h3>Support for AIR</h3>
<p>I am yet to just click a mouse button and set the publish settings of the .fla file to publish the content to <strong><a href="http://labs.adobe.com/technologies/air2/" target="_blank" rel='nofollow'>AIR 2</a></strong>. That&#8217;s all there is to it. I have made use of <strong><code>Capabilities.playerType</code></strong> to determine if the content runs on Flash Player or AIR and based on this, I enable/disable AIR specific features to my content.</p>
<h3>Source Code</h3>
<p>You can find the source code here &#8211; <a href="http://www.hsharma.com/tech/articles/source-one-code-multiple-screens/" target="_blank" rel='nofollow'>Source: One Code, Multiple Screens</a></p>
<p>You may play the game for fun &#8211; <a href="http://www.hsharma.com/projects/crazygems2" target="_blank" rel='nofollow'>Crazy Gems 2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/adobe/one-code-multi-screen/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Presentation: Creating Multiscreen Apps</title>
		<link>http://www.hsharma.com/tech/adobe/presentation-creating-multiscreen-apps/</link>
		<comments>http://www.hsharma.com/tech/adobe/presentation-creating-multiscreen-apps/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 13:45:45 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Seminars]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[multi]]></category>
		<category><![CDATA[platform]]></category>
		<category><![CDATA[Player]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[summit]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=1223</guid>
		<description><![CDATA[This was the presentation I showcased during the Great Indian Developer Summit 2010 this month. I also showcased the Flash Professional CS5 to Flash Builder 4 workflow. Showcased the game that I developed in Flash Professional CS5 and used Flash Builder 4 to write code for the same and publishing the same code for Browser, [...]]]></description>
			<content:encoded><![CDATA[<p>This was the presentation I showcased during the <a href="http://www.developermarch.com/developersummit/" target="_blank" rel='nofollow'>Great Indian Developer Summit 2010</a> this month. I also showcased the Flash Professional CS5 to Flash Builder 4 workflow. Showcased the game that I developed in Flash Professional CS5 and used Flash Builder 4 to write code for the same and publishing the same code for Browser, Standalone and Devices.</p>
<p style="text-align: center;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ssplayer2_1762813330"
			class="flashmovie"
			width="425"
			height="355">
	<param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=creatingmultiscreenapps-100427083419-phpapp02&amp;stripped_title=creating-multiscreen-apps-using-adobe-flash-platform" />
	<param name="allowscriptaccess" value="always" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=creatingmultiscreenapps-100427083419-phpapp02&amp;stripped_title=creating-multiscreen-apps-using-adobe-flash-platform"
			name="fm_ssplayer2_1762813330"
			width="425"
			height="355">
		<param name="allowscriptaccess" value="always" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/adobe/presentation-creating-multiscreen-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Symbian Packager &#8211; Helisso</title>
		<link>http://www.hsharma.com/tech/s60/flash-symbian-packager-helisso/</link>
		<comments>http://www.hsharma.com/tech/s60/flash-symbian-packager-helisso/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 06:36:16 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[S60]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[package]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=1074</guid>
		<description><![CDATA[
As AIR 2.0 is down the line ticking time for the release, the current BETA AIR 2.0 has got one of the best examples a developer can build. Helisso &#8211; A Symbian Packager developed in AS3 for AIR 2.0.
Mark Doherty, platform evangelist has posted complete details of the app Helisso on his blog. Also demonstrating [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone size-full wp-image-1076" title="helisso" src="http://www.hsharma.com/tech/wp-content/uploads/2010/03/helisso.jpg" alt="" width="500" height="264" /></p>
<p>As AIR 2.0 is down the line ticking time for the release, the current BETA AIR 2.0 has got one of the best examples a developer can build. Helisso &#8211; A Symbian Packager developed in AS3 for AIR 2.0.</p>
<p><a href="http://www.flashmobileblog.com" target="_blank" rel='nofollow'>Mark Doherty</a>, platform evangelist has posted complete details of the app <a href="http://www.flashmobileblog.com/2010/03/03/helisso-a-packager-for-symbian-devices/" target="_blank" rel='nofollow'><strong>Helisso</strong></a> on his blog. Also demonstrating a video walkthrough.</p>
<p>If you want to get your content packaged with custom svg icon for S60 v3 and v5, this might be the tool for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/s60/flash-symbian-packager-helisso/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Building iPhone Apps in CS5</title>
		<link>http://www.hsharma.com/tech/adobe/building-iphone-apps-in-cs5/</link>
		<comments>http://www.hsharma.com/tech/adobe/building-iphone-apps-in-cs5/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 17:18:12 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[cs5]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=1068</guid>
		<description><![CDATA[Presentation by Mike Chambers, Principal Product Manager, Adobe. Very informative and useful if you are seeking help in improving performance of your App using CS5 for iPhone (for future use of course).

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ssplayer2_913217926"
			class="flashmovie"
			width="425"
			height="355">
	<param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=flashiphonefitc2010-100223094652-phpapp02&#38;stripped_title=flash-iphone-fitc-2010" />
	<param name="allowscriptaccess" value="always" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=flashiphonefitc2010-100223094652-phpapp02&#38;stripped_title=flash-iphone-fitc-2010"
			name="fm_ssplayer2_913217926"
			width="425"
			height="355">
		<param name="allowscriptaccess" value="always" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></description>
			<content:encoded><![CDATA[<p>Presentation by Mike Chambers, Principal Product Manager, Adobe. Very informative and useful if you are seeking help in improving performance of your App using CS5 for iPhone (for future use of course).</p>
<p style="text-align: center;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ssplayer2_261777905"
			class="flashmovie"
			width="425"
			height="355">
	<param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=flashiphonefitc2010-100223094652-phpapp02&amp;stripped_title=flash-iphone-fitc-2010" />
	<param name="allowscriptaccess" value="always" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=flashiphonefitc2010-100223094652-phpapp02&amp;stripped_title=flash-iphone-fitc-2010"
			name="fm_ssplayer2_261777905"
			width="425"
			height="355">
		<param name="allowscriptaccess" value="always" />
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/adobe/building-iphone-apps-in-cs5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3D Realistic Earth using Papervision 3D &#8211; Part 1</title>
		<link>http://www.hsharma.com/tech/flash/3d-realistic-earth-using-papervision-3d-part-1/</link>
		<comments>http://www.hsharma.com/tech/flash/3d-realistic-earth-using-papervision-3d-part-1/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 08:03:07 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Papervision 3D]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[earth]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=980</guid>
		<description><![CDATA[
Introduction
I was researching more on Papervision 3D when I realized I can share some information on creating a 3D realistic Earth model. I will also explain how to add rotation to earth and one way to show the rotation of moon and revolution of it around earth. I will also briefly describe how to handle [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-988" title="earth_render" src="http://www.hsharma.com/tech/wp-content/uploads/2009/11/earth_render.jpg" alt="earth_render" hspace="10" vspace="10" width="244" height="182" /></p>
<h3>Introduction</h3>
<p>I was researching more on Papervision 3D when I realized I can share some information on creating a 3D realistic Earth model. I will also explain how to add rotation to earth and one way to show the rotation of moon and revolution of it around earth. I will also briefly describe how to handle something called &#8220;Pivot&#8221; points in Papervision 3D.</p>
<h3>Setting Up</h3>
<p>To start with, if you are fresh and new to Papervision 3D, I will describe the basic steps to configure your Flash CS4 authoring tool to work with Papervision 3D.</p>
<p><span id="more-980"></span></p>
<ol>
<li>Navigate to <a href="http://code.google.com/p/papervision3d/downloads/list" target="_blank" rel='nofollow'>http://code.google.com/p/papervision3d/downloads/list</a> in your browser</li>
<li>Download the latest build&#8217;s ZIP file (You may also use the SWC or use SVN to download latest Papervision 3D class files if you know. This is just my way of setting up).</li>
<li>Extract it to a folder of your choice, e.g., C:\PV3D or Documents\PV3D</li>
<li>Open your Flash CS4 authoring tool and go to Edit&gt;Preferences(Win) or Flash&gt;Preferences (Mac)</li>
<li>Navigate to Action Script and choose Action Script 3.0.</li>
<li>In the &#8220;Source Path&#8221; section, click on the folder icon to browse to add a folder of libraries. Choose the folder where you extracted Papervision 3D class files.</li>
<li>Click OK and you are done with the setup. Now you can proceed creating Papervision 3D content.</li>
</ol>
<h3>Creating Basic Earth</h3>
<p>We shall create a simple sphere (basic shape) and rotate it in place along Y axis.</p>
<ol>
<li>Now that Papervision is set up, we create a new Action Script class file connected to an FLA file (e.g., Earth.as -&gt; Earth.fla). Go ahead and create a new Action Script file and save it as Earth.as. Also create an FLA file and name it Earth.fla and in the Document Properties of the FLA file, enter Earth (the class name attached to the document).</li>
<li>Before you compile, you need to pour in data in to .as file. We need to create basic class/package structure to start with as shown -
<pre class="brush: as3">package {
	import org.papervision3d.view.BasicView;
	import flash.events.Event;

	public class Earth extends BasicView {
		public function Earth():void {
			super(640, 480, false);
			stage.frameRate=30;
			startRendering();
		}
		override protected function onRenderTick(evt:Event=null):void {
			super.onRenderTick();
		}
	}
}</pre>
</li>
<li>If you compile the FLA file now, you shouldn&#8217;t be getting any error. In the above basic code, we have imported the <code>BasicView</code> class from Papervision 3D&#8217;s packages for making the rendering job easier as it contains necessary implementation of rendering, initiating scene, viewport, etc. Let&#8217;s not worry about it now. We have extended <code>Earth</code> class from <code>BasicView</code> and written a constructor with initialization code for rendering and stage properties. Also an override function <code>onRenderTick()</code> to handle each frame of animation for rendering.</li>
<li>Now we shall create a sphere and rotate it. Observe the highlighted code below -
<pre class="brush: as3;highlight: [3, 7, 13, 14]">package {
	import org.papervision3d.view.BasicView;
	import org.papervision3d.objects.primitives.Sphere;
	import flash.events.Event;

	public class Earth extends BasicView {
		private var earth:Sphere;

		public function Earth():void {
			super(640, 480, false);
			stage.frameRate=30;

			earth=new Sphere(null,300,20,20);
			scene.addChild(earth);

			startRendering();
		}
		override protected function onRenderTick(evt:Event=null):void {
			super.onRenderTick();
		}
	}
}</pre>
</li>
<li>We have created a new Sphere of radius 300 and 20 vertical and horizontal segments. This sphere is added as a child to the scene in order to display the created Sphere. Now test the file you created by saving and compiling the SWF. The output should seem similar to the below screenshot -</li>
<p style="text-align: center;"><a href="http://www.hsharma.com/tech/wp-content/uploads/2009/12/basic_sphere.jpg" target="_blank" rel='nofollow'><img class="alignnone size-thumbnail wp-image-998" title="basic_sphere" src="http://www.hsharma.com/tech/wp-content/uploads/2009/12/basic_sphere-150x150.jpg" alt="basic_sphere" hspace="5" vspace="5" width="150" height="150" / rel='nofollow'></a></p>
<li>Without delay, we shall rotate this sphere with only one line of code added to the above code (in function <code>onRenderTick</code>) -
<pre class="brush: as3; first-line: 18; highlight: [19]">	override protected function onRenderTick(evt:Event=null):void {
		earth.localRotationY+=1;
		super.onRenderTick();
	}</pre>
</li>
<li><code>localRotationY</code> is a property of every DisplayObject3D used to rotate the object along the Y axis with respect to it&#8217;s local origin. The below image should help you understand it in case you need.<br />
<a href="http://www.hsharma.com/tech/wp-content/uploads/2009/12/y_rotation.jpg" rel='nofollow'></a></li>
<p style="text-align: center;"><img class="alignnone size-full wp-image-1003" title="y_rotation" src="http://www.hsharma.com/tech/wp-content/uploads/2009/12/y_rotation.jpg" alt="y_rotation" width="303" height="227" /></p>
<li>Now you may test your movie by pressing Ctrl+Enter (Win) / Command+Enter (Mac). You will see that the sphere rotates according to the Y axis.</li>
</ol>
<p>Hold on with this output for now. I shall update with the next part soon where we will apply texture to the rotating sphere with proper lighting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/flash/3d-realistic-earth-using-papervision-3d-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dynamic Multidimensional Vector in AS3</title>
		<link>http://www.hsharma.com/tech/flash/dynamic-multidimensional-vector-in-as3/</link>
		<comments>http://www.hsharma.com/tech/flash/dynamic-multidimensional-vector-in-as3/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 12:30:54 +0000</pubDate>
		<dc:creator>Hemanth Sharma</dc:creator>
				<category><![CDATA[Action Script 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[Multidimensional]]></category>
		<category><![CDATA[Vector]]></category>

		<guid isPermaLink="false">http://www.hsharma.com/tech/?p=973</guid>
		<description><![CDATA[We all know by now how beneficial Vector is over Array in most cases. Relating to strict data typing, way to an error free code and of course the performance are some benefits of using Vector instead of Array in Action Script 3.0. Below is a small code snippet of working with Multidimensional vector created [...]]]></description>
			<content:encoded><![CDATA[<p>We all know by now how beneficial Vector is over Array in most cases. Relating to strict data typing, way to an error free code and of course the performance are some benefits of using Vector instead of Array in Action Script 3.0. Below is a small code snippet of working with Multidimensional vector created dynamically.</p>
<pre class="brush: as3">for (var i:int=0; i&lt;3; i++) {

	this["myVar_"+i] = new Vector.&lt;Vector.&lt;int&gt;&gt;();

	for (var j:int=0; j&lt;3; j++) {

		this["myVar_"+i][j] = new Vector.&lt;int&gt;();

		for (var k:int=0; k&lt;3; k++) {
			this["myVar_"+i][j][k]=k;
		}
	}
}</pre>
<p>To explain the code above for people who don&#8217;t understand this easily, there are 3 loops and I am creating 2 dimensional <span style="text-decoration: line-through;">Array</span> Vector &#8211; Vector[i] and Vector[j].</p>
<p>As you can also notice, I am creating variables dynamically with no predefined name.  I don&#8217;t use <code>var myVariable:Vector</code> syntax as I don&#8217;t know the names of variables that I need to create and I don&#8217;t know how many I need to create. Hence, I use &#8220;<code>this</code>&#8221; to create dynamic variable of name <code>["myVar_" + i]</code>. Thus resulting in <code>myVar_0</code>, <code>myVar_1</code>, <code>myVar_2</code>&#8230;</p>
<p>For the i loop, I define each dynamic Vector variable as <code><strong>new Vector.&lt;Vector.&lt;int&gt;&gt;();</strong></code> This is because I know I want to create <code>myVar_i</code> as a Vector and each element in this vector will in turn contain a Vector (similar to 2 dimensional array) and later, each Vector inside <code>myVar_i</code> Vector will contain elements of data type <code>int</code> (Integer). So, as you can see in the j loop, I have initiated each element of <code>myVar_i</code> Vector as new Vectors and specified that each element of <code>[i][j]</code> Vector will contain an int type element. Finally in k loop, I populate/push the Vector with an integer data k.</p>
<p>You may view further comparision of Array and Vector performance in <a href="http://www.mikechambers.com/blog/2008/09/24/actioscript-3-vector-array-performance-comparison/" target="_blank" rel='nofollow'>Mike Chambers&#8217; blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hsharma.com/tech/flash/dynamic-multidimensional-vector-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
