Flint Particle System Forum - Using flint with Flash Builder 4 and Actionscript 2011-12-13T06:52:18+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1170#Comment_1170 2010-04-16T15:33:32+01:00 2011-12-13T06:52:18+00:00 neonblue http://flintparticles.org/forum/account.php?u=351 For anyone that is looking in using Flashbuilder 4, Flint, and Actionscript 3 and having a hard time. I just realized how to do it and am documenting it here. UIComponent doesn't exist by default ...
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 2010-04-16T18:14:09+01:00 2011-12-13T06:52:18+00:00 Richard http://flintparticles.org/forum/account.php?u=1 There are two versions of each renderer, in the packages org.flintparticles.twoD.renderers.* org.flintparticles.twoD.renderers.mxml.* The former are based on Sprite, and are intended for ...
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 2010-04-17T07:44:36+01:00 2010-04-17T07:50:39+01:00 knowledge http://flintparticles.org/forum/account.php?u=352 Thanks, Richard, this is awesome! I've been using a MX Panel with the addRawChild method to do the same thing as your Canvas technique. But what about using the new Flex 4 Spark components? Have you ... Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1173#Comment_1173 2010-04-17T12:48:26+01:00 2010-04-17T12:48:47+01:00 neonblue http://flintparticles.org/forum/account.php?u=351 I first started playing with MXML with Flint but quickly discovered that a lot of the exotic examples/help are in AS3. Since I do both AS3 and MXML programming I thought that it might be better to ... Using flint with Flash Builder 4 and Actionscript http://flintparticles.org/forum/comments.php?DiscussionID=344&Focus=1176#Comment_1176 2010-04-17T14:18:21+01:00 2010-04-17T14:24:55+01:00 Richard http://flintparticles.org/forum/account.php?u=1 If you want to define the emitter using AS3, I'd still be inclined to use the mxml renderer, like this
<?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 2010-04-17T14:36:11+01:00 2010-04-17T14:38:08+01:00 Richard http://flintparticles.org/forum/account.php?u=1 Just to add, Flint's mxml works with Flex 4 (I just tested it). The above effect, in mxml, ...
<?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 2010-04-18T13:59:49+01:00 2011-12-13T06:52:18+00:00 neonblue http://flintparticles.org/forum/account.php?u=351 This is super info; thanks.