gpt4 book ai didi

apache-flex - AIR:为什么 stage == null?

转载 作者:行者123 更新时间:2023-12-03 23:14:54 24 4
gpt4 key购买 nike

我正在尝试在我的 AIR 应用程序上设置 scaleMode。这是通过 stage.scaleMode 设置的。但是,当我尝试引用 stage 时,它​​返回为 null。我不知道为什么?

这是整个应用程序:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
<mx:Script>
<![CDATA[
import flash.display.StageDisplayState;
private function init():void
{
var s:Stage = this.stage; //<<-- this.stage == null...why??
s.scaleMode = StageScaleMode.EXACT_FIT;
}
]]>
</mx:Script>
</mx:WindowedApplication>

最佳答案

试试 windowComplete而不是 creationComplete .还:

[If] you are trying to add eventListeners to the stage right from the start of your application execution, this will only work with updateComplete() and applicationComplete().



来源: http://www.wietseveenstra.nl/blog/2007/02/understanding-the-flex-application-startup-event-order/

关于apache-flex - AIR:为什么 stage == null?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1075067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com