Fork me on GitHub
Not signed in (Sign In)
    • CommentAuthorDomingo
    • CommentTimeMay 10th 2013 edited
    At the moment, I am attempting to resize a Position on an emitter when the stage itself resizes.

    I opted for the simpler (I thought) method of just recreating the emitter on resize. My assumption was, while it was probably expensive it wouldn't happen often.
    That seems to have worked; however...

    After I resize the window the actual particles aren't being drawn on the entire stage:

    If I even resize it back to its original dimensions, it looks fine again:

    I'm not sure if its relevent or not, but there are times that about 1 to 3 particles have been drawn outside that small subset. Also, it looks as if the edge of that stars is around the same as the stage height (like its forcing it to be square.)...

    Here's the code for the event:

    public class Client extends MovieClip {
    public var emitter:StarEmitter;
    public var cloudEmitter:CloudEmitter;
    public var renderer:DisplayObjectRenderer;

    public var loginPane:MovieClip;

    public var starBg:StarBackground;

    public function Client() {
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;

    emitter = new StarEmitter(stage.stageWidth, stage.stageHeight);
    renderer = new DisplayObjectRenderer();

    stage.addEventListener(Event.RESIZE, this.onResizeStage);


    private function onResizeStage(e:Event):void {

    trace("Stage Width: " + stage.stageWidth + ". Stage Height: " + stage.stageHeight + ".");

    emitter = new StarEmitter(stage.stageWidth, stage.stageHeight);



    Here's the StarEmitter code:
    public class StarEmitter extends Emitter2D {
    private var position:Position;
    public static const STARS:Number = 1000;

    public function StarEmitter(w:Number, h:Number) {
    counter = new Blast(STARS);
    addInitializer( new ImageClass( RadialDot, [2] ) );
    position = new Position( new RectangleZone(0, 0, w, h));
    addInitializer( position );

    Here's what the console output said:
    Stage Width: 1676. Stage Height: 963. (this was while it was large)
    Stage Width: 892. Stage Height: 592. (this was back to small again)