Change background in openSpace map dynamically

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

Change background in openSpace map dynamically

Postby Madhav » 15 Jan 2013, 10:42

How to change the background of the openSpace map dynamically!!?
I have a openspace map who's background movieclip has got different frames (each with different bg's),

At first i have first frame bg, but how to change it to 2nd or other on button click???
Thanx...
:D
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Change background in openSpace map dynamically

Postby Bax » 16 Jan 2013, 09:47

Check the IOpenSpaceAPI.getBackgroundParts() method. It returns an Array2 (a matrix) containing a reference to all the sections of the current map's background (maybe just one in your case). You can access it and change the frame or what else.
Paolo Bax
The SmartFoxServer Team
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Change background in openSpace map dynamically

Postby Madhav » 16 Jan 2013, 11:40

hai Bax, thanx for reply...

may be a silly question, but can you explain how to access the background frames!!?
as you said, i got this-
var myBG : Array2 = openSpace.getBackgroundParts();

and my openspace map has got "myMapBG" movieclip which is having different frames with different backgrounds.. :)
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Change background in openSpace map dynamically

Postby Bax » 16 Jan 2013, 16:38

Are you using a single background movieclip, or did you split it in multiple parts?
In any case you can get each part like this:

Code: Select all

var bgParts:Array2 = openSpace.getBackgroundParts();
for (var r:int = 0; r < bgParts.height; r++)
{
   for (var c:int = 0; c < bgParts.width; c++)
   {
      var part:DisplayObject = bgParts.get(c, r) as DisplayObject
      
      if (part != null)
      {
         // YOUR CODE TO CHANGE THE DisplayObject FRAME (CHECK THE AS3 DOCUMENTATION)
      }
   }
}
Paolo Bax
The SmartFoxServer Team
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: Change background in openSpace map dynamically

Postby Madhav » 17 Jan 2013, 04:42

:D wow...Thanks a lot Bax for detailed code, it helped a lot...
I am using a single background movieclip, and it worked :D Thanks again...

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 43 guests