Flash tutorials
Home 3D (2) Actionscripting (66) Animation (108) Audio (4) Drawing (7) Full flash sites (4) Getting Started (15) Navigation (25) Special Effects (61) Text Effects (38)

Photo information using the Action Script code

29.12.2009, 13:56    Total views: 18944

Using this thoroughly explained, detailed flash lesson, I will explain to you how to create information about any photo using the action script code. Using this lesson, you will also learn how to import any photo into a flash stage, how to convert it into a movie clip symbol, how to create instance name, how to create dynamic text field and much much more! Let's start!

Example:

Move your mouse cursor over a photo to see the information about photo!



Step 1

First, save the photo below that we will use for this lesson.





Step 2


Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as the dimensions of photo (440x330px). Select any color as background color. Set your Flash movie's frame rate to 36 and click ok.



Step 3

Call the current layer photo. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!

Step 4

Choose now File > Import > Import to stage (Ctrl+R) and import the photo that you just saved into a flash stage. While the photo is still selected, go to the Align Panel (Ctrl+K) and do the following:

1. Make sure that the Align/Distribute to Stage button is turned on,
2. Click on the Align horizontal center button and
3. Click the Align vertical center button.



Step 5

While the photo is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.



Step 6

While the new made Movie Clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip "photo_mc". See the picture below!



Step 7

Cretae a new layer above the layer photo and name it toolbar.

Step 8

Select toolbar layer and take the Rectangle Tool (R). In the Colors portion of the Tool panel, block the Stroke color by clicking on the little pencil icon and then on the small square with the red diagonal line. For Fill color choose any color and draw a rectangle shape about 100x20 px which will represent your toolbar. See the picture below.



Step 9

While the toolbar is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.See the picture below.



Step 10

While the new made Movie Clip (toolbar) is still selected, go again to the Properties Panel (Ctrl+F3).On the left side, You will find the Instance name input field there. Call this Movie Clip(toolbar) toolbar_mc. See the picture below.



Step 11

Double-click on the movie clip (toolbar) on stage with the Selection tool(V).You should now be inside the Movie Clip.



Step 12

After that, create a new layer above the layer 1 and name it content.

Step 13

Select the content layer and take the Text tool (T). Then, go to the Properties Panel (Ctrl+F3) below the stage, and select the following options:

a) Select a Dynamic Text field.
b) Select a Trebuchet MS font.
c) Choose 14 as font size.
d) Select white color.
e) As the rendering option, select Anti - alias for readability.

Then, create the dynamic area over the toolbar. See the picture below.



Step 14

Then, go again to the Properties Panel (Ctrl+F3) and for Instance Name type text. See the picture below.



Step 15

After that, type in dynamic area Pussycat Dolls. See the picture below.



Step 16

Go back on the main scene (Scene 1).



Step 17

Then, move the toolbar somewhere out of stage. See the picture below.



Step 18

It's time for action script code, so create a new layer above the toolbar layer and name it action script.

Step 19

Click on the first frame of layer action script and go to the Action Script Panel (F9). Then, enter the following action script code inside the actions panel:

toolbar_mc._visible = false;
letter_width=6;

funk_toolbar_mc = function (flag, toolbar_mc_text) {
 
 if (flag) {
  
  createEmptyMovieClip("control", this.getNextHighestDepth());
  toolbar_mc.text.text = toolbar_mc_text;
  toolbar_mc._width =letter_width*toolbar_mc.text.text.length;
  
 
  control.onEnterFrame = function() {
   if ((_root._xmouse+toolbar_mc._width)>Stage.width) {
    d_x =-10-toolbar_mc._width;
   }
   else {
    d_x=80;
   }
   if ((_root._ymouse-toolbar_mc._height)<0) {
    d_y =toolbar_mc._height;
   }
   else {
    d_y=0;
   }
   
   toolbar_mc._x = _xmouse+d_x;
   toolbar_mc._y = _ymouse+d_y;
   toolbar_mc._visible = true;
  }
 } else {
  toolbar_mc._visible = false;
  delete control.onEnterFrame;
 }
}

photo_mc.onRollOver=function() {
  _root.funk_toolbar_mc(true, "Pussycat Dolls");
}
photo_mc.onRollOut=function() {
  _root.funk_toolbar_mc(false);
}

We're done!

Test your movie and enjoy!

Download source file (.fla)

Have questions about this tutorial?
Visit our friendly Community Forums!
Digg it! Add this tutorial to del.icio.us! Furl it! Add this tutorial to reddit! Spurl it! Add this tutorial to technorati!

Top tutorials

1. Advanced full flash site - Part 1
Total views: 310287

2. High-tech city animation
Total views: 272904

3. Water effect
Total views: 237059

4. Photo slide show
Total views: 220388

5. Special Picture Effect
Total views: 190723



Related links