URGENT HELP - Actionscript Image Fader - Almost There!

  • new_AS
  • Born
  • Born
  • new_AS
  • Posts: 3

Post 3+ Months Ago

Hi there,

This may seem veru basic but i am new to this!

I am aiming to create a looping array of images so that each fades in and fades out again ... here is the code i have so far ... it works EXCEPT ... it stops at the end of the array (need an infinate loop!)and appears to jump or hop a little between images (probably the fade rate or alpha) ... want it to be smoother.

Can anyone help me? I am in need of a helping hand!

Code: [ Select ]
var aImages:Array = new Array("flashcontent.png", "flashcontent2.png", "flashcontent3.png");[/quote][quote]
var imageFolder = "../images/";
var fadeRate:Number = 1;
var imageCounter:Number = 0;


function imageFade (selectedImage) {

onEnterFrame = function()
{
selectedImage._alpha += fadeRate;
if (selectedImage._alpha > 100 )
{
fadeRate *= -1;
}
if (selectedImage._alpha < 6)
{
imageCounter++;
if (imageCounter>aImages.length-1)
{
onEnterFrame = null;
selectedImage._alpha = 0;
break;
}
else
{
mcContainer.loadMovie(imageFolder+aImages[imageCounter]);
fadeRate *=-1;
}
}
}

}

mcContainer._alpha = 12;
mcContainer.loadMovie(imageFolder+aImages[0]);
imageFade(mcContainer);
  1. var aImages:Array = new Array("flashcontent.png", "flashcontent2.png", "flashcontent3.png");[/quote][quote]
  2. var imageFolder = "../images/";
  3. var fadeRate:Number = 1;
  4. var imageCounter:Number = 0;
  5. function imageFade (selectedImage) {
  6. onEnterFrame = function()
  7. {
  8. selectedImage._alpha += fadeRate;
  9. if (selectedImage._alpha > 100 )
  10. {
  11. fadeRate *= -1;
  12. }
  13. if (selectedImage._alpha < 6)
  14. {
  15. imageCounter++;
  16. if (imageCounter>aImages.length-1)
  17. {
  18. onEnterFrame = null;
  19. selectedImage._alpha = 0;
  20. break;
  21. }
  22. else
  23. {
  24. mcContainer.loadMovie(imageFolder+aImages[imageCounter]);
  25. fadeRate *=-1;
  26. }
  27. }
  28. }
  29. }
  30. mcContainer._alpha = 12;
  31. mcContainer.loadMovie(imageFolder+aImages[0]);
  32. imageFade(mcContainer);
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

sure, since you make onEnterFrame = null; then it stops.
Anyway, you need something more for this, and also you can use tween transition. See my post, maybe you get something out of it.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 7 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.