AS3 Accessing frame without using gotoAndStop

杀马特。学长 韩版系。学妹 提交于 2020-01-06 01:35:08

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/21182811/as3-accessing-frame-without-using-gotoandstop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!