actionscript-3videostagevideo

AS3 StageVideo > controlling depth of multiple stage video instances


http://www.adobe.com/devnet/flashplayer/articles/stage_video.html

According to the documentation the stageVideo object exposes a depth property which allows you to set the z depth.

But am confused on how to implement. There is a read only vector object

stage.stageVideos[0];

but how exactly do you populate this vector with more than one StageVideo object? Nowhere in the documentation does it explain this.


Solution

  • The stage.stageVideos array is pre-populated with the amount of stage video objects the system supports. So you don't have to do anything there. That number can change though based off app size and other things, so it's important to listen for the stage video availability events and react accordingly.

    To change the z-order, you use the depth property of a StageVideo instance:

    var stgVideo1:StageVideo = stage.stageVideos[0];
    stgVideo.depth = 2;
    
    //if the system supports more than 1, lets grab a reference to another stage video
    if(stage.stageVideos.length > 1){
        var stgVideo2:StageVideo = stage.stageVideos[1];
        stgVideo2.depth = 1;
    }
    

    This will make stgVideo2 behind the first one. All things being equal (same depth value, or none specified) the depth will be the same order as the stage.stageVideos array.

    For more information, read the documentation