Have XML Slide Show need to make it show behind other movie clips

Webman04
Webman04 used Ask the Experts™
on
Hi, I have the script below embedded into an fla file with a frame, my idea is to have the frame show partially overlapping the movie in order to give it depth, but I can't get the external images to show behind the other layers.  Anyone know what I'm doing wrong?  Thanks
import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load("slideshow.xml");
 
myShowXML.onLoad = function() {
	_root.myWidth = myShowXML.firstChild.attributes.width;
	_root.myHeight = myShowXML.firstChild.attributes.height;
	_root.mySpeed = myShowXML.firstChild.attributes.speed;
 
	_root.myImages = myShowXML.firstChild.childNodes;
	_root.myImagesNo = myImages.length;
 
	createContainer();
	callImages();
 
};
 
 
function createContainer() {
	_root.createEmptyMovieClip("myContainer_mc",1);
 
	myContainer_mc.lineStyle(5,0x000000,100);
	myContainer_mc.lineTo(_root.myWidth,0);
	myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
	myContainer_mc.lineTo(0,_root.myHeight);
	myContainer_mc.lineTo(0,0);
 
	myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
	myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;
 
}
 
function callImages() {
 
	_root.myMCL = new MovieClipLoader();
	_root.myPreloader = new Object();
	_root.myMCL.addListener(_root.myPreloader);
 
	_root.myClips_array = [];
 
	_root.myPreloader.onLoadStart = function(target) {
 
		_root.createTextField("myText_txt",_root.getNextHighestDepth(),0,0,100,20);
		_root.myText_txt._x = (Stage.width-_root.myText_txt._width)/2;
		_root.myText_txt._y = (Stage.height-_root.myText_txt._height)/2;
		_root.myText_txt.autoSize = "center";
 
		_root.myText_txt.text = "test";
 
	};
 
	_root.myPreloader.onLoadProgress = function(target) {
 
		_root.myText_txt.text = "Loading.. "+_root.myClips_array.length+"/"+_root.myImagesNo+" Completed";
 
	};
 
 
	_root.myPreloader.onLoadComplete = function(target) {
 
		_root.myClips_array.push(target);
		target._alpha = 0;
 
		if (_root.myClips_array.length == _root.myImagesNo) {
 
			_root.myText_txt._y = myContainer_mc._y + myContainer_mc._height;
			_root.target_mc = -1;
			moveSlide();
			myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);
 
 
		}
 
	};
 
	for (i=0; i<_root.myImagesNo; i++) {
 
		temp_url = _root.myImages[i].attributes.url;
		temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());
 
		_root.myMCL.loadClip(temp_url,temp_mc);
	}
 
}
 
 
function moveSlide() {
 
	current_mc = _root.myClips_array[_root.target_mc];
	new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);
 
	_root.target_mc++;
 
	if (_root.target_mc>=_root.myImagesNo) {
		_root.target_mc = 0;
	}
	
	_root.myText_txt.text = _root.myImages[target_mc].attributes.title;
	next_mc = _root.myClips_array[_root.target_mc];
	new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
 
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2009

Commented:
Swap the depths of the external images with the other layers.

For example, externalImage.swapDepths(otherstuff);

Alternatively you can use externalImage.swapDepths(somenumber);, where some number is a depth number lower than the other objects you want to be behind.
Top Expert 2008

Commented:
as per your code, you are loading all external images inside "myContainer_mc". which you have created dynamically on _root at depth 1.

I suggest to create a blank movieClip with instanceName "blank_mc" on the lowest layer where you want to place this container_mc which holds all images.

now just add one line of code below the code where "myContainer_mc" is being created...
//----------------------------
function createContainer() {
      _root.createEmptyMovieClip("myContainer_mc",1);
      _root.myContainer_mc.swapDepths(_root.blank_mc);   // this is the new code
//----------------------------

now all images should go beneath other layers...

Author

Commented:
Hi aneeshchopra, is this correct?
import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load("slideshow.xml");
 
myShowXML.onLoad = function() {
        _root.myWidth = myShowXML.firstChild.attributes.width;
        _root.myHeight = myShowXML.firstChild.attributes.height;
        _root.mySpeed = myShowXML.firstChild.attributes.speed;
 
        _root.myImages = myShowXML.firstChild.childNodes;
        _root.myImagesNo = myImages.length;
 
        createContainer();
        callImages();
 
};
 
 
function createContainer() {
        _root.createEmptyMovieClip("myContainer_mc",1);
 
        myContainer_mc.lineStyle(5,0x000000,100);
        myContainer_mc.lineTo(_root.myWidth,0);
        myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
        myContainer_mc.lineTo(0,_root.myHeight);
        myContainer_mc.lineTo(0,0);
 
        myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
        myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;
 
}
 
function createContainer() {
      _root.createEmptyMovieClip("myContainer_mc",1);
      _root.myContainer_mc.swapDepths(_root.blank_mc);   // this is the new code
 
 
function callImages() {
 
        _root.myMCL = new MovieClipLoader();
        _root.myPreloader = new Object();
        _root.myMCL.addListener(_root.myPreloader);
 
        _root.myClips_array = [];
 
        _root.myPreloader.onLoadStart = function(target) {
 
                _root.createTextField("myText_txt",_root.getNextHighestDepth(),0,0,100,20);
                _root.myText_txt._x = (Stage.width-_root.myText_txt._width)/2;
                _root.myText_txt._y = (Stage.height-_root.myText_txt._height)/2;
                _root.myText_txt.autoSize = "center";
 
                _root.myText_txt.text = "test";
 
        };
 
        _root.myPreloader.onLoadProgress = function(target) {
 
                _root.myText_txt.text = "Loading.. "+_root.myClips_array.length+"/"+_root.myImagesNo+" Completed";
 
        };
 
 
        _root.myPreloader.onLoadComplete = function(target) {
 
                _root.myClips_array.push(target);
                target._alpha = 0;
 
                if (_root.myClips_array.length == _root.myImagesNo) {
 
                        _root.myText_txt._y = myContainer_mc._y + myContainer_mc._height;
                        _root.target_mc = -1;
                        moveSlide();
                        myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);
 
 
                }
 
        };
 
        for (i=0; i<_root.myImagesNo; i++) {
 
                temp_url = _root.myImages[i].attributes.url;
                temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());
 
                _root.myMCL.loadClip(temp_url,temp_mc);
        }
 
}
 
 
function moveSlide() {
 
        current_mc = _root.myClips_array[_root.target_mc];
        new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);
 
        _root.target_mc++;
 
        if (_root.target_mc>=_root.myImagesNo) {
                _root.target_mc = 0;
        }
        
        _root.myText_txt.text = _root.myImages[target_mc].attributes.title;
        next_mc = _root.myClips_array[_root.target_mc];
        new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
 
}

Open in new window

Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Hi, still not working?  I've included the new code below.  I need the xml slide show to load behind the crabs so that their claws overlap the slides a bit, any help would be great.  Thanks
import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load("slideshow.xml");
 
myShowXML.onLoad = function() {
	_root.myWidth = myShowXML.firstChild.attributes.width;
	_root.myHeight = myShowXML.firstChild.attributes.height;
	_root.mySpeed = myShowXML.firstChild.attributes.speed;
 
	_root.myImages = myShowXML.firstChild.childNodes;
	_root.myImagesNo = myImages.length;
 
	createContainer();
	callImages();
 
};
 
 
function createContainer() {
	_root.createEmptyMovieClip("myContainer_mc",1);
 
	myContainer_mc.lineStyle(5,0x000000,100);
	myContainer_mc.lineTo(_root.myWidth,0);
	myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
	myContainer_mc.lineTo(0,_root.myHeight);
	myContainer_mc.lineTo(0,0);
 
	myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
	myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;
 
}
 
 
function createContainer() {
      _root.createEmptyMovieClip("myContainer_mc",1);
      _root.myContainer_mc.swapDepths(_root.blank_mc);   // this is the new code
	  
	  
	};
 
function callImages() {
 
	_root.myMCL = new MovieClipLoader();
	_root.myPreloader = new Object();
	_root.myMCL.addListener(_root.myPreloader);
 
	_root.myClips_array = [];
 
	_root.myPreloader.onLoadStart = function(target) {
 
		_root.createTextField("myText_txt",_root.getNextHighestDepth(),0,0,100,20);
		_root.myText_txt._x = (Stage.width-_root.myText_txt._width)/2;
		_root.myText_txt._y = (Stage.height-_root.myText_txt._height)/2;
		_root.myText_txt.autoSize = "center";
 
		_root.myText_txt.text = "test";
 
	};
 
	_root.myPreloader.onLoadProgress = function(target) {
 
		_root.myText_txt.text = "Loading.. "+_root.myClips_array.length+"/"+_root.myImagesNo+" Completed";
 
	};
 
 
	_root.myPreloader.onLoadComplete = function(target) {
 
		_root.myClips_array.push(target);
		target._alpha = 0;
 
		if (_root.myClips_array.length == _root.myImagesNo) {
 
			_root.myText_txt._y = myContainer_mc._y + myContainer_mc._height;
			_root.target_mc = -1;
			moveSlide();
			myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);
 
 
		}
 
	};
 
	for (i=0; i<_root.myImagesNo; i++) {
 
		temp_url = _root.myImages[i].attributes.url;
		temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());
 
		_root.myMCL.loadClip(temp_url,temp_mc);
	}
 
}
 
 
function moveSlide() {
 
	current_mc = _root.myClips_array[_root.target_mc];
	new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);
 
	_root.target_mc++;
 
	if (_root.target_mc>=_root.myImagesNo) {
		_root.target_mc = 0;
	}
	
	_root.myText_txt.text = _root.myImages[target_mc].attributes.title;
	next_mc = _root.myClips_array[_root.target_mc];
	new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
 
}

Open in new window

Top Expert 2009

Commented:
You have a clash in function names, so you should do this.
Replace the entire code you show with this.

import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var myShowXML = new XML();
myShowXML.ignoreWhite = true;
myShowXML.load("slideshow.xml");
 
myShowXML.onLoad = function() {
	_root.myWidth = myShowXML.firstChild.attributes.width;
	_root.myHeight = myShowXML.firstChild.attributes.height;
	_root.mySpeed = myShowXML.firstChild.attributes.speed;
 
	_root.myImages = myShowXML.firstChild.childNodes;
	_root.myImagesNo = myImages.length;
 
	createContainer();
	callImages();
 
};
 
 
function createContainer() {
	_root.createEmptyMovieClip("myContainer_mc",1);
 
	myContainer_mc.lineStyle(5,0x000000,100);
	myContainer_mc.lineTo(_root.myWidth,0);
	myContainer_mc.lineTo(_root.myWidth,_root.myHeight);
	myContainer_mc.lineTo(0,_root.myHeight);
	myContainer_mc.lineTo(0,0);
 
	myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
	myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;
	myContainer_mc.swapDepths(_root.blank_mc); 
 
}
 
function callImages() {
 
	_root.myMCL = new MovieClipLoader();
	_root.myPreloader = new Object();
	_root.myMCL.addListener(_root.myPreloader);
 
	_root.myClips_array = [];
 
	_root.myPreloader.onLoadStart = function(target) {
 
		_root.createTextField("myText_txt",_root.getNextHighestDepth(),0,0,100,20);
		_root.myText_txt._x = (Stage.width-_root.myText_txt._width)/2;
		_root.myText_txt._y = (Stage.height-_root.myText_txt._height)/2;
		_root.myText_txt.autoSize = "center";
 
		_root.myText_txt.text = "test";
 
	};
 
	_root.myPreloader.onLoadProgress = function(target) {
 
		_root.myText_txt.text = "Loading.. "+_root.myClips_array.length+"/"+_root.myImagesNo+" Completed";
 
	};
 
 
	_root.myPreloader.onLoadComplete = function(target) {
 
		_root.myClips_array.push(target);
		target._alpha = 0;
 
		if (_root.myClips_array.length == _root.myImagesNo) {
 
			_root.myText_txt._y = myContainer_mc._y + myContainer_mc._height;
			_root.target_mc = -1;
			moveSlide();
			myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);
 
 
		}
 
	};
 
	for (i=0; i<_root.myImagesNo; i++) {
 
		temp_url = _root.myImages[i].attributes.url;
		temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());
 
		_root.myMCL.loadClip(temp_url,temp_mc);
	}
 
}
 
 
function moveSlide() {
 
	current_mc = _root.myClips_array[_root.target_mc];
	new Tween(current_mc, "_alpha", Strong.easeOut, 100, 0, 1, true);
 
	_root.target_mc++;
 
	if (_root.target_mc>=_root.myImagesNo) {
		_root.target_mc = 0;
	}
	
	_root.myText_txt.text = _root.myImages[target_mc].attributes.title;
	next_mc = _root.myClips_array[_root.target_mc];
	new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
 
}

Open in new window

Top Expert 2009

Commented:
If you still cannot get this to work, please explain clearly what you want to be in front, what you want to be behind and also post the entire.fla

By saying you want the thing to be behind the layers, I do not know what layers you are referring to.

Please be specific.

For example:

I want object1to be in front of object2.

However, I want object1 to be behind object3,object4.

Author

Commented:
Hi, I wanted to give you the fla but it seems that file type is not allowed for upload?  How can I get it to you?
Top Expert 2009

Commented:
Rename it to .txt extension.

Author

Commented:
Hi, OK thanks I've uploaded the .fla file.  What I am trying to do it get the xml that is located on the slideshow layer (action script in located in the slideshow layer) to load images located in an external xml file which is did fine, but I can't get the images to show behind any of the other layers and I need the slide show to show behind the crabs claws so that they over hang a bit, giving it a bit of depth.  Hope this is clear enough, and I really am very grateful for all your help, thanks very much.

Also, the File was created in CS3
slideShow.txt
Top Expert 2008
Commented:
attached the updated FLA,
It should work fine..

slideShow.fla.txt

Author

Commented:
Thank you very much, you really went the extra mile for me, thanks!!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial