Error when using ENTER_TILE

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Error when using ENTER_TILE

Postby Madhav » 22 Feb 2013, 10:38

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....
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Error when using ENTER_TILE

Postby rjgtav » 22 Feb 2013, 18:12

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
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Error when using ENTER_TILE

Postby Madhav » 25 Feb 2013, 04:53

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...
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Error when using ENTER_TILE

Postby rjgtav » 26 Feb 2013, 00:06

Oh, glad you managed to fix it ;)
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 16 guests