« | »

Flint Particles in Flex

26th June 2009

I released version 2.1 of Flint yesterday. This version features a number of small changes and a couple of major ones. You can read about all the changes on the Flint website, but I want to talk about the biggest change here. Flint now has full support and integration with the Flex Framework.

This means that all Flint’s renderer’s have Flex Framework compatible counterparts that extend UIComponent and that particle effects can be created with MXML code.

So, for example, a snow effect can be created like this

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
  xmlns:mx="http://www.adobe.com/2006/mxml"
  xmlns:f="http://flintparticles.org/2009/flint2d"
  layout="absolute" width="600" height="400">
  
  <mx:Script>
    <![CDATA[
      import org.flintparticles.common.displayObjects.RadialDot;
    ]]>
  </mx:Script>

<mx:Image source="@Embed(source='assets/Snow_1.png')"/>
<f:DisplayObjectRenderer id="renderer" width="600" height="400">
  <f:emitters>
    <f:Emitter id="emitter" autoStart="true" runAheadTime="10">
      <f:counter>
        <f:Steady rate="150"/>
      </f:counter>
      <f:initializers>
        <f:Position>
          <f:LineZone startX="-5" startY="-5" endX="605" endY="-5"/>
        </f:Position>
        <f:Velocity>
          <f:PointZone x="0" y="65"/>
        </f:Velocity>
        <f:ImageClass imageClass="{RadialDot}" parameters="{[2]}"/>
        <f:ScaleImageInit minScale="0.75" maxScale="2"/>
      </f:initializers>
      <f:actions>
        <f:Move/>
        <f:DeathZone zoneIsSafe="true">
          <f:RectangleZone left="-10" right="620"
                   top="-10" bottom="420"/>
        </f:DeathZone>
        <f:RandomDrift driftX="20" driftY="20"/>
      </f:actions>
    </f:Emitter>
  </f:emitters>
</f:DisplayObjectRenderer>
<mx:Image source="@Embed(source='assets/Snow_1_over.png')"/>
</mx:Application>

Which produces this swf

Flash required: You need version 9 or later of the free Flash player from Adobe to use this content. To download and install the free player from Adobe's web site click here.

All the examples in the Flint project are now available in at least three forms – Flash, PureAS3, and Flex.

Have fun with the new version.

Tags: , ,  

5 Comments add your own

Leave a Comment comment policy

required

required, hidden

XHTML: you can use these tags - <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to the comments via RSS Feed