i'm pretty new to AS3 and programming in general. I'm working on a simple game with various levels. The idea is to have every level in different class. However I can't get it working. For some reason the trace("it works") works as I can see it in the output window but the rectangle (mySprite3) won't appear. Can you please anyone tell me what I'm doing wrong. I'm sure it's something really silly and simple.
Thank you very much.
initial_screen.as
package
{
import flash.text.TextField;
import flash.display.Sprite;
import flash.events.TouchEvent;
import flash.ui.MultitouchInputMode;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.SoftKeyboardEvent;
import flash.ui.Multitouch;
public class initial_screen extends Sprite
{
public function initial_screen()
{
var btnTest:Sprite = new Sprite ();
btnTest.graphics.beginFill(0x891C56);
btnTest.graphics.drawRect(20,50,600,100);
addChild(btnTest);
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
btnTest.addEventListener(TouchEvent.TOUCH_TAP, taphandler1);
function taphandler1(event:TouchEvent):void
{
var eg:LEVEL_01 = new LEVEL_01();
eg.drawPic();
}
}
}
}
LEVEL_01.as
package
{
import flash.display.Sprite;
public class LEVEL_01 extends Sprite
{
public function drawPic()
{
var mySprite3:Sprite = new Sprite ();
mySprite3.graphics.beginFill(0x98b6a8);
mySprite3.graphics.drawRect(20,500,600,100);
addChild(mySprite3);
trace("it works");
}
}
}
Thank you very much.
you need to add your class to the stage
in initial_screen after creating the level
addChild(eg);