Search code examples
actionscript-3flashspriteaddchild

Actionscript 3.0 addchild


Here's my code, the problem is that it doesn't add the sprite when i call it from my main function in main.

package{

import flash.display.*;
import flash.events.*;

public class gfxs extends MovieClip{

    public function gfxs(){
    }
    public function placeCar(){
       var car:MoonCar = new MoonCar();
       car.x = 100;
       car.y = 372;
       addChild(car);
       trace("PLACED CAR"); //JUST TO CHEK IF IT RUNS THIS CODE(IT DOES)
    }
}

}


Solution

  • You need to add gfxs to the stage in your main class. For example in you main.as you might have something like this :

    var myGfxs:gfxs = new gfxs();
    myGfxs.placeCar();
    addChild(myGfxs);
    

    Hard to give a definitive answer as we canot see what you have done in your main.as file.