Jono
Jono

Reputation: 4076

AS3 Accessing frame without using 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.

Upvotes: 1

Views: 188

Answers (1)

Marty
Marty

Reputation: 39458

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.

Upvotes: 4

Related Questions