Flash Professional Project, using FLEX 4 to edit code:
I can add the game and player to the stage, but they have no functionality. I don't believe my AS3 code is being used or seen? Is there a conflict between the linkage name in Flash Pro, and the class in the package?
I created the classes via 'edit class' and chose 'flash builder' but they don't seem to be connected. Anyone know what I'm doing wrong. I'm new to FB so it may be a basic setup issue.
FLASH PRO LIBRARY
FLEX DIR
TestGameA.as
Code:
package
{
import gamepack.*;
import flash.display.Sprite;
public class TestGameA extends Sprite
{
public var game:Game;
public var p1:Player;
public function TestGameA()
{
trace("I am TestGameA constructor");
addChild(game = new Game());
game.x = 300;
game.y = 300;
addChild(p1 = new Player());
}
}
}
Game.as
Code:
package gamepack
{
import flash.display.MovieClip;
public class Game extends MovieClip
{
public function Game()
{
trace ("I am Game Constructor");
}
}
}
Player.as
Code:
package gamepack
{
import flash.events.*;
import flash.display.*;
import flash.ui.*;
public class Player extends MovieClip
{
public var pSpeed:Number = 5;
//CONSTRUCTOR
public function Player()
{
trace ("I am Player Constructor");
addEventListener(Event.ADDED_TO_STAGE, pLoaded);
}
//ADDED TO STAGE
public function pLoaded(e:Event):void
{
trace("player wants to move");
gotoAndStop(1);
addEventListener(KeyboardEvent.KEY_DOWN, pInput);
}
//KEYBOARD MOVEMENT
function pInput(key:KeyboardEvent):void
{
switch (key.keyCode)
{
case 37 ://Left
scaleX = -1; //flip horiz.
x -= pSpeed;
break;
case 39 ://Right
scaleX = 1; //flip horiz.
x += pSpeed;
break;
case 38 ://Up
y -= pSpeed;
break;
case 40 ://Down
y += pSpeed;
break;
}
}
}