home
faq
how to
sitemap
contact
 
 

How to create a starter skeleton project
in Adobe flash using ActionScript 3.0.

part II

 
   
A basic tutorial for importing images, and
adding objects to an Adobe flash file.
 
(page 3)
 
January 4, 2009
 
   
page 1, page 2, page 3, page 4, page 5  
   

Next, left-click on the image's icon in the library and drag test_image_1.png onto the stage.

Then convert the image on the stage to a symbol:

right-click on the image on the stage >> Convert to Symbol

to open up the symbol's properties menu.

Then, set the symbol's properties:

set Name: to: Main_Object  

set Registration: to: the center,

or whatever corner you wish to define the movieclip's center of rotation. (the location for the Registration can also be changed later).

Finally, set the Instance Name for this new MovieClip:

In the properities box below the stage:

fill in the: <Instance Name>
with the scripting variable name:
main_object_1

This will be the variable name that is used in the Main_Class script.

At this point the authoring tool should look like this:

flash cs3 screenshot pt2 2

(click to enlarge)

Now we are ready to add some code to the Main_Class script that will control the new MovieClip.

Click on the tab for the script file: Main_Class.as, and modify it so that it looks like the following:

package
{
      import flash.display.MovieClip;
      import flash.events.*

      public class Main_Class extends MovieClip
      {
            public function Main_Class()
            {
                  trace ('Hail and well met, traveling Selenite.');

                  addEventListener(Event.ENTER_FRAME, enter_frame);
            }

            public function enter_frame(ee:Event)
            {
                  main_object_1.rotation += 0.5;
            }
      }
}

The only new lines that were added are:

    import flash.events.*
...
    addEventListener(Event.ENTER_FRAME, enter_frame);
...
    public function enter_frame(ee:Event)
    {
        main_object_1.rotation += 0.5;
    }

The above new function: enter_frame() will execute when the event: ENTER_FRAME happens. And so, this allows us to add some functionality to the symbols on the stage. In this particular case we have set up the instance main_object_1 to constantly rotate about its center.

 

continued on page 4

 

page 1, page 2, page 3, page 4, page 5

 
   
dark maelstrom icon dark maelstrom
flash games
  t-shirt icon dark maelstrom
t-shirt designs

  purple bitcoin icon 1NempEdpogR6XB6QUky9wAd7HjaAy9M5ts  
 
   

back

home