![]() |
![]() |
![]() |
These are all the animals that we included in the animation. ![]() The start page of the animation is a basic tween of the diver going up and down and a simple button to start. |
These two images (above and below) show the information panel that is displayed when an animal is clicked on. The information slides in from the side via tweening.
![]() |
![]() |
This is the main ActionScript that I used in the animation:
stop();
import flash.filters.*;
var blockArray:Array = new Array();
var fishArray:Array = new Array();
//var test:Number=0
var diffX:int = 0;
var diffY:int = 0;
var maxSpeed:int = 35;
var working:Boolean = true;
var whichFish:Number = 2;
info_bg.visible = false;
stage.addEventListener(Event.ENTER_FRAME, mainScript);
//Hide the mouse;
//Mouse.hide();
function mainScript(myevent:Event):void
{
if (working == true)
{
if (mouseX > 375 && mouseX < 750 && mouseY > 10 && mouseY < 480)
{//greater than x position of arm - mustn't be less
diffX = mouseX - rightHand.x;
//To convert it to a percentage
var percX:Number = diffX / rightHand.x;
//Finally moving it based on the percentage
rightHand.x += percX * maxSpeed;
diffY = mouseY - rightHand.y;
//To convert it to a percentage
var percY:Number = diffY / rightHand.y;
//Finally moving it based on the percentage
rightHand.y += percY * maxSpeed;
}
{
if (mouseX < 375 && mouseX > 10 && mouseY > 10 && mouseY < 480)
{//greater than x position of arm - mustn't be less
diffX = mouseX - leftHand.x;
//To convert it to a percentage
percX = diffX / leftHand.x;
//Finally moving it based on the percentage
leftHand.x += percX * maxSpeed;
diffY = mouseY - leftHand.y;
//To convert it to a percentage
percY = diffY / leftHand.y;
//Finally moving it based on the percentage
leftHand.y += percY * maxSpeed;
}
}
blacktip.addEventListener(MouseEvent.CLICK, fish2click);
function fish2click(event:MouseEvent):void
{
info_bg.visible = true;
info_bg.play();
whichFish = 2;
working = false;
}
LoggerheadTurtle.addEventListener(MouseEvent.CLICK, fish3click);
function fish3click(event:MouseEvent):void
{
info_bg.visible = true;
info_bg.play();
whichFish = 3;
working = false;
}
clownfish.addEventListener(MouseEvent.CLICK, fish4click);
function fish4click(event:MouseEvent):void
{
info_bg.visible = true;
info_bg.play();
whichFish = 4;
working = false;
}
lion_fish.addEventListener(MouseEvent.CLICK, fish5click);
function fish5click(event:MouseEvent):void
{
info_bg.visible = true;
info_bg.play();
whichFish = 5;
working = false;
}
pufferfish.addEventListener(MouseEvent.CLICK, fish6click);
function fish6click(event:MouseEvent):void
{
info_bg.visible = true;
info_bg.play();
whichFish = 6;
working = false;
}








No comments:
Post a Comment