Flash Actionscript

Shooting the Missiles Using Action Script on Flash 3.0


Step 1: Open a new document in flash. Set the stage color as black.
Step 2: Choose Window > Properties from the main menu bar to open the PROPERTIES panel.
Step 3: Expand the Properties section in the panel and choose the Edit button to enlarge the Document Settings window. Next, set the width to 550 px and height to 450 px in the PROPERTIES panel, as shown in Figure below. Choose the Ok button.

image-2285

 

 

 

 

 

 

 

 

Step 4: import an image to perform the action script. Choose File > Import > Import to stage from the main menu bar and Import the unzipped images file. The three files will be imported to the stage, as shown in Figure below.

image-2286

 

 

 

 

Step 5: Perform some actions to this image. From the timeline create new layer to the name them as figure follows

image-2287

 

 

 

 
Step 6: Now we will use some action script. To make the thumbnails function and to rotate them around the main image.
Code 1:

image-2288

Code 2:

image-2289

Code 3:

image-2290

Code 4:

image-2291

Code 5:

image-2292

Code 6:

image-2293

Code 7:

image-2294

Tags: , , , , ,

Shake Effect on Action Script Using Flash 3.0

Step 1: Open a new flash file. Choose Window > Properties from the main menu bar to open the PROPERTIES panel.
Step 2: Expand the Properties section in the panel and choose the Edit button to enlarge the Document Settings window. Next, set the width to 550 pixels and height to 300 pixels in the
PROPERTIES panel, as shown in Figure below. Choose the Ok button.

image-2266

 

 

 

 

 

 

Step 3: Now we need to draw an oval for masking. Select the Oval tool from tools. Draw an circle in the document.

image-2267

 

 

 

 

 

 

 

Step 4: Fill the color (#99FFFF) inside the oval. And name the document on left-top as shake effect on Action Script.

image-2268

 

 

 

 

 

 

 

 

 

Step 5: Place the button on the document and give instance name it Reset as figure shown below.

image-2269

 

 

 

 

 

 

 

 

Step 6: Create a timeline for layer 1 and name it as player.

image-2270

 

 

 

 

Step 7: Create another layer for controlling effects and named it as controls. And for frame select the rectangle tool from toolbar.

image-2271

 

 

 

Step 8: Create a fourth layer for Performing Action Script.

image-2272

 

 

 

 

Step 9: Type the following Action Script in Layer-4(Action Script).

image-2273

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 10: Import shake effect images to library. Images name should be same as in library and script. Go to library panel and right click on each image. Choose Properties à Linkage. Check the “Export for Action script” option. And run the program.

Tags: , , , , ,

Floating Gallery Using Flash Cs4


Step 1: open a new flash file. Set the width to 600 pixels and the height to 540 pixels. For this pictorial we need 8 images. We have to resize them with 330*330 for the main image and 75*75 thumbnail images. Name the images image-0 to image-7 and thumb-0 to thumb-7 and then import them into the library (File-> import->import to library).

image-2172

 

 

 

 

 

 

 

 

Step 2: By using oval tool (O) to creating a dark grey circle (#323232) circle, without an outline by using dimensions and positions below. I have reduced the magnification in Flash to 50%, so that it’s easier to see.

image-2173

 

 

 

 

 

 

 

 

 

 

Step 3: To convert the oval into an MOVIE CLIP (Movie Clip Symbol) called “background”, by pressing F8.

image-2174

 

 

 

 

 

 

 

 

Step 4: Convert this Movie Clip into another one called “gallery” and then, from the properties panel, give it the instance name “gallery”. After that action script will be used to give the gallery some functionality and the instance names given to the MOVIE CLIP’s will be used to reference them.

image-2175

 

 

 

 

 

 

 

Step 5: Double click on the “gallery” movie clip and then on the “background” movie clip. Name the layer with the dark oval “background 1”. Create the second layer called “background” and with the lighter grey (#505050) oval on this layer.

image-2176

 

 

 

 

 

 

 

 

 

 

 

Step 6: From the properties panel, set the dimensions and positions, as shown below.

image-2177

 

 

 

 

 

 

 

 

 

 

 

Step 7: Next, drag image 0 onto the “images” layer as shown below. Convert the image to a Movie Clip (F8) called “image0”, selection “export for action script”. This will allow the image to be attached with action script, using the “identifier” as a reference.

image-2178

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 8: Convert the Movie Clip again (F8) into another Movie Clip called “image Holder”.

image-2179

 

 

 

 

 

 

 

 

Step 9: Use the Oval Tool to create an oval on the mask layer, setting it to have the dimensions and positions as shown below. Right click on the mask layer and choose “mask”.
Fig (a):

image-2180

 

 

 

 

 

 

 

 

 

 

 

 

 

Fig (b):

image-2181

 

 

 

 

 

 

 

 

 

 

Step 10: The circle should now be masking the image, as shown below.

image-2182

 

 

 

 

 

 

 

 

 

 

Step 11: Now we are going to create a temporary guide which will be used to place the thumbnails. Create a new layer called “guide” and see the Oval Tool to create a circle with just the stroke color and no fill. Set the dimensions and positions as figure shown below.

image-2183

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 12: Convert the ring into a Movie Clip (F8) called “guide”.

image-2184

 

 

 

 

 

 

 

 

Step 13: Double click on the MOVIE CLIP, create a new layer and draw a line, using the dimensions and positions as figure shown below.

image-2185

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 14: Create a vertical line on another new layer as figure shown below.

image-2186

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 15: Now copy the 2 lines onto a single new layer.

image-2187

 

 

 

 

 

 

 

 

 

 

 

Step 16: Open the transform panel and set “rotate” to 45 degrees.

image-2188

 

 

 

 

 

 

 

 

Step 17: Now, create a new MOVIE CLIP (Insert > New Symbol) called “thumb0” and create 2 layers called “image” and “mask”. Drag the thumbnail thumb_0 on to the “image” layer, placing it at the position shown below.

image-2189

 

 

 

 

 

 

 

 

 

 

Step 18: Create a circle on the “mask layer”

image-2190

 

 

 

 

 

 

 

 

 

 

Step 19: Right click on the “mask” layer and chose “mask”.

image-2191

 

 

 

 

 

 

 

 

Step 20: Convert the mask into an MC (F8) called thumbMask. You can reuse this MC for the other thumbnails.

image-2192

 

 

 

 

 

 

 

 

 

Step 21: Create a dark grey (#404040) circle on a layer below the image and mask, using the positions and dimensions shown below.

image-2193

 

 

 

 

 

 

 

 

 

 

 

Step 22: This will also be reused for the other thumbnails, so convert it to an MC called “thumbBG”. So, that’s the 1st thumbnails created, now create the other 7, using steps 18 – 23.

image-2194

 

 

 

 

 

Step 23: Next, create a layer called “thumbs” and drag thumb0 MC onto the stage, positioning it at the top over the guide. From the properties panel, give it the instance name “thumb0”.

image-2195

 

 

 

 

 

 

 

 

 

 

 

 

Step 24: Convert thumb0mc into another MC called thumb Holder. Set the registration point (circled in red) to the center. To rotate the thumbnails with action script, the thumb Holder MC will be rotate so that each thumbnail doesn’t have to be rotated individually. Setting the registration point to the center makes sure the MC will rotate from the center.

image-2196

 

 

 

 

 

 

 

 

 

 

Step 25: Add all 8 of the thumbnails where the lines intersect with the ring. Place thumb1 at the second point, thumb2 at the 3rd, and so on.

image-2197

 

 

 

 

 

 

 

 

 

 

Step 26: When all the thumbnails have been added, go back to the Gallery Movie Clip and give the thumb Holder MC the instance name “thumb Holder”.

image-2198

 

 

 

 

 

 

 

 

 

 

Step 27: Then the image Holder MC and delete the image MC inside of it. This is because we will be adding the image dynamically with action script.

image-2199

 

 

 

 

 

 

 

 

 

 

Step 28: Now we are going to create a gallery with rotating thumbnails. We will now use some action script. To make the thumbnails function and to rotate them around the main image.
Step 29: Code Explanation:
Line 1: A stop() function to stop it from looping
Line 2: A variable to hold the number of images in the gallery
Line 3: A boolean variable which is used to pause / unpause the gallery

image-2200

 

 

Step 30: Code Explanation:
Line 6 – 7: A for loop is created to assign each thumbnail a property containing the name of it’s corresponding image. The “i” in the loop will start off at 0 and increment by 1 (i++), while i is below 8 (i Line 8: Now that we are storing “thumb4” in “t”, we give it the property “image” and assign it to hold image4 (“image”+i)

image-2201

 

 

Step 31: Code Explanation:
Line 9: An onPress function is create for each thumbnail
Line 10: The last displayed image will be held in current, so we use this function to remove it before the new one is attached (line11), upon pressing the thumbnail
Line 11: We use the t.image property to attach the image to “imageHolder” MC. t.image is refered to as this.image because it’s being called from withing an onPress function.
Line 12: When a thumbnail is rolled over with the mouse, the gallery will be pause (see next step), but when the thumbnail is pressed, we want them to start rotating again, so we set “pauseGallery” to equal false.

image-2202

 

 

 

Step 32: Code Explanation:
Line 14 – 16: “pauseGallery” is set to equal true when the thumbnail is rolled over.
Line 17 – 20: “pauseGallery” is set to equal false when the thumbnail is rolled out.

image-2203

 

 

 

 

Step 33: Code Explanation:
Line 21: When the gallery start image0 is attached to be displayed.
Line 22: An onEnterFrame function is created which will execute any code inbetween the braces {} repeatedly, at the frame rate (30) of the movie.
Line 23: Another loop is used to rotate each thumb counter clockwise with 0.5 degrees. This needs to be done because when the thumbnail holder is spinning round (line 27) the thumbnails will stop being upright.
Line 25: Last we rotate the thumbHolder by 0.5 degreess. You can change the value of this and line 27 to increase or decrease the speed of the rotation.

image-2204

 

 

 

 

 

Step 34: the final code is

image-2205

Tags: , , , , , , , ,

Masking The Images On Action Script Using Flash cs4

Step1: open a new flash file. Set the width to 465 pixels and the height to 232 pixels. And set frame rate to 24fps.

image-2130

 

 

 

 

 

 

 

Step 2: By using the rectangle tool draw a rectangle. And import the image for background (file ->import -> import to stage) set as background image.

image-2131

 

 

 

 

 

 

 

Step 3: Now, we need to place the buttons on left-side of the background image to perform action controls. Import the images from file menu. Place 4 buttons as figure shown below

image-2132

 

 

 

 

 

 

 

Step 4: Name the buttons for its relevant actions as shown below

image-2133

 

 

 

 

 

 

 

Step 5: To convert the image into a MOVIE CLIP (Movie Clip Symbol) called “background”, by pressing F8.

image-2134

 

 

 

 

 

 

 

 

 

 

 

Step 6: Now we need to mask the feature for visually cropping display objects within a shape as image shown below.

image-2135

 

 

 

 

 

 

 

 

 

Step 7: To convert the image into a MOVIE CLIP (Movie Clip Symbol) called “background”, by pressing F8.

image-2136

 

 

 

 

 

 

 

 

Step 8: From the cropping image to mask the layer and perform some actionscript towards the masking as image shown below

image-2137

 

 

 

 

Step 9: The image should now be masking the image, as shown below.

image-2138

 

 

 

 

 

 

Step 10: create a timeline to demonstrate the following function.

image-2139

 

 

 

 

Step 11: now we need to focus on second button i.e. mask. The process involves creating a shape and applying it to the “mask” property of another display object.

image-2140

 

 

 

 

Step 12: Masks can stay stationary while the object is being masked move or masks can animate above the object to create transitions and special effects as shown below

image-2141

 

 

 

 

 

Step 13: Now, create a new MOVIE CLIP (Insert > New Symbol) called “thumb0” and create 2 layers called “image” and “mask”. Drag the thumbnail thumb_0 on to the “image” layer, placing it at the position shown below.

image-2142

 

 

 

 

 

 

 

Step 14: then the image will mask the two layers with the movie clip that has been shown in the following image.

image-2143

 

 

 

Step 15: Right click on the “mask” layer and chose “mask”.

image-2144

 

 

 

 

 

 

 

 

 

Step 16: On the mask layer two layers have combined to perform the mask function as figure shown below.

image-2145

 

 

 

 

 

 

Step 17: Then the image Holder MC and delete the image Movie Clip inside of it. This is because we will be adding the image dynamically with action script.

image-2146

 

 

 

 

 

 

Step 18: Then the image Holder MC and delete the image MC inside of it. This is because we will be adding the image dynamically with action script as shown below.

image-2147

 

 

 

 

 

 

Step 19: When all the thumbnails have been added, go back to the Movie Clip and give the thumb Holder Movie Clip the instance name “background”.

image-2148

 

 

 

 

 

 

 

Step 20: Now we need to drag the mask on the right window. By using this drag mask we can able to drag the mouse cursor on the screen as figure shown below.

image-2149

 

 

 

Step 21: Now we need to make spiral movie clip on the right window to mask the two given layer as the figure shown below.

image-2150

 

 

 

 

 

 

 

Step 22: To create the mask frame to function the mask frame on the layer style as figure shown below.

image-2151

 

 

 

 

 

 

 

Step 23: To rotate the thumbnails with action script, the thumb Holder MC will be rotate so that each thumbnail doesn’t have to be rotated individually. Setting the registration point to the center makes sure the MC will rotate from the center. Press F8 to perform the action as figure shown below.

image-2152

 

 

 

 

 

 

Step 24: Setting the registration point to the center makes sure the MC will rotate from the center. Press F8 to perform the action as figure shown below.

image-2153

 

 

 

 

 

 

Step 25: Last layer to perform no function to be done to make the screen idle.

image-2154

 

 

 

 

 

 

 

Step 26: Now we will use some action script. To make the thumbnails function and to rotate them around the main image.
Code 1:

image-2155

 

 

 

 

 

 

 

 

 

 

 

code 2:

image-2156

 

 

 

 

 

 

 

 

 

 

 

 

Code 3:

image-2157

 

 

 

 

 

 

 

 

 

Code 4:

image-2158

 

 

 

 

 

 

 

 

 

 

 

 

Code 5:

image-2159

 

 

 

 

 

 

 

 

There are three types of masks which is displayed above flash file. Click the buttons to see the different effects.

Tags: , , , , ,

Blend Image flash Transition Effect

Follow the steps to complete the tutorial.
1. Open a new flash file. Choose Window > Properties from the main menu bar to open the PROPERTIES panel.
2. Expand the Properties section in the panel and choose the Edit… button to enlarge the Document Settings window. Next, set the width to 500 px and height to 300 px in the
PROPERTIES panel, as shown in Figure below. Choose the Ok button.

image-1930

3. Now we will import the images to be used in this tutorial. Unzip the VMask_tutorial.rar file that you downloaded.
4. Choose File > Import > Import to stage from the main menu bar and Import the unzipped images file. The three files will be imported to the stage, as shown in Figure below.

image-1931

5. The images are not aligned on the stage area. To align them, choose Window > Align from the main menu bar; the ALIGN panel is displayed, as shown in Figure below.

image-1932

6. Next, select all the three images on the stage and select the Align to stage checkbox from the ALIGN panel and choose the second button from left under the Align and the Distribute area. The images will be aligned to the stage.
7. Now, let us distribute these images on different layers. To do so, right click on the images when they are selected and choose Distribute to Layers… from the fly out, the images are distributed in different layers.
8. Next, convert the images into symbols. Select img1.jpg and choose Modify > Convert to Symbol from the main menu bar; the Convert to Symbol window is displayed; as shown in Figure below.

image-1933

9. Name the movie clip symbol as img1 and choose the OK button. The image is converted to movie clip symbol. Similarly, convert img2.jpg and img3.jpg into movie clip symbols.
The movie clip helps to manage a image in a better way. Also, it will help us to apply filters and other effects to the mages in a better way.
10. Set the visibility of img2 and img3 layers to off. Next, select the img1 movie clip and choose Modify > Convert to Symbol from the main menu bar and name the movie clip as masking1.
11. Double-click on the masking 1 movie clip and next create a key frame on frame 30 in the timeline, as shown in Figure below.

image-1934

12. Next, set motion twining between the two key frames. Select the key frame on frame1 and place the img1 movie clip around 30 pixels down from its original place, as shown in Figure below.

image-1935

13. Next, create a new layer and name it as mask 1. Create a rectangle with width 500px and height 60px, as shown in Figure below.

image-1936

14. Select the rectangle and choose CTRL + g to make it as a grouped object. Next, create 4 copies of the rectangle just created and align them to as shown in the Figure below.

image-1937

15. Select all the five rectangle shapes and right click on them and choose Distribute to Layers to distribute them to different layers. Rename the layers as mask1, mask2, mask3, mask4, and mask5.
16. Next, activate the layer named layer1 and rename it to anim1 and select the image movie clip at the first key frame and choose Window > Properties from the main menu bar; the PROPERTIES panel is displayed.
17. Add Adjust Color filter to the selected movie clip and set the following values in its parameters to get and effect as shown in Figure below.
Brightness: 0
Contrast: 50
Saturation: 0
Hue: 180

image-1938

18. Set the alpha to zero for the movie clip on the first frame.
19. Next, create 4 copies of the anim1 layer and rename them as anim2, anim3, anim4, and anim5. Now, make sure that each anim layer is placed below one mask layer, such that the timeline panel looks as shown in Figure below.

image-1939

20. Now, right click on the mask1 layer and choose mask from the fly out. Similarly, set mask for mask2, mask3, mask4, and mask5 layers and align the frames in the timeline to as shown in Figure below.

image-1940

21. Press ENTER and have a look on the masking transition effect. You can tweak the animation as per your needs and requirements.
22. Next, go to the main stage and similar transition effect to the other two images and make a timeline animation to create a photo show transition effect.

Tags: , ,

Sprite Control Using Keyboard in Flash Actionscript

Final Preview:

Use Keyboard Arrow Keys to move up, bottom, left, right.

Step-1 Open a new document in Flash.

Step-2 Create a boy head or whichever you like.

Step-3 Convert it into “movie clip” and name it as “sprite”.

Step-4 Write the following action script in a new layer, Key frame-1.

spriteDirection = 0;

setInterval(function () {

if (Key.isDown(Key.RIGHT)) {

setDirection(0);

_root.sprite._x += 3;

}

if (Key.isDown(Key.LEFT)) {

setDirection(1);

_root.sprite._x -= 3;

}

if (Key.isDown(Key.DOWN)) {

_root.sprite._y += 3;

}

if (Key.isDown(Key.UP)) {

_root.sprite._y -= 3;

}
updateAfterEvent(); }, 10);

action-script-for-sprite
image-1441

Tags: , ,

Request a Free SEO Quote