Macromedia Flash Professional 8 UNLEASHED [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Macromedia Flash Professional 8 UNLEASHED [Electronic resources] - نسخه متنی

David Vogeleer, Eddie Wilson, Lou Barber

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Creating Movie Clips


We covered how to create a movie clip manually back in Chapter 5, "Symbols and the Library," but we will review it quickly here.

Creating Movie Clips Manually


To create a Movie Clip symbol manually, follow these steps:


1.

Choose Insert, New Symbol.

2.

In the Create New Symbol dialog box, give the symbol a symbol name, choose Movie Clip as the behavior, and then click OK.

3.

Now you are inside the newly created movie clip.


That was pretty simple; you just created a movie clip manually. Now if you want to use it, drag an instance of it from the library onto the stage and give it an instance name.

NOTE

Although technically you do not need to give every instance of a movie clip object an instance name unless you plan to refer to it with ActionScript, it is good practice to do so. Also remember that you cannot duplicate instance names in the same timeline or errors will occur.

Creating movie clips manually is not the only way to create them. You can also create them on-the-fly with ActionScript.

Creating Movie Clips with ActionScript


Since the MX version of Flash, users have been able to create movie clips with ActionScript. Before then, when you wanted an empty movie clip on the stage, you would have to create one manually, drag it onto the stage, and then give it an instance name.

To create empty movie clips in ActionScript, use the createEmptyMovieClip() method, which looks like this:


movieClip.createEmptyMovieClip(instanceName, depth);

The parameters of this method are as follows:

  • movieClip
    The instance name of the movie clip where the empty clip will be created.

  • instanceName
    This is a string literal that represents the instance name of the movie clip being created.

  • depth
    This is a numerical value that represents the stacking order of the movie clip being created (more on depth later in this chapter).


That is the basic layout of the createEmptyMovieClip() method. The next example shows how to implement it.


1.

Create a new Flash document.

2.

In the first frame of the main timeline, place these actions:


//this refers the main timeline
this.createEmptyMovieClip("sample_mc", 1);

3.

Now test the movie by choosing Control, Test Movie.

4.

Notice that when the movie runs, there isn't anything on the stage. This is because we created an empty movie clip; there is nothing inside it, but you can tell it's there.


When you're in the test movie screen, choose Debug, List Objects, and you should see in the Output panel something similar to Figure 13.1.

Figure 13.1. Using the List Objects option under Debug, you can see the movie clip you created via ActionScript.



/ 318