Page 1 of 1

Change background in openSpace map dynamically

Posted: 15 Jan 2013, 10:42
by Madhav
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

Re: Change background in openSpace map dynamically

Posted: 16 Jan 2013, 09:47
by Bax
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.

Re: Change background in openSpace map dynamically

Posted: 16 Jan 2013, 11:40
by Madhav
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.. :)

Re: Change background in openSpace map dynamically

Posted: 16 Jan 2013, 16:38
by Bax
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)
		}
	}
}

Re: Change background in openSpace map dynamically

Posted: 17 Jan 2013, 04:42
by Madhav
: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...