So after all this time, I'm only really trying OOP just now. >_> Just playing around.
I created a class "Toy" (Toy.as). I have my main Flash file (let's call it Main.SWF). I need to be able to place an instance of a Toy on the stage of Main.SWF by declaring an instance and passing the coordinates to it.
Code for Toy:
class Toy{
private var type:String = "";
private var libID:String = "";
private var stageID:String = "";
private var locX:Number = 0;
private var locY:Number = 0;
public function Toy(myType:String, myX:Number, myY:Number){
trace("create");
type = myType;
locX = myX;
locY = myY;
if (type == "Teddy"){
libID = "libToy_TeddyBear";
stageID = "mcToy_TeddyBear";
_root.attachMovie(libID, stageID+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:locX, _y:locY});
}
}
}
As for Main.SWF:
var teddy:Toy = new Toy("Teddy", 100, 100);
The problem is with attaching. The attachMovie() will not work, and I was fairly certain it wouldn't, since I "_root" couldn't really mean the stage of Main.SWF. I thought maybe I could pass the Stage, but I don't even know it's data type. I'm sure there's just some tidbit I'm missing here. Help is greatly appreciated.