RSS twitter

Archive for the ‘Flash CS4, flash cs4 tutorials, flash cs4 how to’ Category.

AS3 mouse follow

  • Create New Flash File ActionScript 3.0
  • Select the Selection Tool V
  • Go to Properties tab and press Edit button and set the width of your document to 400 pixels and the height to 300 pixels.
  • Set the frame rate FPS to 30.
  • Change the layer name to background ( double click on it ).
  • Select the rectangle tool and create a 400×300 sized rectangle without any stroke.
  • Align it to the center of the stage ( Ctrl+k).
  • Now add a radial fill for the rectangle as follow in the picture below.
  • Create a new layer and change the name to “follower”.
  • In the follower layer draw a white cirle without any stroke and size 25×25.
  • Convert the circle to a movie clip with as follow in the picture below.
  • Change the Instance Name to “follower”.
  • Create the last  layer and change the name to “as3″
  • Press F9 to open AS3 panel.
  • Copy / Paste the following code:

Step 2

Step 3

Download the source: as3mousefollower.zip

Flash CS menu tutorial

Download TweenMax for AS3 and save the “gs” folder to the same location where you have the .fla file located.

Step 1

  • Create a new >Flash Project
  • Click on the plus icon New flash file > “Flash file” > Change the name of project <Untitled File>.fla
  • Select the Selection Tool V
  • Go to Properties tab and press Edit button and set the width of your document to 400 pixels and the height to 100 pixels, set frame rate to 30 fps.
  • Select ” black” color as background .
  • Change the layer name to menu ( double click on it ).

Step 2

  • Draw a rectangle on the stage with the following properties.
  1. width: 8px
  2. height: 8px
  3. stroke color: no stroke!
  4. Fill color: #FF8800

Step 3

  • Convert the rectangle to a movie clip (select the rectangle and hit F8).
  • Change the Name to “Menu Rectangle” and set the registration point to the center.
  • Link the rectangle to a class named “MenuRectangle”.

Step 4

  • For each menu item  we need  to have multiple menu rectangles.
  • Drag 7 more menu rectangles to the stage (you should now have a total of 8 menu rectangles on stage).
  • Align them horizontally and space them evenly.
  • You can use the align functionality to help you out.

Note that you should not have the “To stage” button selected when you space the rectangles evenly.

  • Select all the eight (8) menu rectangles, hold down the Alt-key and and drag-and-drop the new menu rectangles below the first row.
  • Create a third row as well.
  • You should now have a rectangle matrix of sixe 8×3 (8 colums and 3 rows).

Step 5

  • To Create first button select all the menu rectangles and convert them to a single movie clip.
  • Name it “Home Button” and set the registration point to the center.

  • While inside the movie clip, select all the menu rectangles and set the alpha to 30%.

  • While still inside the home button movie clip, create a new layer named “text”.

  • In the text layer, create a static text field and type “Home” in it.
  • Position the text field on top of the menu rectangles and size it so that it covers most of the rectangles area.
  • Set the following properties.
  1. font: Berlin Sans
  2. size: 14 pt
  3. color: white
  4. format: center
  • While still inside the home button movie clip, create a new layer named “hit area”.

  • In the hit area layer, draw a white rectangle so that it covers all the menu rectangles.
  • Convert the rectangle to a movie clip.
  • Name it “Hit Area” and set the registration point to the center.

  • Give the hit area movie clip an instance name of “mouseArea”.
  • We don’t want the hit area to be visible, its only function is to catch mouse events via ActionScript.
  • Set the alpha to zero for the hit area (color effect).
  • While still inside the home button movie clip, create a new layer named “actions”.

Step 6

So in the actions layer, type the following.

//Import TweenMax
import com.greensock.*;

//This array will contain all the rectangles
var rectangles:Array = new Array();

//Loop through the items in this movie clip
for (var i:uint = 0; i < this.numChildren; i++) {

//Get an object
var object:* = this.getChildAt(i);

//Check to see if the object is a MenuRectangle
if (object is MenuRectangle) {

//Save the rectangle’s coordinates (we need these later on)
object.origX = object.x;
object.origY = object.y
;

//Add the rectangle to the rectangles array
rectangles.push(object);
}
}

//Add mouse listeners for the mouse area
mouseArea.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
mouseArea.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
mouseArea.addEventListener(MouseEvent.CLICK, itemClicked);

//This function is called when the cursor is over the mouse area
function mouseOverHandler(e:Event):void {

//Loop through the rectangle array
for (var i:uint = 0; i < rectangles.length; i++) {

//Assign the rectangle to a local variable
var rectangle:MenuRectangle = rectangles[i] as MenuRectangle;

//Calculate random target coordinates for the rectangle
var randomX:Number = rectangle.x + 10 * Math.cos(Math.random() * Math.PI * 2);
var randomY:Number = rectangle.y + 10 * Math.sin(Math.random() * Math.PI * 2);

//Animate the rectangle to the random coordinates
TweenMax.to(rectangle, 0.4, {x: randomX, y: randomY, alpha: 0.6, tint: Math.random() * 0xffffff});

}

//Add an ENTER_FRAME listener for the shake effect
addEventListener(Event.ENTER_FRAME, shake);
}

//This function is called when the cursor moves out of the mouse area
function mouseOutHandler(e:Event):void {

//Loop through the rectangle array
for (var i:uint = 0; i < rectangles.length; i++) {

//Assign the rectangle to a local variable
var rectangle:MenuRectangle = rectangles[i] as MenuRectangle;

//Tween the rectangle to the original position
TweenMax.to(rectangle, 0.4, {x: rectangle.origX, y: rectangle.origY, rotation: 0, alpha: 0.3, tint: 0xff8800});
}

//Remove the ENTER_FRAME listener (we don’t want to shake the rectangle anymore)
removeEventListener(Event.ENTER_FRAME, shake);
}

//This function is called when the mouse area is clicked
function itemClicked(e:Event):void {

//Navigate to some URL
var urlRequest:URLRequest = new URLRequest(“http://www.flashconf.com”);
navigateToURL(urlRequest);
}

//This function is called in each frame
function shake(e:Event):void {

Download the source of this project: FllashMenu.zip

Flash movie with transparent background

How to use  Publish Settings feature in Flash. The Publish Settings dialog box provides an option to affect the WMODE setting. The options selected in the Publish Settings will be added to the HTML source code automatically:

  1. Select the File menu
  2. select Publish Settings ( Ctrl+Shift+F12)
  3. Select the HTML (.html) option
  4. Click the HTML tab
  5. Select the Window Mode menu
  6. Select Transparent Windowless (setting to make the Flash movie’s background disappear in browsers which support this feature.)
  7. Click Publish
  8. Click Ok.

Editing HTML code manually

To edit an existing HTML page, add the WMODE parameters to the HTML code.

  1. Add the following parameter to the OBJECT tag:
     <param name="wmode" value="transparent"> 
  2. Add the following parameter to the EMBED tag:
     wmode="transparent" 

How to create a flash animation tutorial

Download the source effect.zip
Step 1

  • Create a new flash Project ,
  • New flash file > Document (shortcut key: Ctrl+J ). Set the width of your document to 300 pixels and the height to 300 pixels.
  • Select any color as background color and set your Flash movie’s frame rate to 33 fps.
  • Change the layer name to Image
  • Import your Photo: File > Import > Import to stage (Ctrl+R) and import any photo into a flash stage. Ctrl+K and check this 3 steps.
  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.
  • While the image or object is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

  • Now click on frame  50 and press F6 key.

Step 2

  • Go to first frame and select the Free Transform Tool (Q) and drag it (decrease it) see the picture below.

Step 3

  • Select the Selection Tool (V) and click once on the image to select it.
  • Go to:  Properties Panel -> Filters tab -> Click on the add icon and select the Blur filter . Make the adjustments as follow in the picture below.

Step 4

Now the last step, right click anywhere on the gray area between the frame 1 and 55 on the timeline and choose Create Motion Tween.

Flash glowing text tutorial

Download the source file : textglow.zip

Step 1

  • Create a new flash Project ,
  • New flash file > Document (shortcut key: Ctrl+J ). Set the width of your document to 300 pixels and the height to 180 pixels.
  • Select any color as background color and set your Flash movie’s frame rate to 25 fps.
  • Change the layer name to Image
  • Import your Photo: File > Import > Import to stage (Ctrl+R) and import any photo into a flash stage.
  • Create a new layer above the layer image and name it text .
  • Now Select the Text Tool (T) and type any text on flash stage.
  • While the Text   is still selected, press F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

  • While the new made Movie Clip is still selected, go to the Properties Panel 0n the right side (up) and change the Instance name input field to flash_text

Step 2

  • Select the first frame of layer text and go to the AS panel (F9) and paste this code:

import flash.filters.GlowFilter;
var gf:GlowFilter = new GlowFilter(0xbe1313, 100, 2, 5, 3, 3, false, false);
flash_text.filters = [gf];
flash_text.onRollOver = function() {

this.onEnterFrame = function() {

if (gf.blurX < 10) {

gf.blurX++;
gf.blurY++;

} else {

delete this.onEnterFrame;

}
this.filters = [gf];

};

};
flash_text.onRollOut = function() {

this.onEnterFrame = function() {

this.filters = [gf];
if (gf.blurX > 3) {

gf.blurX–;
gf.blurY–;

} else {

delete this.onEnterFrame;

}

};

};

FLash image zoom tutorial

Download the source zoom.zip

Step 1

  • Create a new flash Project ,
  • New flash file > Document (shortcut key: Ctrl+J ). Set the width of your document to 400 pixels and the height to 250 pixels.
  • Select any color as background color and set your Flash movie’s frame rate to 37 fps.
  • Change the layer name to Image
  • Import your Photo: File > Import > Import to stage (Ctrl+R) and import any photo into a flash stage. Ctrl+K and check this 3 steps.
  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.
  • While the image or object is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

  • Now click on frame 30,40,50 and 60 and press F6 key.

Step 2

  • Go to frame 60 and select the Free Transform Tool (Q) and drag it (decrease it) see the picture below.

Step 3

  • Select the Selection Tool (V) and click once on the image that you just decrease.
  • Go to:  Properties Panel -> Filters tab -> Click on the add icon and select the Adjust Color filter. Make the adjustments as follow in the picture below.

  • Go back on the first frame and repeat Step 3 and Step 2.

Step 4

  • Go to frame 40, select  the Free Transform Tool (Q) and enlarge the image like in the picture below.

  • Now on frame 40 select the Selection Tool (V) and click on the image
  • Go to:  Properties Panel -> Filters tab -> Click on the add icon and select the Blur filter. Make the adjustments as follow in the picture below.

Step 5

  • Right-click  on the gray area between frame 1 and 30, frame 30 and 40, frame 40 and 50 and frame 50 and 60 on the timeline and choose Create Motion Tween from the menu.

Flash dissolve tutorial

Download the source: dissolve.zip

Step 1

  • Create a new flash Project ,
  • New flash file > Document (shortcut key: Ctrl+J ). Set the width of your document to 300 pixels and the height to 180 pixels.
  • Select any color as background color and set your Flash movie’s frame rate to 32 fps.
  • Change the layer name to Image
  • Import your Photo: File > Import > Import to stage (Ctrl+R) and import any photo into a flash stage.
  • While the image or object is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

  • While the new made Movie Clip is still selected, go to the Properties Panel 0n the right side (up) and change the Instance name input field to Image.

Step 2

  • Create a new layer above the layer image and name it button.
  • Now create a button, type on it Button and convert it into a button symbol.

  • While the new made Movie Clip is still selected, go to the Properties Panel 0n the right side (up) and change the Instance name input field to myButton.

Step 3

  • Create a new layer above the layer button and name it actionscript.
  • Select the first frame of layer action and go to the AS panel (F9) and paste this code:

import fl.transitions.*;
import fl.transitions.easing.*;

DissolveButton.addEventListener(MouseEvent.CLICK, dissolveMyObject);


function dissolveMyObject(event:MouseEvent) {
TransitionManager.start(Image, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Regular.easeIn, xSections:10, ySections:10});
}

Flash blic effect

Download the source: blic.zip

Step 1

  • Create a new flash Project ,
  • New flash file  > Document (shortcut key: Ctrl+J ). Set the width of your document to 300 pixels and the height to 180 pixels.
  • Select any color  as background color and set your Flash movie’s frame rate to 88 fps.
  • Change the layer name to image
  • Import your Photo: File > Import > Import to stage (Ctrl+R) and import any photo into a flash stage.
  • While the image or object is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

  • While the new made Movie Clip is still selected, go to the Properties Panel 0n the right side (up) and change the Instance name input field to Image.

Step 2

  • Create a new layer above the layer image and name it  button.
  • Now create a button, type on it Button  and convert it into a button symbol.

  • While the new made Movie Clip is still selected, go to the Properties Panel 0n the right side (up) and change the Instance name input field to myButton.

Step 3

  • Create a new layer above the layer  button and name it actionscript.
  • Select the first frame of layer action and go to the AS panel (F9) and paste this code:

import fl.transitions.*;
import fl.transitions.easing.*;

myButton.addEventListener(MouseEvent.CLICK, blicMyObject);
function blicMyObject(event:MouseEvent) {
TransitionManager.start(Image, {type:Photo, direction:Transition.IN, duration:1, easing:None.easeNone});
}

Flash rotate actionscript

Download the source rotate.zip

Step 1

  • Create a new flash Project ,
  • New flash file  > Document (shortcut key: Ctrl+J ). Set the width of your document to 400 pixels and the height to 300  pixels.
  • Select any color  as background color and set your Flash movie’s frame rate to 34 fps.
  • Change the layer name to image
  • Import your Photo: File > Import > Import to stage (Ctrl+R) and import any photo into a flash stage.
  • While the image or object is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

  • While the new made Movie Clip is still selected, go to the Properties Panel 0n the right side (up) and change the Instance name input field to Image.

Step 2

  • Create a new layer above the layer image and name it rotate button.
  • Now create a button, type on it Button  and convert it into a button symbol.

  • While the new made Movie Clip is still selected, go to the Properties Panel 0n the right side (up) and change the Instance name input field to myButton.

Step 3

  • Create a new layer above the layer rotate button and name it action.
  • Select the first frame of layer action and go to the AS panel (F9) and paste this code:

import fl.transitions.*;
import fl.transitions.easing.*;

myButton.addEventListener(MouseEvent.CLICK, rotateMyObject);


function rotateMyObject(event:MouseEvent) {
TransitionManager.start(Image, {type:Rotate, direction:Transition.IN, duration:4, easing:Strong.easeInOut, ccw:false, degrees:1080});
}

Flash bevel filter as3

Download the source Bevel.zip

We will learn how to apply Bevel filter using actionscript 3.0

Step 1

  • Create a new flash Project ,
  • New flash file  > Document (shortcut key: Ctrl+J ). Set the width of your document to 300 pixels and the height to 180 pixels.
  • Select any color  as background color and set your Flash movie’s frame rate to 12 fps.
  • Change the layer name to photo
  • Import your Photo: File > Import > Import to stage (Ctrl+R) and import any photo into a flash stage.
  • While the image or object is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

  • While the new made Movie Clip is still selected, go to the Properties Panel 0n the right side (up) and change the Instance name input field to flash_photo.

Step 2

  • Select the first frame of layer photo and go to the AS panel (F9) and paste this code:

import flash.filters.*;

var myBevel:BevelFilter = new BevelFilter();
myBevel.type = BitmapFilterType.FULL;
myBevel.distance = 8;
myBevel.highlightColor = 0xefa4040;
myBevel.shadowColor = 0xc52c2c;
myBevel.blurX = 15;
myBevel.blurY = 15;
flash_photo.filters = [myBevel];