dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Play forward/reverse & stop - newb question

  1. #1
    Junior Member
    Join Date
    Oct 2003
    Location
    Essex, UK
    Posts
    4

    Play forward/reverse & stop - newb question

    Hi All,

    First of all, great site. Lots of helpfull people on here.

    I wonder if any anyone can help me. I am trying to create a menu that scrolls across the page, using a mask layer so only one heading at a time is visble. There are two buttons that control the scrolling of the menu left and right. At first i had a problem with the reversing of the Menu MC but solved that by searching this site.

    The MC is 7 seperate headings. The idea is that once you hit the fordward/reverse buttons it scrolls to the next heading and stops. Sadly all i get after hitting the buttons is all 7 headings scroll past until the end (or start!) of the MC. I need to beable to get the heading to stop at the correct position until one of the directional buttons are hit again. Any ideas because i'm totally stuck!

    I'm using Flash MX. I really am a numpty when it comes to AS so be gentle! And thanks to anyone that takes time out to check out this post.

    This is the AS for the MC itself:

    onClipEvent (load) {
    stop();
    var speed = 1;
    var direction;
    }
    onClipEvent (enterFrame) {
    if (direction == "ff") {
    gotoAndStop(_currentframe+speed);
    } else if (direction == "rr") {
    gotoAndStop(_currentframe-speed);
    }
    }


    And the forward button:

    on (release) {
    _root.MenuMC.direction = "ff";
    }


    And the back/reverse button:

    on (release) {
    _root.MenuMC.direction = "rr";
    }

    Cheers again!
    Markio.

  2. #2
    Are all 7 headings in one MC?

  3. #3
    Junior Member
    Join Date
    Oct 2003
    Location
    Essex, UK
    Posts
    4
    They certainly are. It's just seemed the obvious way but like i say i no flash expert so i could be making life difficult for myself.

  4. #4
    That would work fine if the content in each section isn't heavy--like if you have a bunch of images or something in each one you would probably want to try an array or a different format altogether cuz it will get laggy. But as far as having 7 section in one clip to scroll left to right, you need to figure out the x position that the MC has to be at for each section to display correctly and put a motion function in there for the MC and use your buttons to set the target. I'll give you a function assuming that each section is the same width; Start out by setting the starting position of your 7-sectioned MC on the stage and put this code on the MC itself--giving it an instance name of "content_mc":

    onClipEvent(enterFrame){
    this._x +=(targx-this._x)/4;
    }

    this just sets some motion math that will refresh continuously and uses a variable ="targx", which will be the x target for each section. Sorry if you are understanding all of this--I'm being thorough just in case. Then on the root timeline--or whatever timeline is holding the buttons & the content, set a variable for the width of each section, let's say 400, so on the root timeline:

    content_width = 400;

    and let's say that the start x position of the content_mc is 20, then on each button put this code:

    Button 1:
    on (press){
    _parent.content_mc.targx = 20;
    }

    Button 2:
    on (press){
    _parent.content_mc.targx = 20 + _parent.content_width;
    }

    Button 3:
    on (press){
    _parent.content_mc.targx = 20 + _parent.content_width*2;
    }

    Button 4:
    on (press){
    _parent.content_mc.targx = 20 + _parent.content_width*3;
    }

    and so on....hopefully that works for you!

    /Chris

  5. #5
    Junior Member
    Join Date
    Oct 2003
    Location
    Essex, UK
    Posts
    4
    Thanks for the help but to be honest, i'm a bit confused! I can paste your code into the MC itself but you mention more than two buttons. I have only two buttons, one forward, one back. Did you mean enter the 'button' code for each of the headings?

    Sorry to be such a numbnuts but could you clarify?

    Cheers mate.
    /Mark.

  6. #6
    not a free man 51055's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    120
    looking at your script, the reason it won't stop scrolling is that there's nothing to change the 'direction' variable back to 'none'(or whatever, just not 'ff' or 'rr').
    what you need is to put in something to change the variable when the headings are in the right places.

    If I've understood this right (I rarely do ) the headings movie clip is made up of the headings moving from right to left over the period of 100 frames (or however many). If this is the case then
    In every frame with a heading in the right position place an empty movie clip with the following AS
    onClipEvent (load) {
    _root.MenuMC.direction = "none";
    }
    that should stop it till they click again.

    hope that helps

    andy

  7. #7
    Junior Member
    Join Date
    Oct 2003
    Location
    Essex, UK
    Posts
    4
    Excellent! It works. Cheers for both of your help guys, i found that Andy's idea worked a treat.

    At first it only worked in the forward direction but that was because i had created multiple, not single frames for each black MC.

    I only hope that i can contribute to this forum at some point.

    Cheers again!
    Mark.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center