You are on page 1of 8

MOVEING MOVIE UP,DOWN,LEFT,RIGHT AND DIAGONALLY.

onClipEvent (load) { // declare and set speed variable speed = 5; } onClipEvent (enterFrame) { // move up, down, left, or right if (Key.isDown(Key.LEFT) && !Key.isDown(Key.RIGHT)) { _x -= speed; _rotation = 270; } if (Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT)) { _x += speed; _rotation = 90; } if (Key.isDown(Key.UP) && !Key.isDown(Key.DOWN)) { _y -= speed; _rotation = 0; } if (Key.isDown(Key.DOWN) && !Key.isDown(Key.UP)) { _y += speed; _rotation = 180; } // // move diagonally if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.DOWN)) { _rotation = 315; } if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.DOWN)) { _rotation = 45; } if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.UP)) { _rotation = 225; } if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.UP)) { _rotation = 135; } // // loop to opposite side of the masked area when the beetle travels offscreen if (_y<0) { _y = 900; } if (_y>900) { _y = 0; } if (_x<0) { _x = 900; } if (_x>900) { _x = 0; } }

MOVE MOVIE ACCORDING TO DIRECTION SET. onClipEvent (load) { // declare and set initial variables thrust = 1; decay = .97; maxSpeed = 15; } onClipEvent (enterFrame) { // rotate right or left if (Key.isDown(Key.RIGHT)) { _rotation += 10; } if (Key.isDown(Key.LEFT)) { _rotation -= 10; } if (Key.isDown(Key.UP)) { // calculate speed and trajectory based on rotation xSpeed += thrust*Math.sin(_rotation*(Math.PI/180)); ySpeed += thrust*Math.cos(_rotation*(Math.PI/180)); flames._visible = 1; } else { // deccelerate when Up Arrow key is released xSpeed *= decay; ySpeed *= decay; flames._visible = 0; } // maintain speed limit speed = Math.sqrt((xSpeed*xSpeed)+(ySpeed*ySpeed)); if (speed>maxSpeed) { xSpeed *= maxSpeed/speed; ySpeed *= maxSpeed/speed; } // move beetle based on calculations above _y -= ySpeed; _x += xSpeed; // loop to opposite side of the stage when the beetle travels off-screen if (_y<0) { _y = 900; } if (_y>900) { _y = 0; } if (_x<0) { _x = 900; } if (_x>900) { _x = 0; } }

SPACE FIGHTER Draw three layer. On third layer movie clip "f16" have a motion tween . Import two sounds files and link it with name "engin" and "crash". Write first layer code on frame1of frame action. for (i=1; i<25; i=i+1) { _root.rock.duplicateMovieClip(("rock"+i), i); } On layer2 make a movie clip shape like rock and name it "rock" and also instance name "rock". Write code on "rock" movie clip object action. onClipEvent (load) { this._x = random(840); this._y = random(640); this._rotation = random(360); this._alpha = random(50)+50; scale = random(100)+50; this._xscale = scale; this._yscale = scale; xDirection = random(20)-10; yDirection = random(20)-10; } onClipEvent (enterFrame) { this._x = this._x+xDirection+((_root._xmouse+200)/20); this._y = this._y+yDirection+((_root._ymouse-240)/10); if (this._x>840) { this._x = -100; } else if (this._x<-100) { this._x = 840; } if (this._y>640) { this._y = 0; } else if (this._y<0) { this._y = 640; } if (this.hitTest(_root.f16._x, _root.f16._y, true)) { _root.f16.play(); } } On third layer draw f16 shape and convert to movie clip "f16" .this movie clip also have one layer. Write this below code on "f16" object action. onClipEvent (load) { startDrag (this, true, 0, 0, 640, 480); Mouse.hide(); enginSound = new Sound(); enginSound.attachSound("engin"); crashSound = new Sound(); crashSound.attachSound("crash"); } onClipEvent (enterFrame) {

enginSound.setPan((_root._xmouse-320)/3.2); } Movi clip "f16" layer1 write these code on frame1 of frame action. enginSound.start(0,9999); stop (); Write these code on movie clip"f16" layer1 of frame2. enginSound.stop(); crashSound.start(0, 0); write these code on "f16" layer1 of frame13. gotoAndPlay (1);

CLOCK Draw three layers on main time line with three movie clip respectively and named the layer second,minute,hour respectively. On these three layers draw shapes as clock niddles and convert them to movie clip named "sec",:min","hrs",respectivly. enter code on "sec" object action. onClipEvent ( enterFrame ) { // create an instance of the Date object myDate = new Date(); // //rotate clock Hands and shadows this._rotation = myDate.getSeconds()*6; } enter code on "min" object action. onClipEvent (enterFrame) { // create an instance of the Date object myDate = new Date(); // //rotate clock Hands and shadows this._rotation = myDate.getMinutes()*6+(myDate.getSeconds()/10); } enter code on "hrs"object action. onClipEvent (enterFrame) { // create an instance of the Date object myDate = new Date(); // this._rotation = myDate.getHours()*30+(myDate.getMinutes()/2); }

CREATING CURSOR In this tutorial we will create a Global mouse cursor. This cursor is perfect for a Multi scene site or Those who are looking for an alternative to the usual "start drag and hide mouse" script. Before embarking on this tutorial you should have some basic Flash Knowledge. Launch FLASH and make sure your frame rate is at 30fps. You can edit the movie properties by going to Modify>movie . Lets begin... Step 1. We begin by drawing the cursor we would like to use. Begin by drawing something simple. Make sure to fill the shape with a color ( in this case I chose white) other wise our cursor will be transparent. Convert the desired shape into a movie clip by pressing F8 and selecting the movie clip behavior from the symbol properties panel. Step 2. Right click on the newly created movie clip and select edit. Select the shape and position it so that the upper corner of the shape looks like it's "pointing" at the crosshair. Step 3. Click on the scene tab on the upper right hand corner of the screen to return to the main timeline. Step 4. Right click on the cursor movie clip and chose "actions". Copy and paste the following code provided. Then go to File>export. Export the movie as an SWF file. onClipEvent (load){ Mouse.hide(); } onClipEvent (mouseMove) { setProperty (this, _x, _root._xmouse); setProperty (this, _y, _root._ymouse); updateAfterEvent(mouseMove); } Step 5. Open up a new file by going to File>new. Draw out a circle and convert it into a button. Right click on the newly created button and chose "actions". Step 6. Go to basic actions and chose "on mouse event", select "release". Then go to Actions>load movie. Under "URL:" type in the name, or location, of the swf you wish to load. Then chose Level 1 as location. Levels can be thought of as layers, with Level 0 being your Main movie. Once the FLA has been saved to the same folder that u exported the cursor.swf to you can test out the movie.

SHIP FIRING Draw two layers named ship,bullet respectively. Draw two movie clip "ship","bullet" respectively Write below code on movie clip "ship" object action. onClipEvent (load) { startDrag (ship, true); } Write below code on "bullet" object action. onClipEvent (mouseDown) { this.play(); } On movie clip "bullet" draw a motion tween of as bullet on first layer. First frame of layer is blank keyframe, write below code on frame action. stop (); second frame of layer is blank keyframe, write below code frame action. setProperty (_root.l, _x, _root._xmouse); setProperty (_root.l, _y, _root._ymouse); On third layer start motion tween up to layer 5 or more.

MASKING THE PICTURE Draw seven layers on movie. First layer write code below on frme action. second layer draw push button name instance drag. third layer draw push button name instance drag1. fourth layer draw circle, convert to movie clip, name instance c. fifth layer import picture,convert to movie clip.instance nameb1 . sixth layer import picture,convert to movie clip.instance nameflag . seventh layer import picture,convert to movie clip.instance namep . c._visible = false; b._visible = false; b1._visible = false; flag._visible = false; _root.onEnterFrame = function() { with (c) { if (dragging) { _rotation += 5; _x += (_root._xmouse-_x)*.3; _y += (_root._ymouse-_y)*.3; } } }; drag.onPress = function() { p._visible = false; c._visible = true; b._visible = false; b1._visible = true; flag._visible = true; dragging = true; b1.setMask(c); }; drag1.onPress = function() { p._visible = false; c._visible = true; b1._visible = false; flag._visible = true; dragging = true; b._visible = true; flag.setMask(c); };

You might also like