<?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>Swami Charan&#039;s Blog &#187; Flash AS3</title>
	<atom:link href="http://www.swamicharan.com/blog/tag/flash-as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.swamicharan.com/blog</link>
	<description>My personal blog...</description>
	<lastBuildDate>Sat, 17 Jul 2010 13:02:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Making particles dragable in APE</title>
		<link>http://www.swamicharan.com/blog/flash/making-particles-dragable-in-ape/</link>
		<comments>http://www.swamicharan.com/blog/flash/making-particles-dragable-in-ape/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 06:42:38 +0000</pubDate>
		<dc:creator>Swami Charan</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[APE]]></category>
		<category><![CDATA[APE for Flash]]></category>
		<category><![CDATA[Dragable Circle Particle]]></category>
		<category><![CDATA[Dragable Rectangle Particle]]></category>
		<category><![CDATA[Dragging in APE]]></category>
		<category><![CDATA[Flash AS3]]></category>
		<category><![CDATA[Physics in Flash]]></category>
		<category><![CDATA[Vector]]></category>

		<guid isPermaLink="false">http://www.swamicharan.com/blog/?p=686</guid>
		<description><![CDATA[As you all know what APE is, I will go directly into what problem i faced when started with it and how i overcame it. First of all, APE source has class named Vector defined in it. When we try to publish any content with APE on Flash CS4/FP 10, there will be a conflict [...]]]></description>
			<content:encoded><![CDATA[<p>As you all know what APE is, I will go directly into what problem i faced when started with it and how i overcame it. First of all, APE source has class named <strong>Vector</strong> defined in it. When we try to publish any content with APE on Flash CS4/FP 10, there will be a conflict that arises between Vector class of APE and Vector Datatype of Flash Player 10.</p>
<p>So, i had to modify the APE source to rename the Vector class in APE and change the reference of Vector in APE source with the new name. Then i could able to run content with APE on Flash Player 10. You can download the modified source from <strong><a href="http://www.swamicharan.com/blog/wp-content/uploads/2009/11/source.zip" target="_blank"><span style="color: #0000ff;">here</span></a></strong>.</p>
<p><strong>Making Particle Dragable:</strong></p>
<p>After successful in running the content on Flash Player 10, i wanted to check out how drag works on APE particles. There are separate class files called 'DragableCircleParticle.as' and 'DragableRectangleParticle.as' under Files section of <a href="http://groups.google.com/group/ape-general/files" target="_blank"><span style="color: #0000ff;">APE Google Group</span></a>.</p>
<p>Place these .as files under '<strong>source\org\cove\ape</strong>' Folder of APE.</p>
<p>Using these classes can make our work easy in making particles dragable.</p>
<p>These dragable particles can be initialized as follows:</p>
<pre class="brush: php;">DragableCircleParticel(x:Number, y:Number, radius:Number, fixed:Boolean, mass:Number,elasticity:Number, frictio:Number);

DragableRectanlgeParticle(x:Number, y:Number, width:Number, height:Number, rotation:Number, fixed:Boolean, mass:Number, elasticity:Number, friction:Number)</pre>
<p class="brush: php;"><span id="more-686"></span></p>
<p class="brush: php;">Here is the sample code to make use of these classes:</p>
<p class="brush: php;"> </p>
<pre class="brush: php;">stage.frameRate=60;
import org.cove.ape.*;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.Event;

addEventListener(Event.ENTER_FRAME, run);

var apeholder:MovieClip = new MovieClip();
apeholder.graphics.drawRect(0, 0, 550, 400);
addChild(apeholder);

APEngine.init(1/3);
APEngine.container=apeholder;

APEngine.addForce(new VectorForce(false,0,2));
var examplelevel:Group = new Group();
examplelevel.collideInternal=true;

var leftwall:RectangleParticle=new RectangleParticle(5,200,10,600,0,true);
leftwall.setStyle(3, 0x000000, 1, 0xFFFFFF,1);
examplelevel.addParticle(leftwall);

var rightwall:RectangleParticle=new RectangleParticle(545,200,10,600,0,true);
rightwall.setStyle(3, 0x000000, 1, 0xFFFFFF,1);
examplelevel.addParticle(rightwall);

var bottomwall:RectangleParticle=new RectangleParticle(275,395,550,10,0,true);
bottomwall.setStyle(3, 0x000000, 1, 0xFFFFFF,1);
examplelevel.addParticle(bottomwall);

var block:DragableRectangleParticle=new DragableRectangleParticle(Math.random()*550,- Math.random()*50, 80, 80,0, false,3);
examplelevel.addParticle(block);

var wheel:DragableCircleParticle=new DragableCircleParticle(Math.random()*550,- Math.random()*50, 20, false,3);
examplelevel.addParticle(wheel);

APEngine.addGroup(examplelevel);

function run(event:Event):void {
	APEngine.step();
	APEngine.paint();
}</pre>
<p class="brush: php;">Here is the output <a href="http://www.swamicharan.com/blog/wp-content/uploads/2009/12/dragable.swf " target="_blank"><span style="color: #0000ff;"><strong>SWF</strong></span></a>.</p>
<p class="brush: php;">Hope this would be helpful...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.swamicharan.com/blog/flash/making-particles-dragable-in-ape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

