URGENT HELP - Actionscript Image Fader - Almost There!

  • new_AS
  • Born
  • Born
  • No Avatar
  • Joined: Jan 24, 2007
  • Posts: 3
  • Status: Offline

Post January 24th, 2007, 11:31 am

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);
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 24th, 2007, 11:31 am

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post January 24th, 2007, 2:34 pm

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.
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Post Information

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

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.