Problem with xml picture gallery = fade in fade out clip

  • spyan
  • Newbie
  • Newbie
  • User avatar
  • Posts: 6
  • Loc: Grenoble, france

Post 3+ Months Ago

Hey everyone!
I'm trying to have the following clips "motion1" and "motion2" fade in and out with alpha values. I got them to fade in (using if (motion1._alpha<100){motion1._alpha +=0.9}), and I just can't mak'em fade out.
Here's the code, I've commented it as much as i could, could anyone check it out?
Just as a reminder, the "delay" value tells how long the image stays displayed before it is changed...What I'm trying to do is having the "motion1" and "motion2" movie clips gradually appear when the image changes for exemple, with the delay value = on 19500, motion1 and 2 fade in; on 20500, motion1 and 2 fade out...

I hope I'm making sense, overall I hope I get through this code one day! PLEAAAAAAASE help me out!



delay = 20000;
//-----------------------LOAD XML-------------------------------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
//LOADER SECTION----------------------------------------------------
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
//-------------LOAD PICTURE+boucle alpha pour images et motionclips--------------

---Warning line below part of else
if (picture._alpha<100) {
picture._alpha += 50;
}if (motion1._alpha<100)
motion1._alpha += 0.9;
}
if (motion2._alpha<100) {
motion2._alpha += 0.9;
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • krismeister
  • Graduate
  • Graduate
  • krismeister
  • Posts: 202

Post 3+ Months Ago

If you're using MX2004 or later, maybe you're interested in using the tween class. I believe it's much easier than what you are doing.

fade in would be written like:
Code: [ Select ]
var tFadeIn :Tween = new Tween(picture, "_alph", None, 0 , 100 ,1);

and the breakdown

Tween(movie clip, property to tween, effect,beginning value, ending value, number of second for tween to last)

fade out would be written like:
Code: [ Select ]
var tFadeOut :Tween = new Tween(picture, "_alph", None, 100 , 0,1);

simple right?

If you're interested in trying it out, go over the tutorial here:
http://www.kirupa.com/developer/actionscript/tween.htm
  • spyan
  • Newbie
  • Newbie
  • User avatar
  • Posts: 6
  • Loc: Grenoble, france

Post 3+ Months Ago

Thanks Krismeister, u rule.
Of course I'm interested in trying it out!
I'll be doin' the tutorial DI-rectly!
Keep up the great work, peace!

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 5 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.