Jump to content
GreenSock

bhoffmann

applySavedXML.. getting rid of gray boxes.

Recommended Posts

I have set up undo functionality where I save transformmanager xmls into an array, then when the user clicks 'undo' it just applies the previous xml using applySavedXML().

 

This works great, but it gets a little tricky when I undo an item after I have deleted an image or textfield. A gray box appears in the transformitem. I have managed to load back in the image into the correct transformitem but I am having a problem with text. When I bring the textfield back in I can still see the gray box.

 

The textfield is being added to a movieclip that is then added to the targetObject of the transformItem. Any way I can make the gray box dissapear?

 

I tried looping through the children of the transformItem and all I could find was the movieClip I added.

Link to comment
Share on other sites

It sounds like you must not be putting the target objects onto the stage and naming them properly. Here's an excerpt from the ASDocs which can be found at http://www.greensock.com/as/docs/transf ... lyFullXML()

 

When applyFullXML() is called, it attempts to find the targetObjects in the display list based on their names, but for each one that cannot be found, a new Sprite will be created and added as a placeholder, filled with the placeholderColor and named identically. An array of those placeholders (if any) is returned by applyFullXML() which makes it easy to loop through and load your images/assets directly into those placeholder Sprites.

 

So, for example, if you have a MovieClip named "mc1" that is being managed by TransformManager and then you exportFullXML() and then later you applyFullXML(), if you don't have a DisplayObject named "mc1" there, a placeholder Sprite is created in its place. Again, make sure the "name" property is what it needs to be - like myObject.name = "mc1". See what I mean?

Link to comment
Share on other sites

Well, I am trying to do just that.

 

1. I call applySavedXML().

2. I loop through the transformanager to find any objects that might be missing their target object

3. I add an MC to those items with the name that I find in the xml

 

 

No Dice.

 

Do I need to call it twice?

 

I feel like I need to call it first to be able to first figure out what is missing, then maybe a second time after the item has been added?

Link to comment
Share on other sites

It sounds like you're doing things out of order. It should be:

 

1) Put all of the target objects on the stage and make sure they're named appropriately (you don't need to add the targets to the TransformManager yet)

2) Call applyFullXML() on the TransformManager instance. That'll find all the targets, apply the size/scale/rotation, and add them to the TransformManager.

 

Does that clear things up?

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