Jump to content
GreenSock

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

Saving and loading a transform mgr state

Recommended Posts

I have a project wherein I need to be able to let the user save the current state of the objects they have added to the TM and the position/scale/rotation of those objects.

 

Further, I then need to be able to let them re-load this data and set up the TM exactly the way it was when they saved.

 

Can this be done? Are there any examples I could refer to?

Link to comment
Share on other sites

My transform manager is declared in the MXML


 

And adding exportFullXML fails with undefined method:

protected function saveBtn_clickHandler(event:MouseEvent):void
		{
			myManager.exportFullXML();
		}

 

Am I using it right?

Link to comment
Share on other sites

Sounds like maybe you're using a stale version. exportFullXML() was added in version 1.88 months ago. I'd recommend logging into your GreenSock account and downloading the latest version. https://www.greensock.com/account/

Link to comment
Share on other sites

Yes, that was it. I thought I had updated but perhaps I picked up an older project.

 

EDIT: applyFullXML() is requiring 2 arguments although the help text looks as though only XML is required.

 

One further question, I am adding objects to the transform manager from a list and adding my own metadata to the objects:

protected function addNewItem(img:String, name:String, id:String):void {
			var newImage:Image = new Image();
			newImage.source = "images/full/"+img;
			newImage.x = 100;
			newImage.y = 200;
			newImage.name = name;
			newImage.id = id;
			newImage.toolTip = "Double Click for More Info";

			// to show pop up details
			newImage.doubleClickEnabled = true;
			newImage.addEventListener(MouseEvent.DOUBLE_CLICK,doubleClickItem );

			myManager.addItem(newImage);
		}

How might I extend/modify the exportFullXML() and importFullXML() to include these additional attributes?

Link to comment
Share on other sites

applyFullXML() is requiring 2 arguments although the help text looks as though only XML is required.

I just checked the ASDocs and it indeed shows 2 required arguments - what "help text" are you talking about? Where is it indicating only a single argument is required? http://www.greensock.com/as/docs/transform/

 

I am adding objects to the transform manager from a list and adding my own metadata to the objects:

...

How might I extend/modify the exportFullXML() and importFullXML() to include these additional attributes?

You would need to manage that on your own, getting the XML that exportFullXML() spits out and adding the various attributes to the necessary nodes and then also loop through and apply those values after calling importFullXML() or edit the TransformManager class file directly to add that customized functionality.

Link to comment
Share on other sites

The ASDOC is correct, but I meant the tooltip:

20101208-29m6k3h47um8iiscm9ji9jfnr.jpg

I thought required items in the tooltip were bold, but i could be wrong.

 

You would need to manage that on your own, getting the XML that exportFullXML() spits out and adding the various attributes to the necessary nodes and then also loop through and apply those values after calling importFullXML() or edit the TransformManager class file directly to add that customized functionality.

 

OK, makes sense. It says in the docs that applyFullXML looks for the object to be in the displaylist. How does it "connect" an object? Meaning, if my transform manager is full of items I have added dynamically (as in the code snippet posted earlier) and then I applyFullXML to a new session where those items haven't been added?

 

I assume I can keep track of the added items in an ArrayCollection or something on my own, but I guess I am unclear of the process by which they get "added" back to the transform mgr.

Link to comment
Share on other sites

The ASDOC is correct, but I meant the tooltip:

20101208-29m6k3h47um8iiscm9ji9jfnr.jpg

I thought required items in the tooltip were bold, but i could be wrong.

Yeah, the bold just indicates which one you're typing at that moment. As soon as you enter a value and type a comma, you'll see that the second parameter becomes bold, etc.

 

OK, makes sense. It says in the docs that applyFullXML looks for the object to be in the displaylist. How does it "connect" an object? Meaning, if my transform manager is full of items I have added dynamically (as in the code snippet posted earlier) and then I applyFullXML to a new session where those items haven't been added?

 

I assume I can keep track of the added items in an ArrayCollection or something on my own, but I guess I am unclear of the process by which they get "added" back to the transform mgr.

 

You are responsible for making sure the DisplayObjects are there on the stage - TransformManager just looks for them based on their name property. So make sure each one has a unique name before you exportFullXML() and then those names should be identical before you applyFullXML().

Link to comment
Share on other sites

You are responsible for making sure the DisplayObjects are there on the stage - TransformManager just looks for them based on their name property. So make sure each one has a unique name before you exportFullXML() and then those names should be identical before you applyFullXML().

 

Conceptually I know what you're saying, but I am having a hard time figuring out how to add the correct items to the displayList. Do you have any examples of a working save/load?

 

I have saved the xml file to the server. I can load it again. Of course the TM will be empty before load. All the possible objects that could be added are displayed in a list with a dataprovider of an XMLListCollection. So I would like to "pull" the same items out of this collection that are present in the xml file, and then applyFullXML to them.

Link to comment
Share on other sites

You'd need to pull the stuff from your collection and put them on the stage before you applyFullXML(). For example, if you have mc1, mc2 and mc3 (all named accordingly) that the TransformManager manages, and they're all children of an object called "myParent", you'd need to make sure you myParent.addChild() each one of those DisplayObjects and then applyFullXML(). I don't have an example right this second (very short on time) but hopefully this gives you a nudge in the right direction. Let me know if it's still foggy and you can't get it workin'.

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