舞台渲染力/绘 [英] stage force render / redraw

查看:192
本文介绍了舞台渲染力/绘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我会听ENTER_FRAME事件,并执行$ C C帧被渲染每次$ ..但我的应用程序,这是太慢了。 2 ENTER_FRAME事件之间的时间是40毫秒。没关系,如果我改变我的帧率。

Normally I would listen to the ENTER_FRAME event and execute code each time a frame gets rendered.. But for my application this is too slow. The time between 2 ENTER_FRAME events is 40 milliseconds. Doesn't matter if I change my framerate.

那么,是否可以强制闪光重绘/渲染帧不听的事件?我试过stage.invalidate()方法,并改变帧率,但它并没有提高任何东西(stage.invalidate()不会做任何事情,其实)

So is it possible to force flash to redraw/render the frame without listening to events? I tried the stage.invalidate() method and changing the framerate but it doesn't improve anything (stage.invalidate() doesn't do anything actually)

我做了一个小测试,看看ENTER_FRAME和EXIT_FRAME事件之间的平均时间:

I did a small test to see the average time between the ENTER_FRAME and the EXIT_FRAME event:

private var beginTime:Number;
private var endTime:Number;

public function init():void {
    addEventListener(Event.ENTER_FRAME, enterFrame);
    addEventListener(Event.EXIT_FRAME, exitFrame);
}

private function enterFrame(e:Event):void {
    beginTime = new Date().getTime();

    if(endTime) {
        trace(beginTime - endTime);
    }
}

private function exitFrame(e:Event):void {
    endTime = new Date().getTime();
}

如果我是正确的ENTER_FRAME事件是该帧的渲染和EXIT_FRAME事件之前发射的渲染之后触发。所以EXIT_FRAME事件之后渲染完成,该应用程序将派遣一个ENTER_FRAME事件。 这两个事件之间的平均时间为52毫秒。我想缩短那段时间

If I am right the ENTER_FRAME event is fired before the rendering of that frame and the EXIT_FRAME event is fired after the rendering. So after the EXIT_FRAME event the rendering is complete and the app will dispatch an ENTER_FRAME event. The average time between those two events is 52 milliseconds. And I want to shorten that time

Bytheway我心中的帧率为180本次测试

Bytheway I have set my framerate to 180 for this test

推荐答案

stage.Invalidate将迫使阶段重绘。它不是建议你应该先解决自己的时间的问题。

stage.Invalidate will force the stage to redraw. Its not suggested you should fix your time problem first.

这篇关于舞台渲染力/绘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆