Page 1 of 1

leaveEditMode error

Posted: 03 Nov 2010, 20:57
by svizzari
Hi -- I'm experiencing an issue with leaveEditMode(false) where OpenSpace seems to not 'see' the correct room id. After an item has been dropped on the map in edit mode I am validating whether the user has enough virtual credit to 'purchase' that item. If they do not I am calling leaveEditMode(false), the JSON sent to the server is below:

Code: Select all

[OpenSpace|INFO]  Map editing cancelled; reloading current map
[OpenSpace|INFO]  Requesting map to OpenSpace Extension
[Sending - JSON]: {"t":"xt","b":{"p":{"pwd":null,"room":0},"r":7,"x":"__OpenSpaceExtension__","c":"_os_map"}}
I can see that the correct room id is being passed with the request JSON but that the body of the request seems to contain incorrect data:

Code: Select all

{"pwd":null,"room":0}
Any ideas?

Posted: 05 Nov 2010, 07:20
by Bax
Mmm.. no idea at all. :shock:
I made a simple test by calling the leaveEditMode(false) as soon as the tileDropValidator function is called, and everything is smooth (map is reloaded correctly).
Do you have more informations to share? Are you using multiple room join for example?

Posted: 07 Nov 2010, 20:14
by svizzari
Hi Bax,

No, I'm not using multiple room joining, my application is single-room-access only. I can confirm this using the AdminTool and also by debugging on the client-side.

So, at the point at which I am calling cancel, I can see by debugging that:

- OpenSpace is in edit mode.
- SmartFox has the correct room id set as the activeRoomId.
- The roomList on SmartFox includes the current room, from which editing is occuring.

My process does differ from what you described in that I am calling cancel after the tileDropValidator function has been called, and returned true. Perhaps it would be better to call leaveEditMode from the tileDropValidator function, however, I would still expect it to work in my setup.

In relation to the tileDropValidator function and supertiles, it would be difficult for me to work with supertiles validation in my application where the validator was called repeatedly for each tile -- perhaps it would have been better to pass an array of tiles like some of the events in the API, i.e. MAP_ITEM_ADDED

Posted: 11 Nov 2010, 08:30
by Bax
svizzari wrote:My process does differ from what you described in that I am calling cancel after the tileDropValidator function has been called, and returned true. Perhaps it would be better to call leaveEditMode from the tileDropValidator function, however, I would still expect it to work in my setup.
How do you cancel editing after the tileDropValidator returned true? That function is called by OpenSpace internally.

Posted: 11 Nov 2010, 21:08
by svizzari
hey bax -- to be sure we're talking about the same thing ;) When I describe the tileDropValidator function, I am talking about this. I have assigned a function of my own with the signature:

function tileDropValidatorFunction(tile:Tile):Boolean
{
}

So... in my code, this function is called by OpenSpace when an inventory item is dragged over the map. If this function returns true, is it possible to leaveEditMode(false) after that point? Or, is the dropped inventory item 'fixed' at that point?

Posted: 17 Nov 2010, 08:04
by Bax
That should work. In fact I tried to enter the leaveEditMode command inside that validator function directly, and it works. Not sure why it doesn't work for you.

Posted: 17 Nov 2010, 20:45
by svizzari
Hmm, I'll investigate some more and let you know what I find.

Posted: 25 Feb 2011, 02:21
by zoomandenhance
Hi Paolo,

I've finally got back to testing this issue and I'm not sure how the scenario you described *could* work. If you were to call leaveEditMode from within the tileDropValidator function there would be unexpected results as you would still be dragging.

I've tested the scenario and found that after calling leaveEditMode(false) from the tileDropValidator items can still be dropped on the map. When this occurs, no events are fired, i.e. itemAdded.

Also, what did you think about my earlier suggestion of passing all supertile tiles in an array for validation?

Posted: 25 Feb 2011, 06:34
by Bax
We retested this and it works.. partially.
In fact you can call the leaveEditMode, but you keep dragging the item. When you drop it, it simply disappears without affecting the map.
We might cancel the dragging when the method is called.

About passing all supertile tiles in an array for validation, we still have to investigate this. Sorry but we have slowed down the OpenSpace improvements due to the release of SFS 2X.

Posted: 25 Feb 2011, 07:38
by svizzari
Hi Paolo,

Thanks for the reply.

In my test, the dropped item didn't disappear, it fixed to the map at that position.

Posted: 25 Feb 2011, 14:56
by Bax
Are we talking of Flash or Flex? My test was made in Flex.

Posted: 25 Feb 2011, 21:56
by svizzari
Which OpenSpace SWC was I using do you mean? If so, I was using the Flash SWC and compiling via FlashDevelop and the Flex compiler.

Posted: 26 Feb 2011, 08:11
by Bax
Then maybe Flash behaves differently than Flex: even if the source code is the same for the two versions of OpenSpace, we use different drag managers.
We will test the same in Flash as soon as possible.