<?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"
	>

<channel>
	<title>Kablog</title>
	<atom:link href="http://www.kabomb.net/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kabomb.net/blog</link>
	<description>Official Flash Game, Programming and Development Blog of Kabomb</description>
	<pubDate>Fri, 02 May 2008 08:31:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Introduction to AIR</title>
		<link>http://www.kabomb.net/blog/dev/introduction-to-air</link>
		<comments>http://www.kabomb.net/blog/dev/introduction-to-air#comments</comments>
		<pubDate>Fri, 02 May 2008 08:25:40 +0000</pubDate>
		<dc:creator>Kable</dc:creator>
		
		<category><![CDATA[Flash Development]]></category>

		<category><![CDATA[Other Development]]></category>

		<guid isPermaLink="false">http://www.kabomb.net/blog/?p=13</guid>
		<description><![CDATA[
Air is the Earth&#8217;s atmosphere which is a layer of gases surrounding the planet Earth and retained by the Earth&#8217;s gravity.
Adobe Integrated Runtime. It is a system that lets you use HTML/Ajax, Flex or Flash to create rich desktop applications. I don&#8217;t know much about Flex or Ajax, but I&#8217;m going to show you how [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.kabomb.net/blog/wp-content/uploads/2008/05/adobe_air.png'><img src="http://www.kabomb.net/blog/wp-content/uploads/2008/05/adobe_air-300x158.png" alt="" title="adobe_air" width="300" height="158" class="aligncenter size-medium wp-image-25" /></a><br />
<del datetime="2008-03-16T07:50:29+00:00">Air is the Earth&#8217;s atmosphere which is a layer of gases surrounding the planet Earth and retained by the Earth&#8217;s gravity.</del><br />
Adobe Integrated Runtime. It is a system that lets you use HTML/Ajax, Flex or Flash to create rich desktop applications. I don&#8217;t know much about Flex or Ajax, but I&#8217;m going to show you how you can use Flash to build a proper desktop application as easy as you would create a game. First you&#8217;ll need to go <a href="http://www.adobe.com/products/air/develop/flash/" target="_blank">here</a> and click on &#8216;Download the Adobe AIR update for Flash CS3 Professional&#8217;. *Note: this is only for users with Flash CS3 Pro.<br />
<!--adsense#midpost--><br />
You&#8217;ll need to quit Flash to install the update, so open it again. Create a normal Flash file, then go to File>Publish Settings>Version>Adobe AIR 1.0. Now when we export, a swf won&#8217;t be created, instead Flash will take you to a real desktop application. To make a permanent application, go to Commands>AIR - Application and Installer Settings, fill out the required information then press &#8216;Publish Air File&#8217;. You&#8217;ll notice you have to save the FLA before this, and the necessary AIR files will be created in the same directory as the FLA. Open the &#8216;*.air&#8217; file, this will install the application to a destination of your choice. </p>
<p>I&#8217;ll soon post extra info on using AS3 commands especially for AIR, and other features you can use to create a good application. For now, keep experimenting and see what you can come up with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kabomb.net/blog/dev/introduction-to-air/feed</wfw:commentRss>
		</item>
		<item>
		<title>Elasticity</title>
		<link>http://www.kabomb.net/blog/dev/actionscript/as3/elasticity</link>
		<comments>http://www.kabomb.net/blog/dev/actionscript/as3/elasticity#comments</comments>
		<pubDate>Thu, 20 Mar 2008 05:05:39 +0000</pubDate>
		<dc:creator>Kable</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

		<guid isPermaLink="false">http://www.kabomb.net/blog/dev/actionscript/as3/elasticity</guid>
		<description><![CDATA[Both my games Zwingo and Squidgy use elasticity for the main control. Elasticity is the effect of making a MC follow the mouse while keeping it&#8217;s momentum if the mouse stops. Picture holding a yoyo on a string, looking straight down on it and moving the yoyo about. View the example here.


Create a circle on [...]]]></description>
			<content:encoded><![CDATA[<p>Both my games Zwingo and Squidgy use elasticity for the main control. Elasticity is the effect of making a MC follow the mouse while keeping it&#8217;s momentum if the mouse stops. Picture holding a yoyo on a string, looking straight down on it and moving the yoyo about. <a href='javascript:;' onclick="window.open('http://www.kabomb.net/blog/wp-content/uploads/2008/03/elasticity.swf', 'Cursor', 'width=500,height=500,left = ' + ((screen.width - 500) / 2) + ',top = ' + ((screen.height - 500) / 2) + ',scrollbars=yes,resizable=yes');">View the example here.<br />
<img src='http://www.kabomb.net/blog/wp-content/uploads/2008/03/elasticity1.jpg' alt='Elasticity SS1' /></a></p>
<p><!--adsense#midpost--></p>
<p>Create a circle on the stage and convert it to an MC, instance name ball. Add the following code to the main timeline:</p>
<pre><textarea cols="50" rows="10" readonly="yes" onClick="this.select();">var xspeed:Number = 0;
var yspeed:Number = 0;
var fric:Number = 0.9;
var ease:Number = 10;
function EF(event:Event) {
	xspeed += (mouseX-ball.x)/ease;
	yspeed += (mouseY-ball.y)/ease;
	xspeed*=fric;
	yspeed*=fric;
	ball.x+=xspeed;
	ball.y+=yspeed;
}
addEventListener(Event.ENTER_FRAME, EF);</textarea></pre>
<p>The variables we set are xspeed, yspeed, fric (friction) and ease. Alter these later if you want. </p>
<p>Each frame we add the difference between where the ball is and where it needs to go divided by ease on to the speeds. We then multiply the speed by friction, in other words friction has an effect on the ball. Finally we relate this speed to the ball&#8217;s properties, and the effect is complete. </p>
<p>Say at first, xspeed = 0, the difference from the mouse to the ball is 100. This means the resultant speed is (0+100/10)*0.9=9<br />
The next frame, xspeed = 9, difference = 91 so resultant speed is (9+91/10)*0.9=16.29<br />
As you can see, as the ball gets closer (difference gets smaller), the speed increases. Now lets see what happens when the ball passes the target:</p>
<p>xspeed = 20, difference = 0, so resultant speed is (20+0/10)*0.9=18<br />
Then xspeed = 18, difference = -18 (the ball has passed to the other side), resultant is (18-18/10)*0.9=14.58</p>
<p>Now that the ball has passed the target, it starts to slow down.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kabomb.net/blog/dev/actionscript/as3/elasticity/feed</wfw:commentRss>
		</item>
		<item>
		<title>Introduction to Flash Game Sponsorship</title>
		<link>http://www.kabomb.net/blog/dev/games-dev/sponsorship/introduction-to-flash-game-sponsorship</link>
		<comments>http://www.kabomb.net/blog/dev/games-dev/sponsorship/introduction-to-flash-game-sponsorship#comments</comments>
		<pubDate>Wed, 19 Mar 2008 22:56:16 +0000</pubDate>
		<dc:creator>Kable</dc:creator>
		
		<category><![CDATA[Sponsorship]]></category>

		<guid isPermaLink="false">http://www.kabomb.net/blog/dev/games-dev/sponsorship/introduction-to-flash-game-sponsorship</guid>
		<description><![CDATA[Flash game sponsorship has been going around for a few years now, and it has grown from portal to portal. There are hundreds of websites out there that are willing to sponsor games. So what is sponsorship? The most basic type of sponsorship is when a website pays a developer an agreed amount so the [...]]]></description>
			<content:encoded><![CDATA[<p>Flash game sponsorship has been going around for a few years now, and it has grown from portal to portal. There are hundreds of websites out there that are willing to sponsor games. So what is sponsorship? The most basic type of sponsorship is when a website pays a developer an agreed amount so the developer will put the website&#8217;s logo and link on the games, before it is released. It&#8217;s kind of like when before TV shows they say &#8216;This program is brought to you by Kraft&#8217;. Even though Kraft didn&#8217;t make the TV show, they would have payed to put the message on. Likewise, the websites pay you to say &#8216;presented by &#8230;&#8217; or you can make other agreements such as to have links to the website. </p>
<p>Websites want to do this because they know (or assume) they can earn more money from your game than they paid for the sponsorship. When people click on their link in your game, they get more traffic and more people click on their ads, earning them money. This is like Kraft hoping the viewers of that TV show will buy their product. The amount they pay you depends on how good your game is, and the agreement you make with them. This can be anywhere from $200 to $2000, even higher in some cases. </p>
<p>What you should never do <span id="more-12"></span>is sell ownership of your game. Most portals respect your right to be the owner and creator of your Flash game, and they can&#8217;t force you to say something like &#8216;Game created by (sponsor)&#8217;. There are different types of sponsorship, too. Exclusive sponsorship is when you have to domain lock your game (so it can&#8217;t be shown on other sites) to the sponsor&#8217;s site either for a given period of time or forever. In this case, the payment will be more but you won&#8217;t have as much exposure of your game, and you can&#8217;t have it on your own site either. </p>
<p><!--adsense#midpost--></p>
<p>Some common sponsors (and one&#8217;s that I&#8217;ve dealt with) include <a href="http://www.armorgames.com" target="_blank">Armorgames</a>, <a href="http://www.hallpass.com" target="_blank">Hallpass</a>, and <a href="http://www.maxgames.com/" target="_blank">Maxgames</a>. <a href="http://www.flashgamesponsorship.com/" target="_blank">FlashGameSponsorship</a> is a site that is all about this developed by Adam Schroeder, It&#8217;s worth a look. It has details on sponsorship, a list of sponsors and other information. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kabomb.net/blog/dev/games-dev/sponsorship/introduction-to-flash-game-sponsorship/feed</wfw:commentRss>
		</item>
		<item>
		<title>Simple Shooter Game - Part 1</title>
		<link>http://www.kabomb.net/blog/dev/actionscript/as3/simple-shooter-game-part-1</link>
		<comments>http://www.kabomb.net/blog/dev/actionscript/as3/simple-shooter-game-part-1#comments</comments>
		<pubDate>Tue, 18 Mar 2008 12:13:59 +0000</pubDate>
		<dc:creator>Kable</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

		<category><![CDATA[Game Making]]></category>

		<guid isPermaLink="false">http://www.kabomb.net/blog/dev/actionscript/as3/simple-shooter-game-part-1</guid>
		<description><![CDATA[
This set of tutorials with take you through the basics of how to create a simple shooter game. Note that this is the way I do it, not the only way, and feel free to change things as you read as every game maker has a different style. The first part of the tutorial will [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.kabomb.net/blog/wp-content/uploads/2008/03/shooter-ss2.png' alt='shooter ss2' /></p>
<p>This set of tutorials with take you through the basics of how to create a simple shooter game. Note that this is the way I do it, not the only way, and feel free to change things as you read as every game maker has a different style. The first part of the tutorial will show you how to make the main player and how you can control it. This tutorial is done completely is Actionscript 3.0, so if you only know AS2, <a href="http://www.kabomb.net/blog/dev/actionscript/as3/converting-from-as2-to-as3">see this post</a> and if you don&#8217;t know actionscript at all, <a href="http://www.kabomb.net/blog/about-this-blog">go here</a>.</p>
<p>The first step is to draw the main character. We&#8217;re going to be controlling him using the WASD or UP, LEFT, DOWN, RIGHT keys to move him, the mouse to aim and mouse click will fire bullets.<a href='javascript:;' onclick="window.open('http://www.kabomb.net/blog/wp-content/uploads/2008/03/shooter1.swf', 'Shooter 1', 'width=500,height=500,left = ' + ((screen.width - 500) / 2) + ',top = ' + ((screen.height - 500) / 2) + ',scrollbars=yes,resizable=yes');"> This is what you&#8217;ll be able make after you do this part. </a>After you&#8217;ve drawn the character, put it on the stage and give it an instance name of &#8217;ship&#8217;. </p>
<p>Now add this code to the main timeline:<span id="more-19"></span></p>
<pre><textarea cols="50" rows="90" readonly="yes" onClick="this.select();">var effects1_mc:MovieClip = new MovieClip();
addChild(effects1_mc);
addChild(ship);

var rad:Number = Math.PI/180;

var xspeed:Number = 0;
var yspeed:Number = 0;
var speed:Number = 0;
var maxspeed:Number = 3;
var angle:Number = 0;
var acc:Number = 0.3;
var friction:Number = 0.9;
var mouse_angle:Number = 0;

//KEYS
var left_key:Boolean = false;
var right_key:Boolean = false;
var up_key:Boolean = false;
var down_key:Boolean = false;
function key_down(e:KeyboardEvent) {
	if (e.keyCode == 37 || e.keyCode == 65) {
		left_key=true;
	}
	if (e.keyCode == 39 || e.keyCode == 68) {
		right_key=true;
	}
	if (e.keyCode == 38 || e.keyCode == 87) {
		up_key=true;
	}
	if (e.keyCode == 40 || e.keyCode == 83) {
		down_key=true;
	}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);
function key_up(e:KeyboardEvent) {
	if (e.keyCode == 37 || e.keyCode == 65) {
		left_key=false;
	}
	if (e.keyCode == 39 || e.keyCode == 68) {
		right_key=false;
	}
	if (e.keyCode == 38 || e.keyCode == 87) {
		up_key=false;
	}
	if (e.keyCode == 40 || e.keyCode == 83) {
		down_key=false;
	}
}
stage.addEventListener(KeyboardEvent.KEY_UP, key_up);
function EF(event:Event) {
	if (left_key) {
		xspeed-=acc;
	} else if (right_key) {
		xspeed+=acc;
	} else {
		xspeed*=friction;
	}
	if (up_key) {
		yspeed-=acc;
	} else if (down_key) {
		yspeed+=acc;
	} else {
		yspeed*=friction;
	}
	speed = Math.sqrt(Math.pow(xspeed,2)+Math.pow(yspeed,2));
	angle = Math.atan2(yspeed, xspeed)+90*rad;
	if (speed>maxspeed) {
		speed = maxspeed;
		xspeed = Math.sin(angle)*maxspeed;
		yspeed = -Math.cos(angle)*maxspeed;
	}
	ship.x += xspeed;
	ship.y += yspeed;
	mouse_angle = Math.atan2(ship.y-mouseY, ship.x-mouseX)-90*rad;
	ship.rotation = mouse_angle/rad;
	//
	if (speed>0.1) {
		var trail:Trail = new Trail();
		effects1_mc.addChild(trail);
		trail.x = ship.x+Math.random()*10-5;
		trail.y = ship.y+Math.random()*10-5;
	}
}
stage.addEventListener(Event.ENTER_FRAME, EF);</textarea></pre>
<p>Skip the first few lines, I will talk about this later. The first variable I set is &#8216;rad&#8217; short for radians. This helps me convert angles quickly between radians and degrees. If you don&#8217;t know what radians are, don&#8217;t worry - you just have to know that they&#8217;re another form of representing angles and AS3 uses them for calculations. So if a times an angle in degrees by &#8216;rad&#8217;, I will get radians, and if I divide &#8216;rad&#8217; into radians, I will get degrees. </p>
<p>The other variables are xspeed, yspeed, speed (absolute value of both xspeed and yspeed), maxspeed, angle (of direction), acc (acceleration), friction, and mouse_angle. </p>
<p>The next stage is creating the key listeners so we can see what keys are down, and what keys aren&#8217;t. As you can see, I set left, up down and right_key to false to indicate no keys are being pressed. Then I add the KEY_DOWN and KEY_UP listeners. The &#8216;keyCode&#8217; corresponds to the code of the key that is pressed. 37 and 65 are the keys for A and the left arrow key. In English, the code reads &#8216;if the keycode is 37 or 65 (if A or the left arrow key is pressed), set left_key to true&#8217;. The same goes for the next 6 keys. We duplicate this for the KEY_UP listener, except change the values to false to show the keys are no longer down. We are going to use these booleans (true/false) in controlling the ship later in the code. </p>
<p>Next we create the ENTER_FRAME function which I named &#8216;EF&#8217;. The next part of the code asks, &#8216;If the left key is down, make the xspeed go down by the acceleration, or if the right key is down, make xspeed go up by the acceleration. If neither key is down, friction will cause the xspeed to come to 0.&#8217; The same goes for the yspeed.</p>
<p>The next part of the code aims to limit the speed so it never goes pass &#8216;maxspeed&#8217;. I use the following technique, which calculates the combined speed value of the x and y speed&#8217;s, checks if it&#8217;s too fast and then adjusts xspeed and yspeed accordingly. The reason I do this, instead of checking the xspeed and yspeed individually is because the overall speed will end up being faster at a 45°. For example, if the maxspeed was 10, and it was travelling right at full speed, the overall speed would be 10. If we were going straight up, the overall speed would be 10. However, if we were going diagonally left and up, the xspeed would be limited to 10, as well as yspeed, meaning an overall speed of about 14 (using Pythagoras&#8217; thereom). My technique ensures the overall speed is always limited to the same number (maxspeed). </p>
<p>Firstly we calculate this speed by using Pythagoras&#8217; Thereom:<br />
<img src='http://www.kabomb.net/blog/wp-content/uploads/2008/03/shooter1-1.jpg' alt='shooter ss1' /><br />
Where speed = the square root of xspeed squared plus yspeed squared.<br />
At this stage we also calculate the angle, as shown in the diagram. I add 90° worth of radians on just because this is right through trial and error. If the speed is greater than the maxspeed, then we calculate the xspeed and yspeed based on this angle. We say xspeed is the sine of the angle times the speed, and yspeed is the cosine of the angle times the speed (we use negative because the flash plane is the normal cartesian plane flipped upside down). </p>
<p>Next we relate the x and y speed&#8217;s to the actual ship, so we add xspeed to the ship&#8217;s x and yspeed to the ship&#8217;s y, just like you would add the speed of a car to it&#8217;s distance travelled every hour. We then calculate the angle between the mouse and the ship with the same technique as we calculated the other angle. Then, the ship&#8217;s rotation will be this angle in degrees, so we divide by &#8216;rad&#8217;.</p>
<p>The next part handles the trails that come out of the ship at it moves. First you&#8217;ll need to make the trail animation. I made a simple shape tween of a white dot fading away. On the last frame, when you want the trail to be removed, place this code:</p>
<pre><textarea cols="50" rows="3" readonly="yes" onClick="this.select();">stop();
parent.removeChild(this);</textarea></pre>
<p>First we stop the animation so it doesn&#8217;t continue playing. Then we remove the trail from it&#8217;s parent, which basically just removes the trail from view. Now go into the library, select your trails MC and right/control click on it and select properties, or press the tiny blue &#8216;i&#8217; icon at the bottom of the library. Click &#8216;Advanced&#8217; if you haven&#8217;t already and select &#8216;Export for Actionscript&#8217;. Where is says &#8216;Class&#8217; type &#8216;Trail&#8217;. This creates a new class for AS and you can now grab the trail MC from the library using just code. </p>
<p>For a trail to to be put there each frame, speed must first be over 0.1, as there shouldn&#8217;t be any trails appearing when the speed is very small or 0. To bring an MC from the library to the code, we use the same format as other classes, like Number or MovieClip except we use the class name we gave the MC in it&#8217;s properties. At the start of the code, I created a new MC called &#8216;effects1_mc&#8217;. This was the MC where all the &#8216;under&#8217; effects would go (effects that are shown below other things in the game). I then had to add the child, which makes the MC visible to the viewer. So that the ship MC appeared on top of the effects, I then added the ship child after the effects. After I made the trail MC I also had to add the child, this time to the effects1_mc who is the parent. This means the trails will appear below the ship. With the trail, I make the x and y positions equal to the ship&#8217;s position plus or minus a bit more. </p>
<p>Now you can export your movie and see what you came up with. Next time I&#8217;ll cover how to shoot bullets from the ship.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kabomb.net/blog/dev/actionscript/as3/simple-shooter-game-part-1/feed</wfw:commentRss>
		</item>
		<item>
		<title>Converting from AS2 to AS3</title>
		<link>http://www.kabomb.net/blog/dev/actionscript/as3/converting-from-as2-to-as3</link>
		<comments>http://www.kabomb.net/blog/dev/actionscript/as3/converting-from-as2-to-as3#comments</comments>
		<pubDate>Mon, 17 Mar 2008 12:29:31 +0000</pubDate>
		<dc:creator>Kable</dc:creator>
		
		<category><![CDATA[Actionscript 2.0]]></category>

		<category><![CDATA[Actionscript 3.0]]></category>

		<guid isPermaLink="false">http://www.kabomb.net/blog/dev/actionscript/as3/converting-from-as2-to-as3</guid>
		<description><![CDATA[This post should help you convert from Actionscript 2.0 to 3.0. AS3, in my opinion, was the biggest jump for Adobe from Flash 8 to CS3. It&#8217;s shown to be heaps faster than AS2, with a whole new bunch of classes and features. I won&#8217;t teach you everything there is to know, this is just [...]]]></description>
			<content:encoded><![CDATA[<p>This post should help you convert from Actionscript 2.0 to 3.0. AS3, in my opinion, was the biggest jump for Adobe from Flash 8 to CS3. It&#8217;s shown to be heaps faster than AS2, with a whole new bunch of classes and features. I won&#8217;t teach you everything there is to know, this is just a small step for you if your facing this dilemma. If know nothing about AS2, don&#8217;t bother reading. </p>
<p>Firstly the properties are represented differently, there is no more underscore when you are setting properties:</p>
<pre><textarea cols="50" rows="5" readonly="yes" onClick="this.select();">//AS2
this._x = 100
//AS3
this.x = 100</textarea></pre>
<p>The next thing you need to notice is that you can no longer add code to movieclips directly on the stage, all coding is now done from the timeline. Also, no more using &#8216;_root&#8217;. </p>
<p>If you are not already into defining variables or classes properly, AS3 forces you to do this or an error occurs. This is the correct format:</p>
<pre><textarea cols="50" rows="5" readonly="yes" onClick="this.select();">var name:Class = value;
//eg
var i:Number = 0;</textarea></pre>
<p>A big difference in AS3 for game development is the use of event listeners. Now, instead of calling a function like &#8216;onEnterFrame&#8217;, you create a custom function that will execute on the event, then add an event listener to the MC you want the event to listen to. Here&#8217;s a quick example with the enter frame event:<span id="more-11"></span></p>
<pre><textarea cols="50" rows="6" readonly="yes" onClick="this.select();">var i:Number = 0;
function EF(e:Event) {
	i++;
	trace(i);
}
addEventListener(Event.ENTER_FRAME, EF);</textarea></pre>
<p><!--adsense#midpost--></p>
<p>First we set &#8216;i&#8217; to 0 in the correct format, and as you can see the function name is custom so it can be whatever you want, however in the parameters you must have: &#8220;name:Event&#8221; to show that it will be part of an event. Then we add the event listener with &#8216;ENTER_FRAME&#8217; as the event type and &#8216;EF&#8217; was the function we created.</p>
<p>A big difference in game making in AS3, especially for me, was the use of depths and linking from the library. It doesn&#8217;t let you &#8216;attach a movie&#8217; anymore, rather you have to add a class name to a MC in the library and then create a class with the same name in the code. Firstly, click on the properties for the MC in the library, click on &#8216;Advanced&#8217; then &#8216;Export for AS&#8217;. You can no longer give an identifier. Instead, put a class name in with no spaces. For example, call it &#8216;MyMC&#8217;. Then add this code to grab the MC from the library and drag it onto the stage:</p>
<pre><textarea cols="50" rows="3" readonly="yes" onClick="this.select();">var mc:MyMC = new MyMC();
addChild(mc);
</textarea></pre>
<p>As you can see, instead of a default class name, we use &#8216;MyMC&#8217;, or whatever you named it in the properties. You then always have to make sure to &#8216;add the child&#8217;. This makes the MC visible on stage, without it the MC would be there but the viewer won&#8217;t be able to see it. Also, there&#8217;s no more &#8216;removeMovieClip&#8217;. Instead, you have to use this code to the MC (not on the main timeline):</p>
<pre><textarea cols="50" rows="3" readonly="yes" onClick="this.select();">parent.removeChild(this)
stop();</textarea></pre>
<p>The &#8217;stop&#8217; isn&#8217;t necessary, I put it in there in case you have a looping mc, in which case if you didn&#8217;t stop it, the MC will still be there (just not visible) and it would loop back to the same code which will cause errors because it will try removing the child that isn&#8217;t visible anymore. You&#8217;ll also have to remove event listeners you put on the MC, or more errors will come up. To do this, use this format:</p>
<pre><textarea cols="50" rows="2" readonly="yes" onClick="this.select();">this.removeEventListener(type, function);</textarea></pre>
<p>This should be all the basics covered. I&#8217;ve missed a lot of things out, so if you need more help see the Flash Help Documentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kabomb.net/blog/dev/actionscript/as3/converting-from-as2-to-as3/feed</wfw:commentRss>
		</item>
		<item>
		<title>New Blog, Cursor Effects</title>
		<link>http://www.kabomb.net/blog/news/kabomb/new-blog</link>
		<comments>http://www.kabomb.net/blog/news/kabomb/new-blog#comments</comments>
		<pubDate>Sat, 15 Mar 2008 06:00:17 +0000</pubDate>
		<dc:creator>Kable</dc:creator>
		
		<category><![CDATA[Actionscript 2.0]]></category>

		<category><![CDATA[Actionscript 3.0]]></category>

		<category><![CDATA[Kabomb News]]></category>

		<category><![CDATA[cursor effects]]></category>

		<guid isPermaLink="false">http://www.kabomb.net/blog/news/kabomb/new-blog</guid>
		<description><![CDATA[Hey, welcome to my new blog!
This new blog will make it tons easier for me to keep you posted on news from Kabomb, as well as flash related news from around the web. I’ll also be able to post open source tutorials, prototypes, and flash experiments that you can follow. You’ll be able to comment [...]]]></description>
			<content:encoded><![CDATA[<p>Hey, welcome to my new blog!</p>
<p>This new blog will make it tons easier for me to keep you posted on news from Kabomb, as well as flash related news from around the web. I’ll also be able to post open source tutorials, prototypes, and flash experiments that you can follow. You’ll be able to comment on all my posts and I’ll try to reply to the ones that need a reply, if not just email me.</p>
<p>If you have no idea what flash is or you want to get into it, you can download a free trial from the <a href="http://www.adobe.com">Adobe Website</a> where you’ll also need flash player (you should already have it) to see all the examples on your web browser. </p>
<p>Okay, let&#8217;s get down to business - my first tutorial - Cursor Effects. This lets you create effects like those in my Cursorized series where MC animations continually come out at the cursor which creates a really cool effect.<br />
<a href='javascript:;' onclick="window.open('http://www.kabomb.net/blog/wp-content/uploads/2008/03/cursor.swf', 'Cursor', 'width=550,height=400,left = ' + ((screen.width - 550) / 2) + ',top = ' + ((screen.height - 400) / 2) + ',scrollbars=yes,resizable=yes');"><br />
Here&#8217;s what I did.<br />
<img src='http://www.kabomb.net/blog/wp-content/uploads/2008/03/ss_cursor.png' alt='Cursor Effect Screenshot' /></a></p>
<p>Now I&#8217;ll explain how I did it.<br />
<span id="more-9"></span></p>
<p><!--adsense#midpost--></p>
<p><a href="#cursorAS2">Scroll to AS2 version</a></p>
<p>AS3<br />
First create a blank MC with an instance name of &#8216;Effect&#8217; (no quotes, case sensitive). Click on &#8216;Advanced&#8217; (if you haven&#8217;t already) and select &#8216;Export for Actionscript&#8217;. Click OK. Now you have to create a simple animation that will be the basis of the effect. </p>
<p>Create a blank keyframe after the last frame of the animation, and put this code there:</p>
<pre><textarea cols="50" rows="2" readonly="yes" onClick="this.select();">parent.removeChild(this);
stop();</textarea></pre>
<p>This removes the MC from being visible, and stops it so it isn&#8217;t needed any more.</p>
<p>On the main timeline, insert this code:</p>
<pre><textarea cols="50" rows="10" readonly="yes" onClick="this.select();">function EF(event:Event) {
	var effect:Effect = new Effect();
	addChild(effect);
	effect.x = mouseX;
	effect.y = mouseY;
	effect.rotation = Math.random()*360;
}
addEventListener(Event.ENTER_FRAME, EF);</textarea></pre>
<p>We create a function called &#8216;EF&#8217; (EnterFrame) which will be executed once every frame.<br />
In this function, we create a variable called &#8216;effect&#8217; in the &#8216;Effect&#8217; class. You created the &#8216;Effect&#8217; class when you selected &#8216;Export for Actionscript&#8217;. In other words, we&#8217;re creating a new MC based on the &#8216;Effect&#8217; instance.<br />
This MC needs to be visible, so we add the child so it can now be viewed by the viewer.<br />
The next lines determine what happens to the effect just as it has been created. Here, we set the effect&#8217;s x and y positions to the mouse, and make the rotation random from 0 to 360. You can change or add code to this if you want, you could make the x and y positions random or whatever. </p>
<p>Finally we add a listener to the function, the listener type is &#8216;ENTER_FRAME&#8217; (so it&#8217;s executed each frame) and the name of the function is &#8216;EF&#8217;. </p>
<p>Export your movie and see what you came up with! You can try out tons of effects, just experiment a little. </p>
<p><a name ="cursorAS2"></a>AS2 Version</p>
<p>First create a blank MC with an instance name of &#8216;effect&#8217; (no quotes). Click on &#8216;Advanced&#8217; (if you haven&#8217;t already) and select &#8216;Export for Actionscript&#8217;. Click OK. Now you have to create a simple animation that will be the basis of the effect. </p>
<p>Create a blank keyframe after the last frame of the animation, and put this code there:</p>
<pre><textarea cols="50" rows="1" readonly="yes" onClick="this.select();">this.removeMovieClip();</textarea></pre>
<p>This removes the MC so it isn&#8217;t needed anymore.</p>
<p>On the main timeline, insert this code:</p>
<pre><textarea cols="50" rows="10" readonly="yes" onClick="this.select();">i = 0
onEnterFrame = function(){
	i++;
	var effect:MovieClip = attachMovie(&#8217;effect&#8217;, &#8216;effect&#8217;+i,i);
	effect._x = _root._xmouse;
	effect._y = _root._ymouse;
	effect._rotation = Math.random()*360;
}</textarea></pre>
<p>The variable &#8216;i&#8217; is set to zero. This will be the basis for uniquely naming MCs and giving them a unique depth. </p>
<p>The &#8216;onEnterFrame&#8217; function executes the code within it each frame. </p>
<p>&#8216;i++&#8217; means 1 is added onto &#8216;i&#8217; each frame, so it will go from 1 to 2, 3, 4, etc.<br />
Then we create and effect MC and the MC we made in the library is attached to it, with a unique depth and name of whatever &#8216;i&#8217; is. With this MC, we set the x and y to the mouse&#8217;s position, and give it a random rotation. You can do whatever you want here.</p>
<p>Export your movie and see what you came up with! You can try out tons of effects, just experiment a little. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kabomb.net/blog/news/kabomb/new-blog/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.540 seconds -->
