Reputation: 253
I am working on a breakout game in adobe flash. I defined a document class, BreakOut.as, and set it to .fla file. I wrote another class Player.as, but I failed to get access to Player.as in my BreakOut.as. Here is the code:
BreakOut.as:
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
public class BreakOut extends MovieClip
{
public function BreakOut()
{
var background:Background;
background= new Background();
addChild(background);
var playerone:Player;
playerone=new Player();
playerone.x=50;
playerone.y=50;
addChild(playerone);
}
}
}
Player.as:
package
{
import flash.display.MovieClip;
public class Player extends MovieClip
{
public function Player()
{
player.graphics.beginFill(0x000000);
player.graphics.drawRect(0,0,20,100);
}
}
}
Adobe flash keeps telling me: Access of undefined property Player. Well, Background.as is another class, and I can get access to it without any problems. But it just won't work on Player.as.
Upvotes: 1
Views: 123
Reputation: 13151
player.graphics.beginFill(0x000000);
player.graphics.drawRect(0,0,20,100);
By this, if you are trying to initialize Player by drawing a rectangle, you should be rather using this:
this.graphics.beginFill(0x000000);
this.graphics.drawRect(0,0,20,100);
Do note that Player.as should also be in the same path as the fla's classpath.
Upvotes: 3