Flint Particle System Forum - How to draw BitmapRenderer without adding to Stage? 2011-06-23T13:23:50+01:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher How to draw BitmapRenderer without adding to Stage? http://flintparticles.org/forum/comments.php?DiscussionID=182&Focus=713#Comment_713 2009-03-03T17:22:52+00:00 2009-03-04T10:21:14+00:00 Exey http://flintparticles.org/forum/account.php?u=165 Nothing is displayed when I trying to bitmapData.draw(render) without adding render to Stage package { import flash.display.Sprite; import flash.display.Bitmap import ...

package {
import flash.display.Sprite;
import flash.display.Bitmap
import flash.display.BitmapData
import flash.geom.Point
import flash.geom.Rectangle
import flash.filters.BlurFilter
import flash.filters.ColorMatrixFilter
import org.flintparticles.twoD.emitters.Emitter2D
import org.flintparticles.twoD.renderers.BitmapRenderer
import org.flintparticles.common.counters.Steady
import org.flintparticles.common.initializers.SharedImage
import org.flintparticles.common.displayObjects.Line
import org.flintparticles.common.initializers.ColorInit
import org.flintparticles.twoD.initializers.Velocity
import org.flintparticles.twoD.zones.DiscZone
import org.flintparticles.common.initializers.Lifetime
import org.flintparticles.common.actions.Age
import org.flintparticles.twoD.actions.Move
import org.flintparticles.twoD.actions.RotateToDirection
import org.flintparticles.twoD.activities.FollowMouse
import org.flintparticles.common.events.EmitterEvent
import org.flintparticles.twoD.activities.MoveEmitter;

public class Main extends Sprite {

private var renderer:BitmapRenderer
private var bmp:Bitmap

public function Main( ) {
bmp = new Bitmap(new BitmapData(300, 300))
bmp.x = 300
addChild(bmp)

initEmitter()
}

private function initEmitter():void {
var emitter:Emitter2D = new Emitter2D();
emitter.counter = new Steady( 150 );

emitter.addInitializer( new SharedImage( new Line( 8 ) ) );
emitter.addInitializer( new ColorInit( 0xFFFFCC00, 0xFFFFCC00 ) );
emitter.addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 300, 300 ) ) );
emitter.addInitializer( new Lifetime( 0.2, 0.4 ) );

emitter.addAction( new Age() );
emitter.addAction( new Move() );
emitter.addAction( new RotateToDirection() );

renderer = new BitmapRenderer( new Rectangle( 0, 0, 300, 300 ) );
renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.95,0 ] ) );
renderer.addEmitter( emitter );
addChild( renderer ); // comment it!
renderer.visible = false; // comment it!

emitter.addActivity(new MoveEmitter(100,100));
emitter.addEventListener(EmitterEvent.EMITTER_UPDATED, onEmitterUpdate)

emitter.start( );
}

private function onEmitterUpdate(e:EmitterEvent):void {
if (bmp.bitmapData) bmp.bitmapData = new BitmapData(300, 300)
bmp.bitmapData.draw(renderer)
}

}
}


Why it isn't possible?]]>
How to draw BitmapRenderer without adding to Stage? http://flintparticles.org/forum/comments.php?DiscussionID=182&Focus=716#Comment_716 2009-03-03T18:50:02+00:00 2011-06-23T13:23:50+01:00 Richard http://flintparticles.org/forum/account.php?u=1 That's because the BitmapRenderer updates when it receives a render event, and it will only receive a render event when it's on the stage. You could try dispatching the render event yourself ...
renderer.dispatchEvent( new Event( Event.RENDER ) );

I've not tried this before myself but it seems it should work.]]>