|
||||||||||||||||
. . . . . |
Flash MX - Common Errors In this tutorial I will be going through some common errors and show
you how to resolve these errors. Finding errors and fixing them is known as
"debugging" in programming. It can be frustrating at times, but it is
an integral part of programming and the errors dont go away as you get better
at programming. The problems only get more complex! Naming MovieClipsMovieClips in Flash MX can be named in a variety of ways. Lets go through them all.
Flash Tutorials in Video Format -
Watch them now at LearnFlash.com duplicateMovieClip namingWhen we use duplicateMovieClip command, we are duplicating a movieclip already on the stage. It must be on the stage to duplicate it. Use other commands for mc's that are only located in the library. We will go through them later.
Do you own a website that needs some creative elements? Get on the web to find information about Albany web design, as well as ecommerce. Naming MovieClips using attachMovie
createEmptyMovieClip
The template for this method is as follows: myMovieClip.createEmptyMovieClip (instanceName, depth)
_root.createEmptyMovieClip("empty_mc", 2);
_root.empty_mc.attachMovie("box", "b1",3);
_root.onEnterFrame = function(){
_root.empty_mc.b1._x +=1;
_root.empty_mc.b1._y +=1;
}
What we have done in this script is create an empty movie clip. The empty mc create is connected to the _root.
Then, the box mc can be attached to this empty mc. And we can call _root.empty_mc.b1.
// create empty mc
_root.createEmptyMovieClip("empty_mc", 2);
// attach b1 to empty mc
_root.empty_mc.attachMovie("box", "b1",3);
// attach b2 to empty mc
_root.empty_mc.attachMovie("box", "b2",4);
_root.onEnterFrame = function(){
// move the container clip
_root.empty_mc._x +=1;
_root.empty_mc._y +=1;
// rotate b1 clockwise
_root.empty_mc.b1._rotation +=5;
// rotate b2 anticlockwise
_root.empty_mc.b2._rotation -=5;
}
So, what happened? Pretty amazing, huh? What we did was move the container clip , which moved the whole shebang.Then we rotated b1 and b2 by targeting the specific clip inside the container. Using a container clip allows us to have control over a number of clips, or all the clips on the stage. Having a container clip allows us to delete all mc's on the stage at once by using container.removeMovieClip(); Otherwise we would have to go through all the mc's on the stage and delete them individually. e.g. _root.empty_mc.b1.removeMovieClip(); _root.empty_mc.b2.removeMovieClip();Instead we can remove both clips in one go by: _root.empty_mc.removeMovieClip(); Error Messages
The most common error message is something like this:
Scene=Scene 1, Layer=control, Frame=1: Line 1:
Clip events are permitted only for movie clip instances
onClipEvent(load){
What does it all mean? Let's try and replicate it first.
But in Flash MX we can put the script all in one place which makes it easier to manage and debug. We can do it this way in Flash MX. Put this script in the control layer. Delete any scripts on MovieClips.
_root.onLoad = function(){
// initialise the square mc
_root.square1._x = 100;
_root.square1._y = 100;
// and initialise any other mcs around
_root.square2._x = 140;
_root.square2._y = 100
}
Recommended Book |
|
||||||||||||||
|
| Home | Flash MX | Actionscript 2.0 | Flash 3D | Flash 8 | Flash Database | Flash Mobile | Flash CS3 | Java For Kids | Video Course | General Video | Photoshop | Web Design | Digital Photography | Forum | Games | free backgrounds | Resume | Flash Animations | Streaming Video | Students Work | Links | Contact me | sitemap | reviews | store | advertisers | . . |
||||||||||||||||