Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
-
- CommentAuthorExey
- CommentTimeMar 3rd 2009 edited
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 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? -
- CommentAuthorRichard
- CommentTimeMar 3rd 2009
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.
1 to 2 of 2
