AS3访问框架,而无需使用gotoAndStop [英] AS3 Accessing frame without using gotoAndStop

查看:108
本文介绍了AS3访问框架,而无需使用gotoAndStop的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来访问图像数据的影片剪辑一个特殊帧(儿童/转换信息),而无需使用 gotoAndStop 的方法。

Is there a way to access the image data (children/transformation info) of a particular frame in a MovieClip without having to use the gotoAndStop methods.

这些方法都是渲染管线的一部分,我要的是对数据的访问,而不是开始一个链开发,以呈现在屏幕上的东西,调用多个事件侦听器,并执行帧动作异步事件。

These methods are part of a rendering pipeline, all I want is access to the data, not to start a chain of asynchronous events that were developed to render things on screen, call multiple event listeners and execute frame actions.

推荐答案

您不仅可以这样做,但 gotoAndStop()甚至没有立即作出这样的数据可用。一帧的内容无法访问,直到<一code href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#event%3aframeConstructed"相对=nofollow> FRAME_CONSTRUCTED 当达到该帧事件分派,所以你实际上需要做的更像是:

Not only can you not do that, but gotoAndStop() doesn't even immediately make that data available. The contents of a frame aren't code accessible until the FRAME_CONSTRUCTED Event is dispatched when that frame is reached, so what you would actually have to do is more like:

var lastFrame:int = currentFrame;

function ready(e:Event):void
{
    if(currentFrame !== lastFrame)
    {
        // In this example, frame 15 is where some image
        // data we want is.
        if(currentFrame === 15)
        {
            // Get image data.
            //
        }

        lastFrame = currentFrame;
    }
}

addEventListener(Event.FRAME_CONSTRUCTED, ready);

自不必说;您需要跨帧存储数据不是一个可行的方法来构造一个应用

Needless to say; storing data you need across frames is not a viable way to structure an application.

这篇关于AS3访问框架,而无需使用gotoAndStop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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