2013-05-03 51 views

回答

4
function getLabel() { 

var stage = sym.getComposition().getStage(); 
var labels = stage.timelines['Default Timeline'].labels; 

var currentLabel; 
var currentPosition = stage.getPosition(); 

$.each(labels, function(label, position){ 
    if (position <= currentPosition) currentLabel = label; 
}); 

return currentLabel; 

} 

console.log(getLabel()); 

这将返回当前位置(或前一个位置)上的标签。

+1

为此答案+1了,但我认为更好的解决方案可能是重写问题并将stage.getLabelPosition([label name])的值与stage.getCurrentPosition()(在本例中)进行比较。人们不一定需要知道逻辑块内标签的位置,你可能只想知道当前位置是否有特定的标签。 – DeeperID 2014-03-05 23:55:01