Hey guys, I’m working on an interactive animation for a university assignment. Here in this scene the user is able to turn a safe dial left and right either using on screen buttons or keyboard keys. The trouble I’m having is trying to write an IF statement to detect the angle of the safe dial so when the dial == an angle of rotation the scene goes on to play the next frame of the animation.
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.media.Sound;
stop();
left.addEventListener(MouseEvent.CLICK, leftTurn);
right.addEventListener(MouseEvent.CLICK, rightTurn);
stage.addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown);
dial.addEventListener (Event.ENTER_FRAME, rotationAngle);
var mySnd:Sound = new click1();
function leftTurn(event:MouseEvent){
dial.rotation -= 3.6;
mySnd.play();
}
function rightTurn(event:MouseEvent){
dial.rotation += 3.6;
mySnd.play();
}
function reportKeyDown(event:KeyboardEvent):void{
if (event.keyCode == Keyboard.LEFT){
dial.rotation -= 3.6;
mySnd.play();
}
if (event.keyCode == Keyboard.RIGHT){
dial.rotation += 3.6;
mySnd.play();
}
}
//If dial == angle of rotation go to and stop frame 2
function rotationAngle (event:Event){
if (dial.rotation == 36) {
gotoAndStop(2);
}
}
Any help with final IF statement would be much appreciated, it works using < and > symbols but not ==. I’ve spent about 5 hours trying to figure this out with no success. Many thanks.