TwelvestoneFlash

detecting when a stage resize is complete


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
baron ruhstoff
 
2008-11-03

So... I have a full-bleed video. In the interest of conserving overhead, I'd like to it to pause while the stage is being resized and resume playing once the resize is complete. Is there a simple way to detect when the stage is no longer being resized? Is there something about Event.RESIZE I'm not aware of?

Storm
 
2008-11-03

Are you going fullscreen or is this just a window resize?

The reason I ask is you could experiment with StageDisplayState to see when it sets its FULLSCREEN or NORMAL value.....theoretically.

baron ruhstoff
 
2008-11-03

Just a window resize.

I considered MouseEvent before realizing that the mouse is offstage. :(

Storm
 
2008-11-03

that was my next thought.....

how about:

trace(Event.COMPLETE);

[edit] package as3 { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event;

public class StageExample extends Sprite {

    public function StageExample() {
        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = StageAlign.TOP_LEFT;
        stage.addEventListener(Event.ACTIVATE, activateHandler);
        stage.addEventListener(Event.RESIZE, resizeHandler);
    }

    private function activateHandler(event:Event):void {
        trace("activateHandler: " + event);
    }

    private function resizeHandler(event:Event):void {
        trace("resizeHandler: " + event);
        trace("stageWidth: " + stage.stageWidth + " stageHeight: " + stage.stageHeight);
        trace(Event.COMPLETE);
    }
}

}

ok, I played with it a bit and it does trace the Event.COMPLETE value as 'complete'. Does that help you?

[edit] NOPE, never mind!! It always reports as complete even with the mouse still down.

I'm sure a code genius will be along soon....... lol k

baron ruhstoff
 
2008-11-03

Interesting. I'll give it a shot. Myself, I kept getting an undefined for e.COMPLETE: private function init(e:Event):void{ removeEventListener(Event.ADDED_TO_STAGE, init); stage.addEventListener(Event.RESIZE, onResize); } private function onResize(e:Event = null):void{ // pause the video - works great, but we don't have a way to detect // when the resizing is done, thus no way to resume playback // _videos.pause(); if (e != null){ trace(e.COMPLETE); } }

I wasn't aware of Event.ACTIVATE. What exactly is that doing?

// edit: Ooooh... it's Event.COMPLETE, not the param. Ah.

// edit: Nah. Still won't work. Not sure how helpful Event.COMPLETE is - it's a constant. :(

Storm
 
2008-11-03

yes it's Event not event, but it still doesn't work.

ACTIVATE is for when the movie loses it's focus, so you can stop the video on DEACTIVATE and play it again on ACTIVATE, but that doesn't work because ACTIVATE doesn't trigger after the resize even after clicking on the screen.

MOUSE_LEAVE also works close to DEACTIVATE.

Sorry I'm no help but I'm trying to figure something out. It seems stupid they wouldn't write something for RESIZE to report it is done AFTER the mouse is UP.

All I can think of now is an interval event that starts comparing the Stage w & h on RESIZE but only checks after 2 or 3 seconds. But, like I said, I am FAR from a code genius on this sort of stuff.

Storm
 
2008-11-03

this is where I'm at.....

package as3 { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event;

public class StageExample extends Sprite {

    public function StageExample() {
        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = StageAlign.TOP_LEFT;
        stage.addEventListener(Event.ACTIVATE, activateHandler);
        stage.addEventListener(Event.DEACTIVATE, deactivateHandler);
        stage.addEventListener(Event.RESIZE, resizeHandler);
        stage.addEventListener(Event.TRYINGTOFIGUREOUTWHATGOESHERE, completeHandler);
    }

    private function activateHandler(event:Event):void {
    // play the video when the movie has focus
        trace("activateHandler: " + event);
    }

    private function deactivateHandler(event:Event):void {
    // pause the video when the movie loses focus
        trace("deactivateHandler: " + event);
    }

    private function resizeHandler(event:Event):void {
    // pause the video
    // you got this to work
        trace("resizeHandler: " + event);
        trace("stageWidth: " + stage.stageWidth + " stageHeight: " + stage.stageHeight);
    }

private function completeHandler(event:Event):void {
    // then play the video
        trace("completeHandler: " + event);
    }
}

}

lithium
 
2008-11-03

perhaps you could set up a timer that monitors the size of the window and dispatches an event when a certain threshold isn't met.

pseudocode:

new timer(200) timer.start()

onTimer : if ( abs(oldW - w) < threshold && abs(oldH - h) < threshold ) dispatch STOPPED_RESIZING end

 oldW = w;
 oldH = h;

might be a hacky and not necessarily optimal way to do it, but it'll work.

cheers,

A.

baron ruhstoff
 
2008-11-04

Holy crap, Storm. Above and beyond the call... Thanks!

Yeah Lith, some sort of polling is probably the way to go. Not ideal, but cheaper than rendering the video.

Much appreciated, all!

Storm
 
2008-11-04

I was done my project and "brainstorming" the next project so there was ample time to help a brutha out.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

detecting when a stage resize is complete