First off let me say I'm completely new to flash development, but not OOP. My assignment is to create a real time (meaning using a game loop) Flash game in an object orientated manner. I've been following guides online, and I think I've got the basics down, but my player sprite isn't appearing.
I imported an image into Flash and then converted it into a symbol called Player
, and now it's a movie clip. I exported it for ActionScript, and called the class com.Player
.
Also, I have set the class of my document to com.Engine
(this is where I plan to have my game loop and call methods to other classes).
Then, I created a directory called com
in the same directory as my .fla
. Inside that directory, I made Engine.as
and Player.as
, and here's the code for them both:
package com {
import flash.display.MovieClip;
import flash.display.Stage;
public class Engine extends MovieClip {
public function Engine() {
// Create a player instance
var player:Player = new Player();
stage.addChild(player);
player.x = stage.stageWidth / 2;
player.y = stage.stageHeight / 2;
}
}
}
--
package com {
import flash.display.MovieClip;
public class Player extends MovieClip {
public function Player() {
}
}
}
According to what I know, that should make the player appear in the center of the screen when I run it, but it doesn't. I've verified that the Engine
class and constructor is being called using trace("hello world")
, and I get that output. I also know that the constructor for the Player
class is being called by using the same method. I just don't get why the player doesn't appear on screen.
If I drag the Player
symbol (correct terminology?) from my library onto the stage, the player sprite shows up... so I know there's an image attached.
Anyone know what could be going wrong? Thank you in advance :)
flash.display.MovieClip
. – ridflash.display.MovieClip
, when I enter that and select OK and then re-open the properties window the field is blank again. If I validate the base class definition it saysThe base class specified is a native class and will be defined in the player at runtime. It cannot be edited.
– James Dawson