Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling a library movieclip within function

Status
Not open for further replies.

dallasweb

Programmer
Jan 4, 2001
45
0
0
US
Hello all,

I have a basic image/link rotater. It loads from a XML file and images from a directory. What I'm trying to do is add a alpha tween to images as they are loaded. Here is my action script:

slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("logo_scroller.xml");
slides_xml.ignoreWhite = true;


//
// Show the first slide and intialize variables
function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);

}
}
//

// Updates the current slide with new image and text
function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
URLTarget = newSlideNode.attributes.URLTarget;
slideText = newSlideNode.firstChild.nodeValue;
targetClip.loadMovie(imagePath);
}
//

obj = new Object();
obj.interval = function(){

//this is where you will advance your movie to the correct node
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
} else {
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}
setInterval(obj,"interval",5000);
time = new Object();
function (time){
getTimer();
if (time >=10000){
delete (obj);
}
clearInterval (interval);
}
//

This is my script to fade in the image

if (a<=100) {
setProperty(&quot;/targetClip&quot;, _alpha, a);
a = a+5;
}

I can get it to fade in when I load the first image, but can't get it to run when it loads the next image(s)

Any Ideas? Thanks in advance.
 
I solved it, hopefully will help someone else.


slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load(&quot;logo_scroller.xml&quot;);
slides_xml.ignoreWhite = true;

//
// Show the first slide and intialize variables
function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);

}
}
//
// Updates the current slide with new image and text
function updateSlide(newSlideNode) {

// Fades in the new image
targetClip._alpha = 0;
fader = setInterval(fade,100)
function fade(){
targetClip._alpha += 10;
if(targetClip._alpha >=100)
clearInterval(fader);
}

// Sets values for movie vars
imagePath = newSlideNode.attributes.jpegURL;
URLTarget = newSlideNode.attributes.URLTarget;
slideText = newSlideNode.firstChild.nodeValue;
targetClip.loadMovie(imagePath);
}
//
obj = new Object();
obj.interval = function(){
//this is where you will advance your movie to the correct node


nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
} else {

currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
}
}



setInterval(obj,&quot;interval&quot;,5000);
time = new Object();
function (time){
getTimer();
if (time >=10000){
delete (obj);
}
clearInterval (interval);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top