I am getting "Packages Cannot Be Nested" in flash CS4 when following this tuturial
Tutorial: http://pus开发者_运维问答hbuttonengine.com/docs/Lesson-01-FlashCS4.html
When I get to hello world, It gives me the error "Packages cannot be nested but, when I remove the { and } it gets mad at me.
Code:
package
{
import flash.display.Sprite;
import com.pblabs.engine.PBE;
import com.pblabs.engine.debug.Logger;
public class Lesson1FlashCS4 extends Sprite
{
public function Lesson1FlashCS4():void
{
PBE.startup(this);
Logger.print(this, "Hello, World!");
}
}
}
Sorry about my strange language, I have not programmed in a long time and have forgotten most everything. Did remember this site though!
In the code where you are trying to use the Lesson1FlashCS4 class, are you using ...
include "Lesson1FlashCS4.as";
instead of ...
import Lesson1FlashCS4;
(or something like that, depending on your file names and paths) -Because that would cause the error you are getting. You need to import your class, not include the .as file.
The code on the site looks perfectly valid -- are you sure you've typed it out verbatim?
The only other thing that I can think of that could be causing the problem is if you put the code on the frame instead of the document class. Make double sure you've followed the instructions in the "Document Class" section precisely.
If you posted more details we could answer more easily (i.e. without guessing ;-)
remove the void return type on your constructor. constructors can't have return types.
public function Lesson1FlashCS4()
{
PBE.startup(this);
Logger.print(this, "Hello, World!");
}
精彩评论