Fork me on GitHub
Not signed in (Sign In)
    • CommentAuthorTomAuger
    • CommentTimeJan 11th 2013
     
    I have an old project from 2008 of an extremely simple nature - it uses a PixelRenderer as a mask to reveal a MovieClip on stage.

    I have tried to port this old code to the latest version of Flint (4.x) and am very surprised that it _appears_ to run a lot slower. I would have imagined that more recent versions would be more performant, if anything, not less. So I assume there may be something wrong with what I'm doing now that wasn't wrong 5 years ago.

    Here's the old code:


    var renderer:BitmapRenderer;
    var emitter:Emitter;

    var mc_pic:MovieClip;

    public function Main() {
    addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init( event:Event ) {
    mc_pic = this.getChildByName( "picMC" ) as MovieClip;
    mc_pic.cacheAsBitmap = true;

    renderer = new PixelRenderer( new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight ) );
    renderer.addFilter( new BlurFilter( 6, 6, 1 ), true );
    renderer.cacheAsBitmap = true;

    emitter = new Emitter();
    emitter.renderer = renderer;
    emitter.counter = new Steady( 10000 );

    emitter.addInitializer( new Position( new RectangleZone( mc_pic.x, mc_pic.y, mc_pic.x + mc_pic.width, mc_pic.y + mc_pic.height ) ) );

    emitter.addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 5, 20 ) ) );
    emitter.addAction( new Move() );

    emitter.start();

    addChild( renderer );
    mc_pic.mask = renderer;
    }


    And here's the updated version:


    var renderer:BitmapRenderer;
    var emitter:Emitter;

    var mc_pic:MovieClip;

    public function Main() {
    addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init( event:Event ) {
    mc_pic = this.getChildByName( "picMC" ) as MovieClip;
    mc_pic.cacheAsBitmap = true;

    renderer = new PixelRenderer( new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight ) );
    renderer.addFilter( new BlurFilter( 6, 6, 1 ), true );
    renderer.cacheAsBitmap = true;

    emitter = new Emitter2D();
    emitter.counter = new Steady( 10000 );

    emitter.addInitializer( new Position( new RectangleZone( mc_pic.x, mc_pic.y, mc_pic.x + mc_pic.width, mc_pic.y + mc_pic.height ) ) );

    emitter.addInitializer( new Velocity( new DiscZone( new Point( 0, 0 ), 20, 5 ) ) );
    emitter.addAction( new Move() );

    renderer.addEmitter( emitter );
    emitter.start();

    addChild( renderer );
    mc_pic.mask = renderer;
    }
    • CommentAuthorRichard
    • CommentTimeJan 20th 2013
     
    Hi Tom

    I don't see anything wrong with your code. I too am surprised it runs a lot slower. Updates to Flint have usually been to add features rather than to improve performance, but with each new feature I tried to offset any resulting slowdown with performance improvements elsewhere. I wouldn't expect your project to be a lot slower (a little maybe).

    Sorry I can't help more.
    Richard
    • CommentAuthorTomAuger
    • CommentTimeJan 24th 2013
     
    There are only so many hours in the day! I wish I had a deeper understanding of optimization in an AS3 context, or I would offer to help.