I am new into as3, was following some tutorials and I made this code:
Class 1 (Enemy.as):
package
{
import flash.display.MovieClip;
public class Enemy extends MovieClip
{
public function Enemy()
{
x = 100;
y = 0;
}
public function moveDownABit():void
{
y = y + 3;
}
}
}
and in main Class (AvoiderGame.as) :
package
{
import flash.display.MovieClip;
public class AvoiderGame extends MovieClip
{
public var enemy:Enemy;
public function AvoiderGame()
{
enemy = new Enemy();
addChild( enemy );
}
}
}
I Linked my Instant with it and all checked and working. also I added the main class to Classdocument of my fla file, though I am getting this error :
C:\Users\x\Documents\Flash\tuts\game1- avoider\Classes\AvoiderGame.as, Line 2 1046: Type was not found or was not a compile-time constant: Enemy.
C:\Users\x\Documents\Flash\tuts\game1- avoider\Classes\AvoiderGame.as, Line 6 1046: Type was not found or was not a compile-time constant: Enemy.
any ideas ?
确保您的避免类和Enemy类位于同一包(文件夹)中,并且其文件名与类名相同(AvoiderGame.as和Enemy.as)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.