SoFunction
Updated on 2025-04-11

FLASHAction Basics Movie Clip Control


Movie Clip is referred to as MC for short. In Flash, MC is a very important part. Using MC flexibly, reasonably and cleverly can make your Flash animation more exciting and dynamic! In Flash 5, MC gives people the impression that it is an object in C++ language. It can define its own "private" variables, define its own functions, and it can respond to events and process it. MCs can pass messages, control and synchronize each other, and define a MC that can be copied into multiple MCs with the same characteristics. Although MCs cannot be inherited, I think it is not an exaggeration to call MC an animation object. The production of MC has been described in detail in the previous chapters. In this section, we will mainly introduce some MC-related functions and objects provided in Flash.

Functions related to Move Clip and their general forms
duplicateMovieClip(<target>,<new name>,<depth>)
Copy an existing MC, where the target parameter is the name of the existing MC, new name is the name of the copied MC, depth is the depth of the new MC. It is worth noting that the depth of each MC cannot be the same, otherwise it will cause display confusion, and MCs with large depth will cover MCs with small depth.
removeMovieClip(<target>)
Delete a copied MC, where target is the name of the copied MC. MCs that are not copied cannot be removed. Deletion means clearing from memory and display screen at the same time. This Action can only be used with duplicateMovieClip.
loadMovie(<url>,<level|target>[,”GET”|”POST”])
Loading an MC from a url address is unknown.
unloadMovie(<level|target>)
Uninstall an already loaded MC, which can only be used with loadMovie.
startDrag(<target>[,True|False][,left,top,right,bottom])
Start dragging an MC, target is the name of the MC, and the second parameter indicates whether to set the number pointer to the center of the MC. The four parameters of left, top, right, and bottom indicate that the MC can only be dragged within the box defined by these two coordinates. These four parameters can be a numeric constant or an arithmetic expression.
stopDrag()
Stop dragging and dropping the MC by the mouse.
onClipEvent(<event>)
MC event response statement. Please see the introduction in the previous section.
swapDepths(<target>,<target>)
Exchange the depth values ​​of two MCs. This statement is a new statement added to Flash 5, so the control between MCs is more convenient.
tellTarget(<target>)
This is a very useful statement. It is used for mutual control and coordination between MCs. For example, an MC can tell another MC when it needs to jump to which frame, and an MC can also control when another MC is loaded, when it is displayed, when it is uninstalled, etc. Reasonable use of tellTarget statements can make your animation more ornamental.

Movie Clip object
Flash 5 provides a Movie Clip object, and the first 6 functions mentioned above are redefined in this object, and they can completely replace the previous 6 functions. The definition of the Movie Clip object is as follows:
attachMovie(<idName>,<new name>,<depth>)
Bind a Movie and generate an entity of the MC in the library. The idName is the name of the MC in the library, new name is the name of the newly generated MC, and depth is the depth. Like a constructor.
duplicateMovieClip(<new name>,<depth>)
Copying the current MC as the new MC, the parameters have the same meaning as above.
getURL(<url>,<window>,<method>)
Makes the browser browse the specified page. The getURL function has been provided separately in Flash 5. I wonder what the special meaning of encapsulation here? ? For the meaning of the parameters, please refer to the description of the getURL function.
gotoAndPlay(<frame>)
Jump to the specified frame and play. The frame parameter can be a numeric constant, a string constant, or an arithmetic expression.
gotoAndStop(<frame>)
Jump to the specified frame and stop playing. The frame parameter can be a numeric constant, a string constant, or an arithmetic expression.
loadMovie(<url>,<method>)
Introduce an external movie to the specified layer. url is a web address, and the method can be one of three empty, GET, and POST.
loadVariables(<url>,<method>)
Introduce external variable values ​​from the web server specified by the URL address. Parameter explanation is the same as above.
nextFrame()
Equivalent to gotoAndStop (next frame).
play()
Play the current MC from the current frame.
prevFrame()
Equivalent to gotoAndStop (the previous frame).
removeMovieClip()
Delete the current MC, and the MC is created with the duplicateMovieClip function.
startDrag(<True|False>,<left>,<top>,<right>,<bottom>)
Start dragging the current MC. The first Boolean parameter indicates whether the mouse is locked at the center of the current MC. The four parameters left, top, right, and bottom define a rectangle, and the MC can only drag within the range of this rectangle.
stop()
Stop playing of the current MC.
stopDrag()
Stop dragging the current MC.
unloadMovie()
Uninstall the current Movie, and the current Movie must be loaded by loadMovie.