Share Posted March 2, 2011 I can't figure this out, since this had been working fine but I use TM to create a room, like this: Where the orange items have lockScale true and the gray walls do not. I have also disabled constrainScale on the TM in MXML, so you can stretch the walls to make a room. I save the whole thing with exportFullXML, and load it, but although the orange items are always correct, the wall objects are not: Why would this be? Link to comment Share on other sites More sharing options...
Author Share Posted March 2, 2011 OK, I see what is happening now, but not sure how to handle it. The problem is from adding items with the same name more than once is confusing things. However, I am unclear on what to do about it. This goes back to by continuing problem about how to "find" the correct items to add to the TM before applyFullXML is called. I am adding items with this: protected function addNewItem(obj:Object):void { var stageItem:AddedItem = new AddedItem(); stageItem.source = "/wsbp/images/full/"+obj.img; stageItem.itemName = obj.name; stageItem.name = obj.name ws.myManager.addItem(stageItem); updateItemCount(); } I was using stageItem.name = obj.name to give the Transform item a name i could associate with the original graphic, so when I load the XML I can fetch is and add it before applyFullXML. So of course, multiple TIs have the same name now, which is obviously not good. If I don't assign a name like I am here, the default item names are things like "AddedItem234", each unique. But how do I know what "AddedItem234" is, so I can load the correct graphic (AddedItem class)? Link to comment Share on other sites More sharing options...
Share Posted March 2, 2011 Are you asking how you can name your DisplayObjects uniquely? I'm a little unclear about the problem you're asking about. It should be as simple as giving each "name" property a unique name. You could just append a unique number to it if you want, using a static variable that you increment each time, like: private static var _instanceCount:uint = 0; //then, inside your addNewItem() method... stageItem.name = obj.name + (_instanceCount++); Does that help? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now