I've got two Actionscript files linked with one .fla file. The file Document.as is suppose to support the keyboard controls and the mouse controls, whilst the Reset.as is suppose to control the reset of the card (this is an interactive birthday card). I've added this on the 'Reset.as' file, however, when the "reset" button is pressed, nothing happens! None of the images move away, or anything! Am I doing something wrong here? All the files have been given instance names!
Here is the 'Reset.as' code;
package src
{
import flash.events.*;
import flash.display.*;
public class Reset extends MovieClip
{
public function Reset ()
{
mouse();
}
public function mouse()
{
reset.addEventListener(MouseEvent.CLICK, Reset1);
}
public function Reset1(e:MouseEvent) :void
{
aldo.x = -176.80;
aldo.y = 282;
aldoo.x = -322.80;
aldoo.y = 286;
reset.x = -401.75;
reset.y = 328.45;
firework1.x = 100.75;
firework1.y = 545.15;
firework.x = 457.55;
firework.y = 551;
instruction.x = 437.25;
instruction.y = 379;
fade2.x = 132.15;
fade2.y = 433.15
}
}
}
//and here's the 'Document.as' code;
package src
{
import flash.events.*;
import flash.display.*;
public class Document extends MovieClip
{
var speed:int = 20;
var fader:Number = 0.1
public function Document ()
{
init();
}
public function init()
{
button1.addEventListener(MouseEvent.CLICK, onMouseClick);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
}
public function onMouseClick(e:MouseEvent) :void
{
//if cake is clicked, the y axis for instance "instruction", "firework1", "firework" changes
instruction.y = 500;
firework1.y = 100;
firework.y = 100;
//if cake is clicked, the y axis for instance "fade2" changes
fade2.y = 240;
}
public function onKeyDown(e:KeyboardEvent):void
{
//if the right key (arrow key) is pressed,
//the instances "aldo and "aldoo" move positively on the x axis by "5"
//the instance "fade2" (which is "Press and hold the right key") also fades out
//the longer the right arrow key is pressed
if (e.keyCode == 39 && alpha > 0 )
{
aldo.x += speed;
aldoo.x += speed;
reset.x += speed;
fade2.alpha -= fader;
}
//if the left key (arrow key) is pressed,
//the instances "aldo and "aldoo" move negatively on the x axis by "5"
if (e.keyCode == 37 )
{
aldo.x -= speed;
aldoo.x -= speed;
reset.x -= speed;
}
}
}
}