Took a bit of research but I figured it out. Here's the code:
- Code: Select all
import flash.display.FrameLabel;
private function convertLabelsToFrames(targetClip:MovieClip, startFrameLabel:String, endFrameLabel:String):int {
var frameLabelsArray:Array = targetClip.currentLabels;
var startLabel:FrameLabel;
var endLabel:FrameLabel;
var n:int = frameLabelsArray.length;
for (var i:int = 0; i < n; i++){
if(frameLabelsArray[i].name == startFrameLabel){
startLabel = frameLabelsArray[i];
}
if(frameLabelsArray[i].name == endFrameLabel){
endLabel = frameLabelsArray[i];
}
}
var time:int = endLabel.frame - startLabel.frame;
return time;
}
EDIT: Here's something super dope. Alliteratively, we can code the return value as such:
- Code: Select all
return int(Math.abs(time));
I'm taking the absolute value of time
Math.abs(time) which returns a positive Number and
casting it as an int to maintain the function's return value integrity. What does this all mean? It means that even if time is a negative number it will always return a positive integer, so you won't have to worry about which label is the start or end label.

Hope this helps.