<?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>Ghost23 Blog &#187; AS3 / Flex</title>
	<atom:link href="http://www.ghost23.de/category/flex-actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ghost23.de</link>
	<description>A blog about Flash and stuff</description>
	<lastBuildDate>Tue, 03 Jan 2012 15:21:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Mercedes Facebook game &#8211; flash</title>
		<link>http://www.ghost23.de/2011/07/mercedes-facebook-game-flash/</link>
		<comments>http://www.ghost23.de/2011/07/mercedes-facebook-game-flash/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 08:31:22 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[Flash in general]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=538</guid>
		<description><![CDATA[Juten Tach, another project just went online this week, in which i was involved: Drive and Seek &#8211; The Prologue. Together with Harald, who was the lead here, we were responsible for the development. I took special care of the interface to facebook and the customization features of the end video, in which you can [...]]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>another project just went online this week, in which i was involved: <a title="Drive and Seek - The Prologue" href="http://www.facebook.com/MercedesBenz?sk=app_214093555274968" target="_blank">Drive and Seek &#8211; The Prologue</a>. Together with <a title="Harald Tobler" href="http://www.seriouscircus.com/" target="_blank">Harald</a>, who was the lead here, we were responsible for the development. I took special care of the interface to facebook and the customization features of the end video, in which you can put your own picture either by uploading one or via webcam.</p>
<p>It was a fun project, going for a about a month.</p>
<p>What did i learn? First of all, i have mixed feelings about robotlegs. I like the DI part, but i cannot get used to these top-down mvc structures, which seem to put too much emphasis on infrastructure and too little on conceptual entities. I have to admit, that robotlegs technically does not tell you how to structure your application, but the best practices documentation does promote the approach of using mediators, commands and so on and tying it all together via bunch of events. This sounds all nice in theory, in practice for me, it is too technical and does not reflect the individual, conceptual relations of the components and modules i like to build. But this is stuff for another post.</p>
<p>I do like the Facebook API, although its documentation leaves a lot to be desired. The JavaScript SDK is nice and after fighting with the Facebook ActionScript library initially (couldn&#8217;t get it to initialize reliably), i soon abandoned it and used the JavaScript SDK directly via ExternalInterface.</p>

<div class="ngg-galleryoverview" id="ngg-gallery-4-538">


	
	<!-- Thumbnails -->
		
	<div id="ngg-image-54" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ghost23.de/wp-content/gallery/mercedesfacebook/game.jpg" title=" " class="shutterset_set_4" >
								<img title="game" alt="game" src="http://www.ghost23.de/wp-content/gallery/mercedesfacebook/thumbs/thumbs_game.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-55" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ghost23.de/wp-content/gallery/mercedesfacebook/start.jpg" title=" " class="shutterset_set_4" >
								<img title="start" alt="start" src="http://www.ghost23.de/wp-content/gallery/mercedesfacebook/thumbs/thumbs_start.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-56" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ghost23.de/wp-content/gallery/mercedesfacebook/userphotoinsert.jpg" title=" " class="shutterset_set_4" >
								<img title="userphotoinsert" alt="userphotoinsert" src="http://www.ghost23.de/wp-content/gallery/mercedesfacebook/thumbs/thumbs_userphotoinsert.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-57" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ghost23.de/wp-content/gallery/mercedesfacebook/webcam.jpg" title=" " class="shutterset_set_4" >
								<img title="webcam" alt="webcam" src="http://www.ghost23.de/wp-content/gallery/mercedesfacebook/thumbs/thumbs_webcam.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class='ngg-clear'></div>
 	
</div>


]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2011/07/mercedes-facebook-game-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brainbattle &#8211; emotiv, flash, union server</title>
		<link>http://www.ghost23.de/2011/05/brainbattle-emotiv-flash-union-server/</link>
		<comments>http://www.ghost23.de/2011/05/brainbattle-emotiv-flash-union-server/#comments</comments>
		<pubDate>Fri, 20 May 2011 10:13:14 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[Stuff]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=513</guid>
		<description><![CDATA[Tug-of-war type of game, using neuro-sensors from emotiv. Measures brain activity and calculates score points for two opponents.
Technologies involved: emotiv sdk, Unity Multiuser Server (Java), Flash / ActionScript3
This project took 2 days.]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>i was once again lucky enough to be able to build a fun little project. Brainbattle!</p>
<p><a href="http://www.ghost23.de/wp-content/gallery/brainbattle/brainbattle.jpg"><img class="alignnone size-full wp-image-518" title="Brainbattle" src="http://www.ghost23.de/wp-content/gallery/brainbattle/brainbattle.jpg" alt="The game Brainbattle in action" /></a></p>
<h3>But how did it all start?</h3>
<p>So, i occasionally give talks at the <a title="GoodSchool" href="http://good-school.de/" target="_blank">GoodSchool</a> about technology, internet and so on. The GoodSchool is a school for new ways of communication. All things digital, social, web, etc. and it is targeted at people in the marketing world. They have lots of different events all over the year. One is &#8220;camp digital&#8221;. Seven days packed full of information, inspiration and, of course, fun things.</p>
<p>So, Christian from the GoodSchool this time gave me two brain sensor headsets from <a title="Emotiv" href="http://www.emotiv.com/" target="_blank">emotiv</a> and asked me to build a little game with it. We decided to do a simple tug-of-war type of game.</p>
<h3>So, how does it work?</h3>
<p>So the setup is:</p>
<ul>
<li>Two emotiv epoc neuroheadsets (and their SDKs)</li>
<li>Two PCs connected via a twisted Ethernet cable</li>
<li>One <a title="Union Platform" href="http://www.unionplatform.com/" target="_blank">Union Platform server</a> (and the game control module build in Java)</li>
<li>Two little client flash apps, which take the converted signals from the emotiv SDKs and send it to the server (along with game controls)</li>
<li>One flash central Display app (seen in the pic above), that shows the game state.</li>
</ul>
<p>OK, the headsets connect two their respective PC over the air via a dongle. These headsets basically read the electric signals from your brain. As you can see in the picture below, the headset has a bunch of sensors, which need to be wet (using a saline solution). The tricky part is, that the sensors ideally touch the skin, which means, you have to fight a bit with the hair of the user to get out of the way.</p>
<p>These signals are read from a software SDK. Part of that SDK is a &#8220;training&#8221; program. There you can basically train &#8220;actions&#8221;. Like pull, push, up, down, vanish, show and lots of others. So you train a certain action, like &#8220;pull&#8221;. For 8 seconds you think about &#8220;pull&#8221; and the programm records the signals of your brain during that time. Then if you think that thought again later, the software recognizes the pattern and knows, that you think &#8220;pull&#8221;.</p>
<p><a href="http://www.ghost23.de/wp-content/gallery/brainbattle/emotiv-headset.jpg"><img class="alignnone size-full wp-image-515" title="emotiv-headset" src="http://www.ghost23.de/wp-content/gallery/brainbattle/emotiv-headset.jpg" alt="Emotiv Epoc neuroheadset close-up" /></a></p>
<p>Then there is a second little tool, called EmoKey. It is a simple converter. It converts an &#8220;action&#8221; into native Windows key events. So you define, that when the user thinks &#8220;pull&#8221;, it should emit a key event of the key &#8220;p&#8221;, for example. It can also do this continuously, lots of settings there.</p>
<p>So then i have a build a little client, which let&#8217;s you connect to the union server i have built, let the user click ready and also read those native key events. It then counts those incoming events per second and sends the result to server (every 500 ms).</p>
<p>The server (java) module takes those numbers from the two clients and calculates a force from it, being either positive or negative (depending on the numbers from client1 and client2). The server module of course also controls the various stages of the game, like client registering, game start, winning, and so on. The server is based on the union multiuser server, which is some nice piece of software and well documented. Its concept is around rooms and clients being in one or more rooms. The clients can send messages, set attributes on themselves or the rooms and so on. So i have created such a room, which has the game logic.</p>
<p>That game state is continuously send to the central flash display app, which is connected to the server as well (but only as an observer). It gets the force number and the game states and displays it.</p>
<p>So, that&#8217;s basically it. It took me about two and a half days to build it (and test it roughly). You can see a <a title="Brainbattle at goodschool" href="http://www.facebook.com/video/video.php?v=1764578721200" target="_blank">video of the game in action at facebook</a>.</p>
<div class="ngg-galleryoverview" id="ngg-gallery-1-513">


	
	<!-- Thumbnails -->
		
	<div id="ngg-image-22" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ghost23.de/wp-content/gallery/brainbattle/brainbattle.jpg" title=" " class="shutterset_set_1" >
								<img title="brainbattle" alt="brainbattle" src="http://www.ghost23.de/wp-content/gallery/brainbattle/thumbs/thumbs_brainbattle.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-28" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ghost23.de/wp-content/gallery/brainbattle/emotiv-headset.jpg" title=" " class="shutterset_set_1" >
								<img title="emotiv-headset" alt="emotiv-headset" src="http://www.ghost23.de/wp-content/gallery/brainbattle/thumbs/thumbs_emotiv-headset.jpg" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class='ngg-clear'></div>
 	
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2011/05/brainbattle-emotiv-flash-union-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Box2D wck together with ND2D</title>
		<link>http://www.ghost23.de/2011/04/box2d-wck-together-with-nd2d/</link>
		<comments>http://www.ghost23.de/2011/04/box2d-wck-together-with-nd2d/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 17:59:54 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[Stuff]]></category>
		<category><![CDATA[box2d]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[molehill]]></category>
		<category><![CDATA[nd2d]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=501</guid>
		<description><![CDATA[Juten Tach, since i a) was working quite a lot with Box2D lately b) am sitting next to Lars (aka nulldesign) today we had the idea to combine the Box2D alchemy port with Lars&#8217; ND2D graphics engine. The result involved lots of basketballs Caution: You need the Flash Player incubator build for this to run: [...]]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>since i</p>
<p>a) was working quite a lot with Box2D lately</p>
<p>b) am sitting next to Lars (aka <a href="http://www.nulldesign.de" target="_blank">nulldesign</a>)</p>
<p>today we had the idea to combine the Box2D alchemy port with Lars&#8217; ND2D graphics engine. The result involved lots of basketballs <img src='http://www.ghost23.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em>Caution: You need the Flash Player incubator build for this to run:</em></p>
<p><strong>[Update]</strong>: As commenters have already pointed out, the app below doesn&#8217;t work with the current flash player anymore. I would have to update Lars&#8217; ND2D engine to make it work again, but i currently simply feel to lazy to do it <img src='http://www.ghost23.de/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> </p>
<p><a href="http://ghost23.de/nd2dbox2d_demo/main.html" target="_blank">http://ghost23.de/nd2dbox2d_demo/main.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2011/04/box2d-wck-together-with-nd2d/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using Tweens with Box2D 2.0.1</title>
		<link>http://www.ghost23.de/2011/02/using-tweens-with-box2d-2-0-1/</link>
		<comments>http://www.ghost23.de/2011/02/using-tweens-with-box2d-2-0-1/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 18:39:09 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[Flash in general]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[box2d]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[tweening]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=484</guid>
		<description><![CDATA[Juten tach, i am currently involved in a fun project, where i am told to build a classical jump &#8216;n run game. Very nice. I am using the flash port of Box2d in its version 2.0.1. I know, that there is version 2.1, but it&#8217;s still alpha and i generally do not feel so comfortable [...]]]></description>
			<content:encoded><![CDATA[<p>Juten tach,</p>
<p>i am currently involved in a fun project, where i am told to build a classical jump &#8216;n run game. Very nice. I am using the flash port of Box2d in its version 2.0.1. I know, that there is version 2.1, but it&#8217;s still alpha and i generally do not feel so comfortable using alpha software.</p>
<p>Like in most jump &#8216;n run games, we have moving obstacles, like little bricks, that move from left to right and back again and you have to jump on them to get over a giant abyss.</p>
<p>Now these moving bricks should move autonomously and indefinitely. Being a flash developer, first thing, that comes to mind is tweening them. But as we learn from many sources in the box2d community, this is actually a no-go, because we should rather use velocities and the real physics of Box2d to make things move. Makes sense to me.</p>
<p>So my first attempt was to reuse some of the <a href="http://www.kerp.net/box2d/displaylesson.php?chapter=2&amp;lesson=26" target="_blank">smart scripts from Todd</a>. And that worked quite well. Here is an excerpt of the script (actually with slight changes from my side), that will run in the usual world update method (box2d specific):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>currentPosition<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&gt;</span>= initialPosition<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> movementDistance<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
   _direction = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span><span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>currentPosition<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">&lt;</span>= initialPosition<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
   _direction = <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> idealLocation<span style="color: #000066; font-weight: bold;">:</span>b2Vec2 = <span style="color: #0033ff; font-weight: bold;">new</span> b2Vec2<span style="color: #000000;">&#40;</span>currentPosition<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>_direction <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span>TRAVEL_SPEED <span style="color: #000066; font-weight: bold;">/</span> PhysiVals<span style="color: #000066; font-weight: bold;">.</span>RATIO<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> initialPosition<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> directionToTravel<span style="color: #000066; font-weight: bold;">:</span>b2Vec2 = idealLocation<span style="color: #000066; font-weight: bold;">.</span>Copy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
directionToTravel<span style="color: #000066; font-weight: bold;">.</span>Subtract<span style="color: #000000;">&#40;</span>currentPosition<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
directionToTravel<span style="color: #000066; font-weight: bold;">.</span>Multiply<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
_body<span style="color: #000066; font-weight: bold;">.</span>SetLinearVelocity<span style="color: #000000;">&#40;</span>directionToTravel<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>So looking at this, after a while i thought, idealLocation is a point, that changes on every box2d world step and reflects the position, where the body should be. Isn&#8217;t that the same thing, that a tweener does? Of course, it is.<br />
So changing this script to use a tweener like TweenLite or something is pretty easy. In my case, i am using TimelineMax, because i want to let my body to move back and forth infinitely (code simplified):</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> positionTracker<span style="color: #000066; font-weight: bold;">:</span>b2Vec2<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> initialize<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
   positionTracker = initialPosition<span style="color: #000066; font-weight: bold;">.</span>Copy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   timeline = <span style="color: #0033ff; font-weight: bold;">new</span> TimelineMax<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span>repeat<span style="color: #000066; font-weight: bold;">:-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   timeline<span style="color: #000066; font-weight: bold;">.</span>append<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TweenLite<span style="color: #000000;">&#40;</span>positionTracker<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>initialPosition<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> <span style="color: #000066; font-weight: bold;">+</span> movementDistance<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   timeline<span style="color: #000066; font-weight: bold;">.</span>append<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> TweenLite<span style="color: #000000;">&#40;</span>positionTracker<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#123;</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span>initialPosition<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onWorldUpdate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> currentPosition<span style="color: #000066; font-weight: bold;">:</span>b2Vec2 = myBody<span style="color: #000066; font-weight: bold;">.</span>GetXForm<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">position</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #6699cc; font-weight: bold;">var</span> directionToTravel<span style="color: #000066; font-weight: bold;">:</span>b2Vec2 = positionTracker<span style="color: #000066; font-weight: bold;">.</span>Copy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   directionToTravel<span style="color: #000066; font-weight: bold;">.</span>Subtract<span style="color: #000000;">&#40;</span>currentPosition<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   directionToTravel<span style="color: #000066; font-weight: bold;">.</span>Multiply<span style="color: #000000;">&#40;</span>Environment<span style="color: #000066; font-weight: bold;">.</span>TIME_STEP<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
   myBody<span style="color: #000066; font-weight: bold;">.</span>SetLinearVelocity<span style="color: #000000;">&#40;</span>directionToTravel<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>So, what is happening here? Well, we keep a helper object, the positionTracker. This is our object, that gets modified by our tweener. It is a b2Vec2 instance, which has x and y attributes. We give the positionTracker our initialPosition of our box2d body. Then we create our tween, just the normal way we always use tweens. But we use our positionTracker with it.</p>
<p>Now, somewhere in our program we usually have a world update method, because that&#8217;s how Box2D works. And here we simply use the approach <a href="http://www.kerp.net/box2d/displaylesson.php?chapter=2&amp;amp;lesson=26" target="_blank">Todd uses in his tutorial</a>, we take the current position of our body, calculate the difference from our desired location (which now is the location our tweener has calculated) and the current location and build a velocity vector from it, which we then set to our body.</p>
<p>The result is a crystal clear animation just the way we have defined it in our tween. But since we are setting a velocity, our body is still open for other forces, that have an impact on it. So in my case, when my character jumps on the brick, the brick eases off a bit, but quickly goes back on its path, which is a rather nice behavior, i think.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2011/02/using-tweens-with-box2d-2-0-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CommandCollection gets little bugfixes</title>
		<link>http://www.ghost23.de/2011/02/commandcollection-gets-little-bugfixes/</link>
		<comments>http://www.ghost23.de/2011/02/commandcollection-gets-little-bugfixes/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 12:01:18 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[Stuff]]></category>
		<category><![CDATA[bugfix]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=476</guid>
		<description><![CDATA[Juten Tach, a commenter made me aware of a bug in the Process class of my CommandCollection library, thanks for that. During fixing the bug i also fixed a wrong reference assignment for ProcessEvent.currentCommand, so now this should work as expected. CommandCollection is now at v.1.0.1.]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>a commenter made me aware of a bug in the Process class of my <a href="http://code.google.com/p/command-collection/" target="_blank">CommandCollection library</a>, thanks for that. During fixing the bug i also fixed a wrong reference assignment for ProcessEvent.currentCommand, so now this should work as expected.</p>
<p><a href="http://code.google.com/p/command-collection/" target="_blank">CommandCollection</a> is now at v.1.0.1.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2011/02/commandcollection-gets-little-bugfixes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 &#8211; internal class, public method</title>
		<link>http://www.ghost23.de/2011/01/as3-internal-class-public-method/</link>
		<comments>http://www.ghost23.de/2011/01/as3-internal-class-public-method/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 14:42:29 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[class]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=441</guid>
		<description><![CDATA[Juten Tach, a little quiz again. We have three classes: The first one is the main class of our swf, InternalTest: package &#123; &#160; import flash.display.Sprite; import testPackage.PublicClass; &#160; public class InternalTest extends Sprite &#123; public function InternalTest&#40;&#41; &#123; &#160; var publicClass:PublicClass = new PublicClass&#40;&#41;; var ref:Object = publicClass.returnInternalClassRef&#40;&#41;; ref.doSomething&#40;&#41;; ref.doSomethingInternally&#40;&#41;; &#125; &#125; &#125; Ok, in [...]]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>a little quiz again. We have three classes:</p>
<p>The first one is the main class of our swf, InternalTest:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #0033ff; font-weight: bold;">import</span> testPackage<span style="color: #000066; font-weight: bold;">.</span>PublicClass<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> InternalTest <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> InternalTest<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         <span style="color: #6699cc; font-weight: bold;">var</span> publicClass<span style="color: #000066; font-weight: bold;">:</span>PublicClass = <span style="color: #0033ff; font-weight: bold;">new</span> PublicClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #6699cc; font-weight: bold;">var</span> ref<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = publicClass<span style="color: #000066; font-weight: bold;">.</span>returnInternalClassRef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         ref<span style="color: #000066; font-weight: bold;">.</span>doSomething<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         ref<span style="color: #000066; font-weight: bold;">.</span>doSomethingInternally<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Ok, in a package &#8220;testPackage&#8221; we have two other classes, PublicClass and InternalClass.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> testPackage <span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PublicClass <span style="color: #000000;">&#123;</span>
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> returnInternalClassRef<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>InternalClass <span style="color: #000000;">&#123;</span>
         <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> InternalClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> testPackage <span style="color: #000000;">&#123;</span>
   <span style="color: #0033ff; font-weight: bold;">internal</span> <span style="color: #9900cc; font-weight: bold;">class</span> InternalClass <span style="color: #000000;">&#123;</span>
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> doSomething<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
         <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;InternalClass did something!!&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #000000;">&#125;</span>
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">internal</span> <span style="color: #339966; font-weight: bold;">function</span> doSomethingInternally<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
         <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;InternalClass did something internally!!&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Now make a guess, what happens?</p>
<p>Well, it&#8217;s not too hard to figure out, right? But interesting to remember anyway. The call for doSomething() works, whereas the call for doSomethingInternally() ends up in an exception. So if you define an internal class, you can still pass its reference outside its package (loosing the type obviously). Any public methods can be called then, but internal methods not. Makes sense, does it? I was just thinking about it, because i asked myself, why one would declare a class internal, but still have public methods.</p>
<p>So it only makes sense, if you want to pass it around as either an untyped reference or as a casted interface implementation. Means, you could have an interface outside the package and the internal class implements it. Then within the package you could use the class by its direct class type and outside you would use it by its interface type.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2011/01/as3-internal-class-public-method/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 library CommandCollection released</title>
		<link>http://www.ghost23.de/2010/12/actionscript-3-library-commandcollection-released/</link>
		<comments>http://www.ghost23.de/2010/12/actionscript-3-library-commandcollection-released/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 16:49:49 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[Flash in general]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=434</guid>
		<description><![CDATA[Juten Tach, today i release a little library i have been working on for quite a while. It contains three little class collections, i have used in the past and i thought, they might be useful for some. CommandCollection is a little ActionScript 3 library around using commands. It includes three tools: Process BranchProcess StateMachine [...]]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>today i release a little library i have been working on for quite a while. It contains three little class collections, i have used in the past and i thought, they might be useful for some.</p>
<p>CommandCollection is a little ActionScript 3 library around using commands. It includes three tools:</p>
<ul>
<li>Process</li>
<li>BranchProcess</li>
<li>StateMachine</li>
</ul>
<p><em>Process</em> is essentially a queue, in which you can put commands (synchronous or asynchronous), which will be executed sequentially.</p>
<p><em>BranchProcess</em> is similar, but allows you to build a tree of commands with the ability of one commands result having an impact on which command comes next.</p>
<p><em>StateMachine</em> is a classical finite state machine, that supports input commands for each state and is navigable. Means, you can aim for a state and the state machine will calculate a path to the target state and will try to reach it.</p>
<p>CommandCollection comes as .swc for integration into your project. Go check it out at <a href="http://code.google.com/p/command-collection/">http://code.google.com/p/command-collection/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2010/12/actionscript-3-library-commandcollection-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>int constants &#8211; many possibilities</title>
		<link>http://www.ghost23.de/2010/11/int-constants-many-possibilities/</link>
		<comments>http://www.ghost23.de/2010/11/int-constants-many-possibilities/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 11:11:50 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=424</guid>
		<description><![CDATA[Juten Tach, some weeks ago i was messing with OSGi and a possible implementation in ActionScript. That has been put aside, but one thing i noticed, was, that in the original Java implementation most of the constants were integers, using a bitwise notation. This is really not new, but i thought, it might be worthwhile [...]]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>some weeks ago i was messing with OSGi and a possible implementation in ActionScript. That has been put aside, but one thing i noticed, was, that in the original Java implementation most of the constants were integers, using a bitwise notation. This is really not new, but i thought, it might be worthwhile to refresh the topic. Take this little example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">const first<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>  = 0x000001<span style="color: #000066; font-weight: bold;">;</span>
const second<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = 0x000002<span style="color: #000066; font-weight: bold;">;</span>
const third<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span>  = 0x000004<span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>The rule is, every other constant has a value double of the previous one. With that, you can do pretty nice things.</p>
<p>You can have a variable, that functions as a toggle container for all your constants:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> constantsToggle<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
constantsToggle <span style="color: #000066; font-weight: bold;">+</span>= second<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// now you have turned on the switch for 'second'</span>
constantsToggle <span style="color: #000066; font-weight: bold;">+</span>= third<span style="color: #000066; font-weight: bold;">;</span>  <span style="color: #009900; font-style: italic;">// now you have turned on the switch for 'third'</span>
constantsToggle <span style="color: #000066; font-weight: bold;">-</span>= second<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// and now you have turned 'second' off again</span></pre></div></div>

<p>Wanna know, if any of the switches is turned on?</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>constantsToggle<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #000066; font-weight: bold;">...</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p>Wanna know, if a particular switch is turned on?</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>constantsToggle <span style="color: #000066; font-weight: bold;">&amp;</span> second<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #000066; font-weight: bold;">...</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p>Again, this is nothing major, but i found it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2010/11/int-constants-many-possibilities/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flash Builder &#8211; library project -include-stylesheets ??</title>
		<link>http://www.ghost23.de/2010/11/flash-builder-library-project-include-stylesheets/</link>
		<comments>http://www.ghost23.de/2010/11/flash-builder-library-project-include-stylesheets/#comments</comments>
		<pubDate>Thu, 18 Nov 2010 15:17:34 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[flash builder]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=414</guid>
		<description><![CDATA[Juten Tach, arghh. Do you know the -include-stylesheets compiler option, which is specifically made for building libraries? It is a great feature, because it compiles your stylesheets instead of just embedding the css file in your swc(see update). BUT! How are we supposed to use that wonderful feature in Flash Builder? If i add it [...]]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>arghh. Do you know the -include-stylesheets compiler option, which is specifically made for building libraries? It is a great feature, <span style="text-decoration:line-through;">because it compiles your stylesheets instead of just embedding the css file in your swc</span>(see update).</p>
<p>BUT! How are we supposed to use that wonderful feature in Flash Builder? If i add it as a compiler option, Flash Builder nags, that it does not want this option. My feeling is, that it is the mxmlc, that is speaking there, although i have a library project. But i cannot find any other place to tell FlashBuilder, that i want to use that option.</p>
<p>Have you found a solution to that? Please shout!</p>
<p>By the way, it would be so cool, if Flash Builder would not only show the classes of a library swc, but also included assets, otherwise, how am i to know, what files i can use?</p>
<p><strong>[Update]</strong>: Hm, seems like that compiler option works differently than i thought. It actually does NOT compile the Stylesheet, but classes, which are referenced by that stylesheet only. Too bad.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2010/11/flash-builder-library-project-include-stylesheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MouseEvent.relatedObject</title>
		<link>http://www.ghost23.de/2010/11/mouseevent-relatedobject/</link>
		<comments>http://www.ghost23.de/2010/11/mouseevent-relatedobject/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 16:03:54 +0000</pubDate>
		<dc:creator>Sven Busse</dc:creator>
				<category><![CDATA[AS3 / Flex]]></category>
		<category><![CDATA[Flash in general]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[mouse]]></category>

		<guid isPermaLink="false">http://www.ghost23.de/?p=405</guid>
		<description><![CDATA[Juten Tach, i just recently stumbled upon this little gem: MouseEvent.relatedObject. It turns out, it already exists since FlashPlayer 9.0, but i missed it. It is a pretty useful property. In a nutshell, it holds a reference to the object, which either lost or gained focus during mouse over or mouse out respectively. So i thought, i [...]]]></description>
			<content:encoded><![CDATA[<p>Juten Tach,</p>
<p>i just recently stumbled upon this little gem: MouseEvent.relatedObject. It turns out, it already exists since FlashPlayer 9.0, but i missed it. It is a pretty useful property. In a nutshell, it holds a reference to the object, which either lost or gained focus during mouse over or mouse out respectively. So i thought, i make a little example:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
   <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> HelloWorld <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> panel<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> button1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> button2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> HelloWorld<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         panel = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         panel<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x777777<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         panel<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">150</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         panel<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         panel<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">;</span>
         panel<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         button1 = createButton<span style="color: #000000;">&#40;</span>0xff0000<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         button2 = createButton<span style="color: #000000;">&#40;</span>0x0000ff<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">120</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         panel<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span>      = <span style="color: #990000;">&quot;Panel&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
         button1<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span>   = <span style="color: #990000;">&quot;Button 1&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
         button2<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span>   = <span style="color: #990000;">&quot;Button 2&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>panel<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>button1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>button2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         <span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">MOUSE_OVER</span><span style="color: #000066; font-weight: bold;">,</span> onMouseOver<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #000000;">&#125;</span>
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onMouseOver<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
         <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>
            <span style="color: #990000;">&quot;Mouse now over: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span>
            <span style="color: #990000;">&quot;. Used to be over: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">relatedObject</span> <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000066; font-weight: bold;">?</span> event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">relatedObject</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #990000;">&quot;n/a&quot;</span><span style="color: #000000;">&#41;</span>
         <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #000000;">&#125;</span>
&nbsp;
      <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> createButton<span style="color: #000000;">&#40;</span><span style="color: #004993;">color</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         <span style="color: #6699cc; font-weight: bold;">var</span> result<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         result<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">color</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         result<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         result<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         result<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
         result<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         <span style="color: #0033ff; font-weight: bold;">return</span> result<span style="color: #000066; font-weight: bold;">;</span>
      <span style="color: #000000;">&#125;</span>
   <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Instead of explaining everything, simply take a look at the result (in which i added a textfield, so you can see the traces). You will see, that whenever you roll on the panel from the main stage (which is colored in this aesthetically bright yellow), the relatedObject is null.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="300" height="250">
      <param name="movie" value="http://www.ghost23.de/wp-content/uploads/HelloWorld.swf" />
      <param name="bgcolor" value="#ffffee" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.ghost23.de/wp-content/uploads/HelloWorld.swf" width="300" height="250" bgcolor="#ffffee">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

]]></content:encoded>
			<wfw:commentRss>http://www.ghost23.de/2010/11/mouseevent-relatedobject/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

