简体   繁体   English

Flex应用程序:帧速率属性为NaN

[英]Flex app: framerate property is NaN

I have an AS3 App class eg (pseudo code) 我有一个AS3 App类,例如(伪代码)

public class MyApp extends Application
{
        protected function onRender():void
        {
            trace("frameRate = "+frameRate);
        }
}

and this is then extended by the app MXML: 然后通过应用程序MXML对其进行扩展:

<MyApp width="100%" height="100%" frameRate="30" enterFrame="onRender()">
...
</MyApp>

The app appears to be running at the right speed, but in MyApp.onRender(), frameRate is seen as NaN (in the debugger too if I step through). 该应用程序似乎以正确的速度运行,但是在MyApp.onRender()中,frameRate被视为NaN(如果我逐步执行,在调试器中也是如此)。 Why is this? 为什么是这样? How should I be obtaining the application's FPS property? 应该如何获得应用程序的FPS属性?

The Language Reference has this note for frameRate in the Application class: 语言参考在Application类中具有关于frameRate注意事项:

Note : This property cannot be set by ActionScript code; 注意 :不能通过ActionScript代码设置此属性。 it must be set in MXML code. 必须在MXML代码中设置。

If you use stage.frameRate in your trace it should give you the framerate you assigned to the Application. 如果在跟踪中使用stage.frameRate ,则应为您分配给应用程序的帧率。 You might need to throw a try-catch statement around the trace , since the enterFrame event can be dispatched before stage is instantiated. 您可能需要在trace周围引发try-catch语句,因为可以在实例化stage之前分派enterFrame事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM