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 4)
 
January 4, 2009
 
   
page 1, page 2, page 3, page 4, page 5  
   

(for the following example flash files, we have reduced the stage size to 150x150 pixels)

Save the project file: (top menu bar) File >> Save.

Test the Movie file: (top menu bar) Control >> Test Movie.

Two windows should pop, as usual, the output text window, and the flash movie, with a rotating test object:

The rotating test object appears pixelated, since smoothing has not been turned on. The following will fix this:

in the library list, right-click on: test_image.png

>> Properties >> check >> Allow smoothing >> OK

Testing the movie file again, we should see a smoother rotating object:

 

(Method II )

Moving on with method 2, we begin as before by importing an image into the library:

Add the following image: test_image_2.png, to the \images directory:

test web image 1

(right-click on the image above, and
save the image to the
\images directory)

Then import it into the library:

from the drop down menus:

File >> Import >> Import to Library >>  

 locate the image file >> open

The next step is different from method 1. Here we create a script file for the class that will control the new symbol before placing the image onto the stage.

In the scripts directory, create a file and call it: Test_Object_2.as

\skeleton_v1\scripts\Test_Object_2.as

Open it up in the authoring tool:

from the drop down menus:

File >> Open >>  

 locate the script file: Test_Object_2.as

>> open

Then add the following lines to the new script file:

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

      public class Test_Object_2 extends MovieClip
      {
            public var base_x;

            public function Test_Object_2()
            {
                  trace ('Test object 2 is alive.');
                  addEventListener(Event.ENTER_FRAME, enter_frame);
                  this.x = base_x = 75;
                  this.y = 125;
            }

            public function enter_frame(ee:Event)
            {
                  this.rotation += 0.5;
                  this.x = base_x + 40 * Math.cos( this.rotation/10 );
            }

      }
}

The enter_frame() function for this object shows that it will rotate about its center ( this.rotation += 0.5; ), and move side to side based on a cosine function ( this.x = base_x + 40 * Math.cos( this.rotation/10 ); ).

 

continued on page 5

 

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