I keep getting, this error"Error package cannot be nested", when I compile my code: 

package  {

    import flash.display.Sprite;
    import flash.text.TextField;
 
    public class MessageBox extends Sprite {
    
        function MessageBox():void {

         var msgbox:Sprite = new Sprite();

          // drawing a white rectangle
          msgbox.graphics.beginFill(0xFFFFFF); // white
          msgbox.graphics.drawRect(0,0,300,20); // x, y, width, height
          msgbox.graphics.endFill();
 
          // drawing a black border
          msgbox.graphics.lineStyle(2, 0x000000, 100);  // line thickness, line color (black), line alpha or opacity
          msgbox.graphics.drawRect(0,0,300,20); // x, y, width, height
        
          var textfield:TextField = new TextField()
          textfield.text = "Hi there!"

          addChild(msgbox)   
          addChild(textfield)
        }
     }
  }
What is a nested package, and how do I fix it?
FlashDave
Member Avatar for rajarajan2017

Its working! Just create a (MessageBox.as) file with the name of your class and paste your code there. Open your flash file and give your class name within the Document. Ctrl+Enter to run the file. Thats it! I checked it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.