在显示屏幕底部显示一个面板actionscript 3

时间:2014-03-05 09:14:04

标签: actionscript-3 flash flex fullscreen

我有一个问题是使用osmf维护我的内置flex和as3的flash播放器的全屏 我想在用户屏幕的底部显示面板栏。这应该适用于所有屏幕分辨率。我目前正在做的工作是在全屏显示视频,但问题是它没有相应地对齐视频控制面板。 我现在拥有的是这个

stage.fullScreenSourceRect = new Rectangle(0, 0, fsvideoContainerW , fsvideoContainerH); videoContainer.width = fsvideoContainerW; videoContainer.height = fsvideoContainerH; stage.scaleMode = StageScaleMode.EXACT_FIT; stage.displayState = StageDisplayState.FULL_SCREEN;

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

我无法在代码中看到专用于定位控件的代码。创建可调整大小的组件时的主要思想是收听Event.RESIZE。这是一个小片段如何工作:

package {

    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;

    public class StackOverflow extends Sprite {
        private var _playerControls:VideoPlayerControls;

        public function StackOverflow() {
            addEventListener(Event.ADDED_TO_STAGE, onAdded);
        }

        private function onAdded(e:Event):void {
            removeEventListener(Event.ADDED_TO_STAGE, onAdded);


            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;

            setup();
        }

        private function setup():void {
            //Main event that will help you reposition and resize your UI components
            stage.addEventListener(Event.RESIZE, onResize);

            _playerControls = new VideoPlayerControls();

            addChild(_playerControls)
        }

        private function onResize(e:Event):void {
            _playerControls.updateWidth(stage.stageWidth);
            _playerControls.y = stage.stageHeight - _playerControls.height;
        }

    }
}

import flash.display.Sprite;

internal class VideoPlayerControls extends Sprite {

    public function VideoPlayerControls() {
        this.graphics.beginFill(0x333333);
        this.graphics.drawRect(0, 0, 100, 40);
    }

    internal function updateWidth(width:int):void {
        //Do logic with reposition and resizing components
        this.width = width;
    }
}

舞台属性alignscaleMode只应在启动视频播放器时设置一次。