使用TLF文本并在AIR2.6中获取阶段null时,Swf未加载为居中

时间:2014-05-20 11:56:07

标签: actionscript-3 flash actionscript air flash-cs5

当加载SWF时,它不会使用&amp ;;加载以TLF文本为中心的SWF。让阶段无效。如果使用经典普通文本,则以负载为中心。

请建议如何在AIR 2.6中加载以TLF文本为中心的SWF。我编写了如下代码。

package {
import flash.display.MovieClip;
import flash.geom.Rectangle;
import flash.display.*;
import flash.events.MouseEvent;
import flash.events.Event;

public class FullScreen extends Sprite {

    public function FullScreen() {

        this.addEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);

        btnClose.addEventListener(MouseEvent.CLICK, btnCloseFun);
    }

    private function _onAddedToStage(e:Event):void {

        txt.text= "This is text";

        var screenBounds:Rectangle = Screen.mainScreen.visibleBounds;

        stage.nativeWindow.x = screenBounds.width/2 - stage.stageWidth/2;
        stage.nativeWindow.y = screenBounds.height/2 - stage.stageHeight/2;

        this.removeEventListener(Event.ADDED_TO_STAGE, _onAddedToStage);
    }           

    function btnCloseFun(event:MouseEvent):void {
        stage.nativeWindow.close(); 
    }
}

}

Flash文件属性为width = 800,height = 600

enter image description here

enter image description here

0 个答案:

没有答案