View Full Version : Layers with Actionscript 3.0
Scharpe
06-03-2008, 01:02 PM
hey there, I am working on a project where i am creating a slideshow from a folder of images and with an xml doc. i have it all working but i have been using code from a few different things. (easier than making my own) The problem i have is that i have some animated graphics in the show that are on different layers, I have them on top of the actionscript i am using to bring in the images but for some reason the images are over top of all of my other graphics and text on the page. i want to know if there is a way to make my pictures be on the bottom of everything else. I can supply the code i am using if it will help. Thanx for all the help!
Mazoonist
06-03-2008, 02:05 PM
var loader:Loader = new Loader();
loader.load(new URLRequest("character1.jpg")); //substitute the name of your image file
addChild(loader);
setChildIndex(loader, 0); //here's what puts it behind everything else
Scharpe
06-03-2008, 02:31 PM
I'm sorry, I am not the best with actionscript code. :confused: I understand what your doing but i dont know where it would go in my code. here is the code i am using.
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(0,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.easeIn, 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.easeIn, 0, 100, 1, true);
}
Mazoonist
06-03-2008, 02:51 PM
That code is actionscript 2.0. You're in the wrong forum. Not only that, but depth management is handled differently between the two. So the solution I gave you doesn't even apply to AS2.
Scharpe
06-03-2008, 05:20 PM
well then thats a prob for me i guess.. Sorry bout that!
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.