0

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)
    }
}

}

1 Answers1

0

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.

prototypical
  • 6,731
  • 3
  • 24
  • 34
  • This is my main.as:`package{ import flash.display.*; import flash.events.*; public class main extends MovieClip { var gfx:gfxs = new gfxs(); public function main(){ gfx.placeCar(); } } }` – user1964811 Jan 10 '13 at 07:26
  • sorry,f*cked that up :S I'm new here – user1964811 Jan 10 '13 at 07:28
  • read my answer- you just need to add gfx as a child in your main function. Based on the code you just gave in that last comment, you are NOT adding gfx to the display list of the stage. So it will not be visible. Make the change and accept the answer. – prototypical Jan 10 '13 at 07:35
  • Also, if you ever need to add code to your question, just do so by editing your question. Code in the comments is generally not a good idea due to the formatting. – prototypical Jan 10 '13 at 07:38
  • Thanks, i figured it out;) If there is any "thanks" system or something i would be glad to "Thank you" if you tell me how to do it :) – user1964811 Jan 10 '13 at 13:47