A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: making a MC play time in reverse

  1. #1
    Senior Member
    Join Date
    May 2001
    Posts
    485

    making a MC play time in reverse

    Hello,

    Im a bit stuck here, cant find a tutorial which is suitable and need some help.

    i have a flash site with 4 pages, I want to put them all in one MC like so....

    page 1 -- page 2 -- page 3 -- page 4

    Now, if you are on page 1 and click page 3, i want the MC to scroll right until it gets to page 3,

    if you then pick page 2, I would like it to scroll left (in reverse) until it gets to page 2...

    any ideas on the best way to do this?

  2. #2
    Registered User
    Join Date
    Jan 2006
    Posts
    135
    Do you mean that you want the animation to play in reverse? Because there is little animation between two or three frames.

    If that's what you want to obtain, I would put everything in one movie clip
    and make it scroll left and right in relation to its _x property.

    Luka

  3. #3
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    here's an example that slides content horizontally based on specific points. right now it's set up to scroll to coordinates stored in an array, using next/prev buttons...but you could easily change it to use a menu and based on the button pressed, go to the array coordinate for that section. look at http://bit-101.com/tutorials/ for a general intro on Easing... and you can move your clips around anywhere you want...

    (the attached is actually a simplified version of a file gparis gave me a while ago)
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    485
    hi,

    tx madzigian, that is exactly what I want to do. Let me work on it and get back to you

  5. #5
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    sure... i'll look through my files again, i know i have at least a dozen different ways to do what you're looking to do. It also would be hard to alter that code to scroll vertically as well as horizontally, so you could move L-R-U-D instead of just L-R.

    What version of Flash are you using...MX?..MX04? I don't have anything for Flash 8 yet (i haven't upgraded) but i'm sure i have different files for anywhere from Flash 5 through MX04. Also might want to check out http://proto.layer51.com/default.aspx There are a lot of code samples for MovieClip.prototypes that perform similar actions to what i sent you, but the way they are written may make more sense to you, making your life easier. (i personally like to see a few different ways to do the same thing, it helps me understand how to write code on my own)
    Last edited by madzigian; 01-14-2006 at 07:12 PM.
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  6. #6
    Senior Member
    Join Date
    May 2001
    Posts
    485
    Hi,

    Ok, my code is crude, but it works.. i am using global variables and i actually have 6 pages..

    home - profile - solutions- portfolio - lounge - contact

    while the intro is loading I set
    _global.current_selection = "home";

    now, the home button has this code....
    on (press) {
    if (_global.current_selection == "home")
    {

    } else if (_global.current_selection == "profile")
    {
    i--;
    } else if (_global.current_selection == "solutions")
    {
    i--;
    i--;
    } else if (_global.current_selection == "portfolio")
    {
    i--;
    i--;
    i--;
    } else if (_global.current_selection == "lounge")
    {
    i--;
    i--;
    i--;
    i--;
    } else if (_global.current_selection == "contact")
    {
    i--;
    i--;
    i--;
    i--;
    i--;
    }
    _global.current_selection = "home";

    }
    on (release) {
    moveMe(mc1, dirs[i], .2);
    }

    and the portfolio button has this code
    on (press) {
    if (_global.current_selection == "home")
    {
    i++;
    i++;
    i++;
    } else if (_global.current_selection == "profile")
    {
    i++;
    i++;
    } else if (_global.current_selection == "solutions")
    {
    i++;
    } else if (_global.current_selection == "portfolio")
    {

    } else if (_global.current_selection == "lounge")
    {
    i--;

    } else if (_global.current_selection == "contact")
    {
    i--;
    i--;

    }
    _global.current_selection = "portfolio";

    }
    on (release) {
    moveMe(mc1, dirs[i], .2);
    }

    each button has similar code

  7. #7
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    wow.. that works?... no offense but that's the strangest chunk of code i think i have ever seen (other than a few prizes i wrote myself not so long ago... only difference is, mine didn't ever work!)

    anyway.. i updated the fla i sent you previously to do what i think you want it to. The proper value from the dirs Array is all that's really necessary in your button code to move the main clip to the right coordinates
    Code:
    home.onRelease = function() {
    	moveMe(mc1, dirs[0], .2);  
     // dirs[0] refers to the first item in the array which equals the _x position 0
    };
    witht the new sample.. there is no need to set gloobal vars or deall with all those if/else etc. it keeps the code as simple as possible..

    Hope this helps

    see if you find this easier.


    ** also, check out this site : http://flashtothecore.praystation.com/ go to "Chapter 21" and look at the scrolling example... it's flawless!
    Last edited by madzigian; 01-17-2006 at 07:54 PM. Reason: updated the previous fla and found a great resource!!
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  8. #8
    Senior Member
    Join Date
    May 2001
    Posts
    485
    tx, so much cleaner..... I know it is a strange cheunk of code... I know how to hack lots of code, not so good at coming up with original .

  9. #9
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    Everything I know how to do in terms of writing code, I either learned from dissecting other people's FLA files, or from reading posts on this forum. (yea, i read a little and did a couple tutorials, but never really learned from them) But i used to make myself physically type out and code chunks i was using from random source files and eventually I started to figure out what each portion did and how to alter it to do what I wanted. Gradually, i just started to write things on my own because all the basics are built on a basic template/structure (for lack of a better word)
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  10. #10
    Senior Member
    Join Date
    May 2001
    Posts
    485
    hello,

    one more question, i need to have buttons that are inside mc1 in different movie clips (i can have up to 3 MC all inside eachother) control mc1 , but i cant get it to work..

    I tried this... with no luck
    home.onRelease = function() {
    moveMe(_root.mc1, dirs[0], .2);
    };

  11. #11
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    i don't know what you mean.... are you trying to control mc's within the main mc from the root timeline>,,, or trying to control things from buttons within the main mc?.. if you're trying to do the latter.. it's not working because you pathing is incorrect... put everything together with a breif description of what you're trying to accomplish, and send it to me, and i'll fix it for you.. sound good?....
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  12. #12
    Senior Member
    Join Date
    May 2001
    Posts
    485
    Hello,

    Sorry for the late response... This is what im trying to do...

    or trying to control things from buttons within the main mc?.. if you're trying to do the latter.

    inside the main MC (mc1), i created new MCs for each page (or position).. Inside those I have buttons which I would like to control the main timeline.

  13. #13
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    ok.. so if i understand you correctly, you have your mainMC which contains, let's say 2 other mc's (we'll call them mc0, and mc1) So to control the main timeline, from mc0 or mc1 you just need to reference _root.. So let's say you have "testFrame" as a frame label on your main timeline, which is currently stopped. Maybe your mainMC plays some sort of animation or something at 'testFrame'. right on you main timeline (1st frame) where all your other code goes, you put something like this:
    Code:
    _root.mainMC.mc0.onRelease = function () {
    _root.gotoAndPlay('testFrame');
    };
    
    //or
    
    _root.mainMC.mc1.onRelease = function() {
    trace("this mc isn't controlling anything!!");
    };
    if you need help targeting the proper timelines and mc's use the little Target tool in the ActionScript panel (the little button with the crosshairs) then you can select an absolute or relative path directly to the mc you want to target. of course, all of your mc's need instance names (which you should give them as a matter of general practice anyway) you can control any mc from any other mc, as long as you target it correctly (such as controlling the main timeline from externally loaded files, or using a dynamically created clip to control clips create in the authoring environment) you just need to use _root appropriately... I think Macromedia started stressing avoiding the use of _root whenever possible, to avoid a lot of problems that may come up integrating with other files down the road. but i wouldn't worry about it too much right now...

    does that help?... or do you need me to whip up a sample? (or even better, you post a sample and i'll fix it for you so you can see)
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  14. #14
    Senior Member
    Join Date
    May 2001
    Posts
    485
    tx, i never thought of putting the AC on the main timeline, i usually just put it on the button...

    _root.mc1.home.btn_sol.onRelease = function () {
    moveMe(mc1, dirs[2], .2);
    };

  15. #15
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    I used to use a lot of object code myself, until someone introduces me to frame code... then i found it much easier to write, manage, change and just deal with thanobject code is. i could code menu's and buttons with loops and arrays instead of having to write out everything on each mc... you can code things to be less processor intensive becauseinstead of using: onClipEvent (enterFrame) you can code tings into functions and delete the enterFrame action. It also centralizes everything, so you don't need to go sorting througth a million mc's and timeline to change all of your code... Most people use a lot of frame code (from what i have seen) and now are using external scripts and Custom Classes a lot more...
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

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