Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
danno

creating dynamic TransformManagers

Recommended Posts

i'm looking to create unique TransformManagers for dynamically created and loaded MC's on the stage and am wanting to know the best way to go about setting up a way to do that.

 

thanks!

Link to comment
Share on other sites

Should be as simple as using Loaders to load your content, listen for a COMPLETE event at which time you addItem() to the TransformManager instance.

Link to comment
Share on other sites

i'm looking to have each dynamic clip have it's own dynamic, unique transformmanager and it's own unique transformitem as well. so a way to be able to reference those , uniquely.

thanks!

Link to comment
Share on other sites

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

and then could they be referenced like this:

 

manager[0].addItem(myObject);
manager[0].removeItem(myObject);

 

and so on?

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.
×