Jump to content
Search Community

creating dynamic TransformManagers

danno test
Moderator Tag

Recommended Posts

I'm confused - are you asking how to create a TransformManager instance and add an item to it? You can create as many TransformManagers as you want. Each one could look something like:

 

var myManager:TransformManager = new TransformManager();
myManager.addItem(myObject);

Link to comment
Share on other sites

here's an example ( wrong of course ), but still an example of what i'm meaning:

 

for (a=0; a <= 10; a++){
var thisManagersName:String = String("manager"+a);
var thisManagersName:TransformManger = new TransformManager();
thisManagersName.addItem(myObject);
}

so that at the end, there would be managers with items added to them, named:

manager0, manager1, manager2, manager3, etc.

 

hope that helps clear it up a little more. thanks!

Link to comment
Share on other sites

I think it'd look more like this:

 

var urls:Array = ["img/image1.jpg","img/image2.jpg","img/image3.jpg"];
var managers:Array = []; //store managers here (they will NOT necessarily be in the same order as the URLs depending on how quickly they load!)
var loader:Loader;
var i:int;
for (i = 0; i 	loader = new Loader();
loader.addEventListener(Event.COMPLETE, onLoadComplete, false, 0, true);
loader.load(new URLRequest(urls[i]));
}

function onLoadComplete(event:Event):void {
var manager:TransformManager = new TransformManager();
manager.addItem(event.target);
managers.push(manager);
}

Link to comment
Share on other sites

Sure. Althought it's usually a good idea to take advantage of strict data typing by doing this:

 

var manager:TransformManager = managers[0];
manager.addItem(myObject);
manager.removeObject(myObject);

 

It performs faster and helps debug because the compiler understands the types of objects it's dealing with. When you reference an object in an Array like managers[0] it has no idea what type of data to expect.

Link to comment
Share on other sites

Sure. Althought it's usually a good idea to take advantage of strict data typing by doing this:

 

var manager:TransformManager = managers[0];
manager.addItem(myObject);
manager.removeObject(myObject);

 

It performs faster and helps debug because the compiler understands the types of objects it's dealing with. When you reference an object in an Array like managers[0] it has no idea what type of data to expect.

 

ahh ok cool. thanks again for all the help, i appreciate it!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...