forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaddFrameScript.as
More file actions
28 lines (23 loc) · 1.02 KB
/
addFrameScript.as
File metadata and controls
28 lines (23 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package utils.frame
{
import flash.display.MovieClip;
/**
Calls a specified method when a specific frame is reached in a MovieClip timeline.
@param target: The MovieClip that contains the <code>frame</code>.
@param frame: The frame to be notified when reached. Can either be a frame number (<code>uint</code>), or the frame label (<code>String</code>).
@param notify: The function that will be called when the frame is reached.
@return Returns <code>true</code> if the frame was found; otherwise <code>false</code>.
@throws ArguementTypeError if you pass a type other than a <code>String</code> or <code>uint</code> to parameter <code>frame</code>.
*/
public function addFrameScript(target:MovieClip, frame:*, notify:Function):Boolean
{
if (frame is String)
frame = getFrameNumberForLabel(target, frame);
else if (!(frame is uint))
throw new Error('frame');
if (frame == -1 || frame == 0 || frame > target.totalFrames)
return false;
target.addFrameScript(frame - 1, notify);
return true;
}
}