Classes and Functions
First post! Just learning ActionScript 3 so please be gentle and treat me as if I am very dumb.
Alright, wanted to experiment and create a character that moves around, I have the main class and my character class. I have done this once before and had it working but I want to try and keep everything nice and tight. So I tried keeping everything that I want my character to do, inside his class.as file. Then in my main.as file all I would need to do is call him to the stage and remove him when im done with him. Im not getting any errors but nothing is happening at all.
P.S.
I dont know if I am supposed to use the "Insert" function when posting code, and if so there is no "AS3" option, so imma just do it like this.
(Main.as)
package {
import flash.display.MovieClip;
public class Main extends MovieClip {
public function Main () {
var player : mcCharacter = new mcCharacter();
player.x = 20;
player.y = 410;
addChild (player);
}
}
}
(end)
(mcCharacter.as)
package {
import flash.display.MovieClip;
import flash.events.*;
public class mcCharacter extends MovieClip {
public var moveRight:Boolean = false;
public function mcCharacter () {
addEventListener (KeyboardEvent.KEY_DOWN, keyboardPress);
addEventListener (Event.ENTER_FRAME, FrameEvents);
}
public function FrameEvents (event:Event):void {
if (moveRight == false) {
}
if (moveRight == true) {
x = x + 5;
}
}
public function keyboardPress (event:KeyboardEvent):void {
trace (event.keyCode);
if (event.keyCode == 68) {
moveRight = true;
} else {
moveRight = false;
}
}
}
}
(end)
I dont understand whats happening.
ALSO!
I keep hearing that everyone wants flash to go away, and in early 2016 they will release Adobe Animate CC, will they be getting rid of Actionscript? Am I wasting my time doing this? I got interested in Flash because I see alot of content using flash, I would like to become a game developer using Adobe Flash but am I wasting my time?
Thank you anyone who takes the time to read this and gives me feedback, I appreciate you!
