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

  • bmcc81
  • Newbie
  • Newbie
  • User avatar
  • Posts: 9

Post 3+ Months Ago

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
Code: [ Select ]
if(i==6) var target_x = home_x-content_mc.section_0._x;
    content_mc.slideTo(target_x,"0",2);
  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.

Code: [ Select ]
var i:Number = 1;

function DoRandom() {
var target_x = home_x - content_mc["section_"+i]._x;
content_mc.slideTo( target_x, "0", 2 );
i++;

if(i==6) var target_x = home_x-content_mc.section_0._x;
    content_mc.slideTo(target_x,"0",2);
}

var intervalID = setInterval(DoRandom, 4000);
  1. var i:Number = 1;
  2. function DoRandom() {
  3. var target_x = home_x - content_mc["section_"+i]._x;
  4. content_mc.slideTo( target_x, "0", 2 );
  5. i++;
  6. if(i==6) var target_x = home_x-content_mc.section_0._x;
  7.     content_mc.slideTo(target_x,"0",2);
  8. }
  9. var intervalID = setInterval(DoRandom, 4000);
Much appreciated for any help,
  • bmcc81
  • Newbie
  • Newbie
  • User avatar
  • Posts: 9

Post 3+ Months Ago

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

I sthis the right idea even.

Code: [ Select ]
function DoRandom() {
for (var i=1; i<6; i++) {
var target_x = home_x - content_mc["section_"+i]._x;
content_mc.slideTo( target_x, "0", 2 );
i++;
}
  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
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

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

you can also do:
Code: [ Select ]
mc.onEnterFrame = function(){ DoRandom(); }
  • tennisaceflink
  • Beginner
  • Beginner
  • tennisaceflink
  • Posts: 58

Post 3+ Months Ago

make sure the movie clip doesnt have a stop actionscript in it
  • bmcc81
  • Newbie
  • Newbie
  • User avatar
  • Posts: 9

Post 3+ Months Ago

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

Code: [ Select ]
if(i==6) {
    i=1;
}
  1. if(i==6) {
  2.     i=1;
  3. }




Code: [ Select ]
import com.mosesSupposes.fuse.*;
ZigoEngine.simpleSetup(Shortcuts);
import mx.transitions.Tween;// IMPORTS MX.TRANSITION.TWEEN
import mx.transitions.easing.*;// IMPORTS MX.TRANSITION.EASING


_root.content_mc.section_0.gotoAndPlay(2);

/////////////////////////////////////////////////////////////////////////////////////

var i:Number = 1;

function DoRandom() {
var target_x = home_x - content_mc["section_"+i]._x;
content_mc.slideTo( target_x, "0", 2 );
content_mc["section_"+i].gotoAndPlay(2);
i++;

if(i==6) {
    i=1;
var target_x = home_x-content_mc.section_0._x;
content_mc.slideTo(target_x,"0",2);
}

if(i==7) {
i = 1;         
var target_x = home_x - content_mc["section_"+i]._x;
content_mc.slideTo( target_x, "0", 2 );

}
trace(i);
if(i==1) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);
    if(i==2) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
    if(i==2) var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 70, 1, true);
    if(i==3) var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
    if(i==3) var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 70, 1, true);
    if(i==4) var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 70, 1, true);
    if(i==4) var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
    if(i==5) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 70, 1, true);
    if(i==5) var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
    if(i==6) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
    if(i==6) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);
    if(i==1) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
};



var intervalID = setInterval(DoRandom, 4000);

/////////////////////////////////////////////////////////////////////////////////////
            //             // BUTTONS //              //
/////////////////////////////////////////////////////////////////////////////////////

var home_x = content_mc._x;

b_0.onRelease = function() {
    clearInterval(intervalID);
    this.content_mc.section_1.gotoAndPlay(2);
    var target_x = home_x-content_mc.section_0._x;
    content_mc.slideTo(target_x,"0",2);
    var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);

    var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);

};

b_1.onRelease = function() {
    clearInterval(intervalID);
    this.content_mc.section_1.gotoAndPlay(2);
    var target_x = home_x-content_mc.section_1._x;
    content_mc.slideTo(target_x,"0",2);
    var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 70, 1, true);

    var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
};

b_2.onRelease = function() {
    clearInterval(intervalID);
    _root.content_mc.sections_2.gotoAndPlay(2);
    var target_x = home_x-content_mc.section_2._x;
    content_mc.slideTo(target_x,"0",2);
    var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 70, 1, true);

    var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
};

b_3.onRelease = function() {
    clearInterval(intervalID);
    _root.content_mc.sections_3.gotoAndPlay(2);
    var target_x = home_x-content_mc.section_3._x;
    content_mc.slideTo(target_x,"0",2);
    var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 70, 1, true);

    var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
};

b_4.onRelease = function() {
    clearInterval(intervalID);
    _root.content_mc.sections_4.gotoAndPlay(2);
    var target_x = home_x-content_mc.section_4._x;
    content_mc.slideTo(target_x,"0",2);
    var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 70, 1, true);

    var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
    var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
};
  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. _root.content_mc.section_0.gotoAndPlay(2);
  6. /////////////////////////////////////////////////////////////////////////////////////
  7. var i:Number = 1;
  8. function DoRandom() {
  9. var target_x = home_x - content_mc["section_"+i]._x;
  10. content_mc.slideTo( target_x, "0", 2 );
  11. content_mc["section_"+i].gotoAndPlay(2);
  12. i++;
  13. if(i==6) {
  14.     i=1;
  15. var target_x = home_x-content_mc.section_0._x;
  16. content_mc.slideTo(target_x,"0",2);
  17. }
  18. if(i==7) {
  19. i = 1;         
  20. var target_x = home_x - content_mc["section_"+i]._x;
  21. content_mc.slideTo( target_x, "0", 2 );
  22. }
  23. trace(i);
  24. if(i==1) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);
  25.     if(i==2) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  26.     if(i==2) var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 70, 1, true);
  27.     if(i==3) var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  28.     if(i==3) var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 70, 1, true);
  29.     if(i==4) var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 70, 1, true);
  30.     if(i==4) var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  31.     if(i==5) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 70, 1, true);
  32.     if(i==5) var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  33.     if(i==6) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  34.     if(i==6) var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);
  35.     if(i==1) var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  36. };
  37. var intervalID = setInterval(DoRandom, 4000);
  38. /////////////////////////////////////////////////////////////////////////////////////
  39.             //             // BUTTONS //              //
  40. /////////////////////////////////////////////////////////////////////////////////////
  41. var home_x = content_mc._x;
  42. b_0.onRelease = function() {
  43.     clearInterval(intervalID);
  44.     this.content_mc.section_1.gotoAndPlay(2);
  45.     var target_x = home_x-content_mc.section_0._x;
  46.     content_mc.slideTo(target_x,"0",2);
  47.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 70, 1, true);
  48.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  49.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  50.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  51.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  52.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  53. };
  54. b_1.onRelease = function() {
  55.     clearInterval(intervalID);
  56.     this.content_mc.section_1.gotoAndPlay(2);
  57.     var target_x = home_x-content_mc.section_1._x;
  58.     content_mc.slideTo(target_x,"0",2);
  59.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 70, 1, true);
  60.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  61.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  62.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  63.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  64.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  65. };
  66. b_2.onRelease = function() {
  67.     clearInterval(intervalID);
  68.     _root.content_mc.sections_2.gotoAndPlay(2);
  69.     var target_x = home_x-content_mc.section_2._x;
  70.     content_mc.slideTo(target_x,"0",2);
  71.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 70, 1, true);
  72.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  73.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  74.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  75.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  76.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  77. };
  78. b_3.onRelease = function() {
  79.     clearInterval(intervalID);
  80.     _root.content_mc.sections_3.gotoAndPlay(2);
  81.     var target_x = home_x-content_mc.section_3._x;
  82.     content_mc.slideTo(target_x,"0",2);
  83.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 70, 1, true);
  84.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  85.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  86.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  87.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 50, 1, true);
  88.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  89. };
  90. b_4.onRelease = function() {
  91.     clearInterval(intervalID);
  92.     _root.content_mc.sections_4.gotoAndPlay(2);
  93.     var target_x = home_x-content_mc.section_4._x;
  94.     content_mc.slideTo(target_x,"0",2);
  95.     var alphaT:Tween = new Tween(b_4, "_alpha", Regular.easeOut, 50, 70, 1, true);
  96.     var alphaT:Tween = new Tween(b_1, "_alpha", Regular.easeOut, 50, 50, 1, true);
  97.     var alphaT:Tween = new Tween(b_2, "_alpha", Regular.easeOut, 50, 50, 1, true);
  98.     var alphaT:Tween = new Tween(b_3, "_alpha", Regular.easeOut, 50, 50, 1, true);
  99.     var alphaT:Tween = new Tween(b_0, "_alpha", Regular.easeOut, 50, 50, 1, true);
  100.     var alphaT:Tween = new Tween(b_5, "_alpha", Regular.easeOut, 50, 50, 1, true);
  101. };

Post Information

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

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