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...
Change background in openSpace map dynamically
Re: Change background in openSpace map dynamically
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
The SmartFoxServer Team
Re: Change background in openSpace map dynamically
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..
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..
Re: Change background in openSpace map dynamically
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:
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
The SmartFoxServer Team
Re: Change background in openSpace map dynamically
wow...Thanks a lot Bax for detailed code, it helped a lot...
I am using a single background movieclip, and it worked Thanks again...
I am using a single background movieclip, and it worked Thanks again...
Return to “OpenSpace v2 discussions and help”
Who is online
Users browsing this forum: No registered users and 43 guests