ActionScript 3.0

This is the new version of ActionScript and is different to any previous versions, as some of the commands that I wanted to achieve in this piece of work were different, so therefore I had to do some research and read some tutorials on how to get the effects that I wanted.

Drag And Drop

The first effect that I wanted to incorporate was the Drag and Drop capability of the different spare parts for the robot, this process was simpler than I first thought as it only requires a short amount of code to do,

There are several different ways to get the same effect, but some of them have problems with frame rates etc.. so I found one that was smooth and easy to manipulate, the code as shown below, simply says, when movie clip is clicked pick up and drag and when the mouse is let go drop it, this can be applied to any of the movie clips by simply giving the movie clip an instance name and including this in the ActionScript, this code is shown below:

eyeclosed2_mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
eyeclosed2_mc.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

function mouseDownHandler(evt:MouseEvent):void {
var object = evt.target;

object.startDrag();
}

function mouseUpHandler(evt:MouseEvent):void {
var obj = evt.target;
obj.stopDrag();
}

Another thing that I used ActionScript for was to give a movie clip a link to another scene that was in my fla file, in this case I wanted the button at the top to link to the scene with the animation on it, this was also done very simply and again only required a small amount of code as shown below:

open_mc.addEventListener(MouseEvent.CLICK, nextscene);

function nextscene (evt:MouseEvent):void {
gotoAndStop(1,"Animation");
}

This basically says when "open_mc" is clicked go the 1st frame of the "Animation" scene and stop there

This completes the ActionScript for the Drag and Drop scene next I will talk about how the character was animated with his walking cycle and how the Grow and Stop buttons work.

No comments:

Post a Comment