跳到主要内容

GetCount

返回序列中的效果数量。

语法

expression.GetCount();

expression - 表示 ApiAnimationSequence 类的变量。

参数

此方法没有任何参数。

返回值

number

示例

此示例获取动画序列中的效果数量。

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);

// Create shapes
const shape1 = Api.CreateShape(
'rect',
80 * 36000, 80 * 36000,
Api.CreateSolidFill(Api.CreateRGBColor(61, 74, 107)),
Api.CreateStroke(0, Api.CreateNoFill())
);
shape1.SetPosition(50 * 36000, 80 * 36000);
slide.AddObject(shape1);

const shape2 = Api.CreateShape(
'ellipse',
80 * 36000, 80 * 36000,
Api.CreateSolidFill(Api.CreateRGBColor(107, 61, 74)),
Api.CreateStroke(0, Api.CreateNoFill())
);
shape2.SetPosition(150 * 36000, 80 * 36000);
slide.AddObject(shape2);

// Add animations
const timeLine = slide.GetTimeLine();
const mainSequence = timeLine.GetMainSequence();
mainSequence.AddEffect(shape1, 'entranceFade', 'onclick');
mainSequence.AddEffect(shape2, 'entranceBounce', 'afterprevious');

const count = mainSequence.GetCount();

const infoShape = Api.CreateShape(
'rect',
150 * 36000, 40 * 36000,
Api.CreateSolidFill(Api.CreateRGBColor(200, 200, 200)),
Api.CreateStroke(0, Api.CreateNoFill())
);
infoShape.SetPosition(20 * 36000, 10 * 36000);
const content = infoShape.GetDocContent();
const paragraph = content.GetElement(0);
paragraph.AddText('Effects count: ' + count);
slide.AddObject(infoShape);