Flint Particle System Forum - Using flint with Flash Builder 4 and Actionscript Tue, 13 Dec 2011 07:20:06 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1170#Comment_1170 http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1170#Comment_1170 Fri, 16 Apr 2010 15:33:32 +0100 neonblue
UIComponent doesn't exist by default in flash builder. If you want to use AS3 code in FB4 you'll need to add the UIComponent then add the renderer to it.

This is the snow example in FB4 using Actionscript:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
xmlns:filters="flash.filters.*"
creationComplete="init()" backgroundColor="#010101" >
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.geom.Point;

import mx.core.UIComponent;

import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.RadialDot;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;

private var emitter:Emitter2D = new Emitter2D();

private function init():void
{
var cnvs:UIComponent = new UIComponent();
emitter.counter = new Steady( 100 );

emitter.addInitializer( new ImageClass( RadialDot, 2 ) );
emitter.addInitializer( new Position( new LineZone( new Point( -5, -5 ), new Point( 505, -5 ) ) ) );
emitter.addInitializer( new Velocity( new PointZone( new Point( 0, 65 ) ) ) );
emitter.addInitializer( new ScaleImageInit( 0.75, 2 ) );

emitter.addAction( new Move() );
emitter.addAction( new DeathZone( new RectangleZone( -10, -10, 520, 420 ), true ) );
emitter.addAction( new RandomDrift( 15, 15 ) );

var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
this.addElement( cnvs );
cnvs.addChild( renderer );
renderer.addEmitter( emitter );

emitter.start();
emitter.runAhead( 10 );
}
]]>
</fx:Script>
<mx:Canvas id="myStage" width="100%" height="100%">
<s:Label x="56" y="41" text="Brrrr..... " color="#FDFBFB"/>
</mx:Canvas>

</s:Application> ]]>
Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1171#Comment_1171 http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1171#Comment_1171 Fri, 16 Apr 2010 18:14:09 +0100 Richard
org.flintparticles.twoD.renderers.*
org.flintparticles.twoD.renderers.mxml.*

The former are based on Sprite, and are intended for projects that don't use the Flex framework. You can, of course, use them with the Flex framework as described above if you wish.

The latter are based on UIComponent and can be used with the Flex framework. You don't need to manually add them to a display object, they are valid Flex components so you just drop them in, using MXML or Actionscript. They were designed for and work with Flex 3, I haven't tested them with Flex 4 but they should work fine given Flex 4 is intended to be backward compatible.

You can even design complete particle systems in MXML, as in this example. Most of the examples in the downloads and SVN have an MXML version along with the Flash and PureAS3 versions.

Richard ]]>
Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1172#Comment_1172 http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1172#Comment_1172 Sat, 17 Apr 2010 07:44:36 +0100 knowledge Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1173#Comment_1173 http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1173#Comment_1173 Sat, 17 Apr 2010 12:48:26 +0100 neonblue Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1176#Comment_1176 http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1176#Comment_1176 Sat, 17 Apr 2010 14:18:21 +0100 Richard
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:f="http://flintparticles.org/2009/flint2d"
minWidth="955" minHeight="600"
creationComplete="init()" backgroundColor="#010101" >
<fx:Script>
<![CDATA[
import flash.geom.Point;

import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.RadialDot;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.zones.*;

private var emitter:Emitter2D = new Emitter2D();

private function init():void
{
emitter.counter = new Steady( 100 );

emitter.addInitializer( new ImageClass( RadialDot, 2 ) );
emitter.addInitializer( new Position( new LineZone( new Point( -5, -5 ), new Point( 505, -5 ) ) ) );
emitter.addInitializer( new Velocity( new PointZone( new Point( 0, 65 ) ) ) );
emitter.addInitializer( new ScaleImageInit( 0.75, 2 ) );

emitter.addAction( new Move() );
emitter.addAction( new DeathZone( new RectangleZone( -10, -10, 520, 420 ), true ) );
emitter.addAction( new RandomDrift( 15, 15 ) );

renderer.addEmitter( emitter );

emitter.start();
emitter.runAhead( 10 );
}
]]>
</fx:Script>
<s:Label x="56" y="41" text="Brrrr..... " color="#FDFBFB"/>
<f:DisplayObjectRenderer id="renderer"/>
</s:Application>
]]>
Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1177#Comment_1177 http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1177#Comment_1177 Sat, 17 Apr 2010 14:36:11 +0100 Richard
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:f="http://flintparticles.org/2009/flint2d"
minWidth="955" minHeight="600"
backgroundColor="#010101" >
<fx:Script>
<![CDATA[
import org.flintparticles.common.displayObjects.RadialDot;
]]>
</fx:Script>
<s:Label x="56" y="41" text="Brrrr..... " color="#FDFBFB"/>
<f:DisplayObjectRenderer id="renderer">
<f:emitters>
<f:Emitter id="emitter" autoStart="true" runAheadTime="10">
<f:counter>
<f:Steady rate="100"/>
</f:counter>
<f:initializers>
<f:ImageClass imageClass="{RadialDot}" parameters="2"/>
<f:Position>
<f:LineZone startX="-5" startY="-5" endX="505" endY="-5"/>
</f:Position>
<f:Velocity>
<f:PointZone x="0" y="65"/>
</f:Velocity>
<f:ScaleImageInit minScale="0.75" maxScale="2"/>
</f:initializers>
<f:actions>
<f:Move/>
<f:DeathZone zoneIsSafe="true">
<f:RectangleZone left="-10" top="-10" right="510" bottom="410"/>
</f:DeathZone>
<f:RandomDrift driftX="15" driftY="15"/>
</f:actions>
</f:Emitter>
</f:emitters>
</f:DisplayObjectRenderer>
</s:Application>
]]>
Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1179#Comment_1179 http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1179#Comment_1179 Sun, 18 Apr 2010 13:59:49 +0100 neonblue