Page 1 of 1

Error when using ENTER_TILE

Posted: 22 Feb 2013, 10:38
by Madhav
Hi....
Sorry for bringing each and every problem to here, but I am really struggling to code with openspace :( ,,,,

I am using AvatarEvent.ENTER_TILE to load diffrent maps. When my avatar enters a particular tile the new map is being loaded, the problem is I am getting the following error trying to do so but irrespective of error the map is loading fine!!!?

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.smartfoxserver.openspace.engine.control::IsoEngineController/http://www.smartfoxserver.com/openspace/osInternal::setGhostPosition()
at com.smartfoxserver.openspace.engine.control.avatar::AvatarAnimator/adjustAvatarRendering()
at com.smartfoxserver.openspace.engine.control.avatar::AvatarAnimator/onAvatarAnimationStep()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.greensock::TweenMax/renderTime()
at com.greensock.core::SimpleTimeline/renderTime()
at com.greensock::TweenLite$/updateAll()


My code to load map is,
private function onAvatarTileInteraction(evt:AvatarEvent):void
{
var tile:Tile = evt.params.tile;
var trigger:Trigger = evt.params.trigger;
if (evt.type == AvatarEvent.ENTER_TILE)
{
if (trigger.target == "gotoCoffeeShop")
{
smartFox.send(new LeaveRoomRequest(smartFox.lastJoinedRoom));
openSpace.unloadMap();
openSpace.setSize(765, 478);
mapsLoadManager.loadMap("Temple");
}
}
}

plz help....

Re: Error when using ENTER_TILE

Posted: 22 Feb 2013, 18:12
by rjgtav
Hi
I've never actually worked with OpenSpace, but if I'm not mistaken in order to load a new map you simply need to join the new room and the engine will automatically load the new map. When you send a JoinRoomRequest the server automatically removes the user from the previous room.
Can you try sending a JoinRoomRequest instead of leaving the current room?

Thanks

Re: Error when using ENTER_TILE

Posted: 25 Feb 2013, 04:53
by Madhav
Hi rjgtav,

As you said loading a new map automatically makes the avatar leave the old room, loadMap property does this for us. So my code to leave old room was of no need.
But the error was in " openSpace.unloadMap(); "!!! :? So when I removed this line and the one which I wrote to leave the room, everything worked fine.... :)

Thanks a lot for your help...

Re: Error when using ENTER_TILE

Posted: 26 Feb 2013, 00:06
by rjgtav
Oh, glad you managed to fix it ;)