Hi.
Here is a complete demo for you to better understand how frames, labels, and scenes can be used to navigate and show animations.
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.events.FocusEvent;
import flash.text.TextField;
var defaultFrameInputText:String = "Frame or Label...";
var defaultSceneInputText:String = "Scene...";
var input:*;
function getLabels(target:MovieClip = null):Vector.<String>
{
var vector:Vector.<String> = new Vector.<String>();
if (!target)
target = root as MovieClip;
for (var i:uint = 0, total:uint = target.currentLabels.length; i < total; i++)
vector.push(target.currentLabels.name);
return vector;
}
function getScenes(target:MovieClip = null):Vector.<String>
{
var vector:Vector.<String> = new Vector.<String>();
if (!target)
target = root as MovieClip;
for (var i:uint = 0, total:uint = target.scenes.length; i < total; i++)
vector.push(target.scenes.name);
return vector;
}
function gotoPreviousFrame(e:MouseEvent):void
{
prevFrame();
if (currentFrame == currentScene.numFrames)
setNavigation();
}
function gotoNextFrame(e:MouseEvent):void
{
nextFrame();
if (currentFrame == 1)
setNavigation();
}
function gotoPreviousLabel(e:MouseEvent):void
{
var labels:Vector.<String> = getLabels();
gotoAndStop(labels[Math.max(labels.indexOf(currentLabel) - 1, 0)]);
}
function gotoNextLabel(e:MouseEvent):void
{
var labels:Vector.<String> = getLabels();
gotoAndStop(labels[Math.min(labels.indexOf(currentLabel) + 1, labels.length - 1)]);
}
function gotoPreviousScene(e:MouseEvent):void
{
if (getScenes().indexOf(currentScene.name) > 0)
{
prevScene();
setNavigation();
}
}
function gotoNextScene(e:MouseEvent):void
{
if (getScenes().indexOf(currentScene.name) < scenes.length - 1)
{
nextScene();
setNavigation();
}
}
function gotoFrameOrLabel(e:MouseEvent):void
{
if (input && input != 0 && input != "")
{
if (isNaN(input))
{
if (getLabels().indexOf(input) > -1)
{
gotoAndStop(input);
setNavigation();
}
}
else
{
if (uint(input) > 0 && uint(input) <= currentScene.numFrames)
{
gotoAndStop(input);
setNavigation();
}
}
}
frameOrLabelText.text = defaultFrameInputText;
}
function gotoScene(e:MouseEvent):void
{
if (input && input != 0 && input != "" && getScenes().indexOf(input) > -1)
{
gotoAndStop(1, input);
setNavigation();
}
sceneText.text = defaultSceneInputText;
}
function focusInHandler(e:FocusEvent):void
{
if (e.target == frameOrLabelText)
frameOrLabelText.text = "";
else if (e.target == sceneText)
sceneText.text = "";
}
function focusOutHandler(e:FocusEvent):void
{
if (e.target is TextField)
input = (e.target as TextField).text;
if (e.target == frameOrLabelText)
frameOrLabelText.text = defaultFrameInputText;
else if (e.target == sceneText)
sceneText.text = defaultSceneInputText;
}
function setNavigation():void
{
if (!previousFrameButton.hasEventListener(MouseEvent.CLICK))
previousFrameButton.addEventListener(MouseEvent.CLICK, gotoPreviousFrame);
if (!nextFrameButton.hasEventListener(MouseEvent.CLICK))
nextFrameButton.addEventListener(MouseEvent.CLICK, gotoNextFrame);
if (!previousLabelButton.hasEventListener(MouseEvent.CLICK))
previousLabelButton.addEventListener(MouseEvent.CLICK, gotoPreviousLabel);
if (!nextLabelButton.hasEventListener(MouseEvent.CLICK))
nextLabelButton.addEventListener(MouseEvent.CLICK, gotoNextLabel);
if (!previousSceneButton.hasEventListener(MouseEvent.CLICK))
previousSceneButton.addEventListener(MouseEvent.CLICK, gotoPreviousScene);
if (!nextSceneButton.hasEventListener(MouseEvent.CLICK))
nextSceneButton.addEventListener(MouseEvent.CLICK, gotoNextScene);
if (!frameButton.hasEventListener(MouseEvent.CLICK))
frameButton.addEventListener(MouseEvent.CLICK, gotoFrameOrLabel);
if (!sceneButton.hasEventListener(MouseEvent.CLICK))
sceneButton.addEventListener(MouseEvent.CLICK, gotoScene);
if (!frameOrLabelText.hasEventListener(FocusEvent.FOCUS_IN))
frameOrLabelText.addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
if (!stage.hasEventListener(FocusEvent.FOCUS_IN))
stage.addEventListener(FocusEvent.FOCUS_IN, focusInHandler);
if (!stage.hasEventListener(FocusEvent.FOCUS_OUT))
stage.addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
}
function start():void
{
stop();
setNavigation();
}
start();
Simple gotoAndStop and gotoAndPlay calls with button clicks will be enough.
My sample goal is to help you visualize what would be best for your needs.
If you want to learn the basics about timelines, navigation, and code, please don't forget to visit the official help (Adobe Animate Learn & Support) or to search for a good tutorial on YouTube.