Skip navigation
lija30 11 posts
Mar 2, 2012
Currently Being Moderated

Scrolling background will not stop

Mar 2, 2012 8:43 AM

Tags: #background #scrolling #flash #stop

I am trying to make a horzontial flash scrolling background and I cant seem to get it to stop at the last frame.

 


animator=createEmptyMovieClip('animator',1);
bg_1=animator.attachMovie('bg_mc','bg_1',1);
bg_2=animator.attachMovie('bg_mc','bg_2',1);
bg_1._x=-bg_1.width/2;
bg_1._x=-bg_2.width/2;
speed=1;
lockerWidth=550;
animator.onEnterFrame=function(){
          bg_1._x-=speed;
          bg_2._x-=speed;
          if(bg_1._x<=-bg_1._width)bg_1._x=lockerWidth;
          if(bg_2._x<=-bg_2._width)bg_2._x=lockerWidth;
}



I have a attached a ms doc showing how it looks in flash 





 
Replies
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 2, 2012 9:06 AM   in reply to lija30

    when do you want to terminate that loop?

     

    (and, does your 5th line of code contain a typo?)

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 2, 2012 12:25 PM   in reply to lija30

    which movieclip's frame 30?  the main timeline?  the timeline that contains that code?  bg_mc?

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 4, 2012 3:32 PM   in reply to lija30

    what's the name of the movieclip that you don't want to loop?

     

    (and, bg_1 doesn't exist once you create bg_2, so if you don't have a typo, you have an error in logic.)

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 4, 2012 6:09 PM   in reply to lija30

    bg_mc is your linkage id.  if you want all your attached bg_mc instances to stop on frame 30, attach the following to frame 30 of your movieclip with linkage id = "bg_mc":

     

    stop()

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 4, 2012 9:45 PM   in reply to lija30

    are you trying to stop if from looping (if so, attach a screen shot that shows its timeline and the actions panel with the stop() in frame 30) or are you trying to stop it from moving?

     

    and, fix the code you showed:

     

    animator=createEmptyMovieClip('animator',1);
    bg_2=animator.attachMovie('bg_mc','bg_2',1);
    speed=1;
    lockerWidth=550;
    animator.onEnterFrame=function(){
              bg_2._x-=speed;
              if(bg_2._x<=-bg_2._width){

    bg_2._x=lockerWidth;
    }

    }

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 5, 2012 10:59 AM   in reply to lija30

    is the problem your sound that's not stopping?  if so, assign its sync property to stream.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points