How do I make it Play Again & Again & Again & Again

  • bmcc81
  • Newbie
  • Newbie
  • User avatar
  • Joined: 07 May 2008
  • Posts: 9
  • Status: Offline

Post May 8th, 2008, 7:21 am

I just want to make this loop or start over. :arrow:

What happens is the Function Do Random goes through the slideTo content_mc["section_"+i]._x; that moves along the _X axis


but once it get's to the end the It say's
  1. if(i==6) var target_x = home_x-content_mc.section_0._x;
  2.     content_mc.slideTo(target_x,"0",2);
I just wanna make this thing start over and play again & again & again.

  1. var i:Number = 1;
  2.  
  3. function DoRandom() {
  4. var target_x = home_x - content_mc["section_"+i]._x;
  5. content_mc.slideTo( target_x, "0", 2 );
  6. i++;
  7.  
  8. if(i==6) var target_x = home_x-content_mc.section_0._x;
  9.     content_mc.slideTo(target_x,"0",2);
  10. }  
  11.  
  12. var intervalID = setInterval(DoRandom, 4000);
Much appreciated for any help,
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 8th, 2008, 7:21 am

  • bmcc81
  • Newbie
  • Newbie
  • User avatar
  • Joined: 07 May 2008
  • Posts: 9
  • Status: Offline

Post May 8th, 2008, 7:30 am

I just looked up how to do this loop, but it doesn't work.

I sthis the right idea even.

  1. function DoRandom() {
  2. for (var i=1; i<6; i++) {
  3. var target_x = home_x - content_mc["section_"+i]._x;
  4. content_mc.slideTo( target_x, "0", 2 );
  5. i++;
  6. }


Thanks
  • graphixboy
  • Professor
  • Professor
  • No Avatar
  • Joined: 11 Jul 2005
  • Posts: 752
  • Loc: Minneapolis, MN
  • Status: Offline

Post May 8th, 2008, 7:55 am

the set interval should loop until you do a clearInterval(). Basically you're code should repeat every 4 seconds...

you can also do:
  1. mc.onEnterFrame = function(){ DoRandom(); }
//// Designer & Art Director for Interactive, Motion and 3D \\\\
Proof @ WhenImNotSleeping.com

Post May 8th, 2008, 8:21 am

make sure the movie clip doesnt have a stop actionscript in it
  • bmcc81
  • Newbie
  • Newbie
  • User avatar
  • Joined: 07 May 2008
  • Posts: 9
  • Status: Offline

Post May 8th, 2008, 1:03 pm

So, It's been figured out.

Basically it was setting i back to 1

I did it in two places.

Works Great!!!

Bmc81 Horizontal Menu

  1. if(i==6) {
  2.     i=1;
  3. }




  1. import com.mosesSupposes.fuse.*;
  2. ZigoEngine.simpleSetup(Shortcuts);
  3. import mx.transitions.Tween;// IMPORTS MX.TRANSITION.TWEEN
  4. import mx.transitions.easing.*;// IMPORTS MX.TRANSITION.EASING
  5.  
  6.  
  7. _root.content_mc.section_0.gotoAndPlay(2);
  8.  
  9. /////////////////////////////////////////////////////////////////////////////////////
  10.  
  11. var i:Number = 1;
  12.  
  13. function DoRandom() {
  14. var target_x = home_x - content_mc["section_"+i]._x;
  15. content_mc.slideTo( target_x, "0", 2 );
  16. content_mc["section_"+i].gotoAndPlay(2);
  17. i++;
  18.  
  19. if(i==6) {
  20.     i=1;
  21. var target_x = home_x-content_mc.section_0._x;
  22. content_mc.slideTo(target_x,"0",2);
  23. }
  24.  
  25. if(i==7) {
  26. i = 1;        
  27. var target_x = home_x - content_mc["section_"+i]._x;
  28. content_mc.slideTo( target_x, "0", 2 );
  29.  
  30. }
  31. trace(i);
  32. if(i==1) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);
  33.     if(i==2) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  34.     if(i==2) var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 70, 1, true);
  35.     if(i==3) var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  36.     if(i==3) var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 70, 1, true);
  37.     if(i==4) var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 70, 1, true);
  38.     if(i==4) var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  39.     if(i==5) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 70, 1, true);
  40.     if(i==5) var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  41.     if(i==6) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  42.     if(i==6) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);
  43.     if(i==1) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  44. };
  45.  
  46.  
  47.  
  48. var intervalID = setInterval(DoRandom, 4000);
  49.  
  50. /////////////////////////////////////////////////////////////////////////////////////
  51.             //              //  BUTTONS   //                //
  52. /////////////////////////////////////////////////////////////////////////////////////
  53.  
  54. var home_x = content_mc._x;
  55.  
  56. b_0.onRelease = function() {
  57.     clearInterval(intervalID);
  58.     this.content_mc.section_1.gotoAndPlay(2);
  59.     var target_x = home_x-content_mc.section_0._x;
  60.     content_mc.slideTo(target_x,"0",2);
  61.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);
  62.  
  63.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  64.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  65.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  66.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  67.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  68.  
  69. };
  70.  
  71. b_1.onRelease = function() {
  72.     clearInterval(intervalID);
  73.     this.content_mc.section_1.gotoAndPlay(2);
  74.     var target_x = home_x-content_mc.section_1._x;
  75.     content_mc.slideTo(target_x,"0",2);
  76.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 70, 1, true);
  77.  
  78.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  79.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  80.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  81.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  82.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  83. };
  84.  
  85. b_2.onRelease = function() {
  86.     clearInterval(intervalID);
  87.     _root.content_mc.sections_2.gotoAndPlay(2);
  88.     var target_x = home_x-content_mc.section_2._x;
  89.     content_mc.slideTo(target_x,"0",2);
  90.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 70, 1, true);
  91.  
  92.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  93.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  94.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  95.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  96.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  97. };
  98.  
  99. b_3.onRelease = function() {
  100.     clearInterval(intervalID);
  101.     _root.content_mc.sections_3.gotoAndPlay(2);
  102.     var target_x = home_x-content_mc.section_3._x;
  103.     content_mc.slideTo(target_x,"0",2);
  104.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 70, 1, true);
  105.  
  106.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  107.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  108.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  109.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  110.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  111. };
  112.  
  113. b_4.onRelease = function() {
  114.     clearInterval(intervalID);
  115.     _root.content_mc.sections_4.gotoAndPlay(2);
  116.     var target_x = home_x-content_mc.section_4._x;
  117.     content_mc.slideTo(target_x,"0",2);
  118.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 70, 1, true);
  119.  
  120.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  121.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  122.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  123.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  124.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  125. };

Post Information

  • Total Posts in this topic: 5 posts
  • Moderators: joebert, digitalMedia, UNFLUX
  • Users browsing this forum: No registered users and 41 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
 
 

© Unmelted Enterprises 1998-2008. Driven by phpBB © 2001-2008 phpBB Group.

 
 
 
 

Need a pre-made web design for your website?

Check out our templates here: Ozzu Templates


400+ FREE Website Templates. Download Now!