A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 34 of 34

Thread: scroll multiple movie clips

  1. #21
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Check how it's done here and adapt it?

    http://www.flashkit.com/tutorials/Ac...-696/index.php

  2. #22
    Member
    Join Date
    Apr 2003
    Location
    Brisbane, Australia
    Posts
    53
    yeah thats what i thought... but cant seem to get it working.
    its close though.

    heres the problem:
    //this is within the 2nd frame of the MC which the scrollUp button calls


    trace("frame2");
    if (_root.contain.content._y > (leastHeight * -1)) {
    trace("called up");
    _root.contain.content._y = _root.contain.content._y - 5;


    the first trace is called, showing that it actually does get here, but the 2nd one isent. This suggests that it is not passing the if statement, but i cant see why because it was working perfectly when it was attached to the button itself...

  3. #23
    Member
    Join Date
    Apr 2003
    Location
    Brisbane, Australia
    Posts
    53
    ahh, i worked out its coz "leastHeight" variable is not defined...
    but it should be. its defined whenever a clip is loaded...

  4. #24
    Member
    Join Date
    Apr 2003
    Location
    Brisbane, Australia
    Posts
    53

    global variables are nice :)

    hehe, ok so i now know all about variable scope

    it seems to be working pretty well now!

    thanks x100 to oldnewbie and retrotron!
    you guys rock

    ill post the link when i get it up

  5. #25
    thinking is design retrotron's Avatar
    Join Date
    Apr 2003
    Location
    Utah
    Posts
    141
    Wow, I feel left out. I didn't notice the "page 2" button, so I was still back on the question about scrolling. I came up with what is posted here below, but now that I've discovered this whole new second page of posts, OldNewbie's recommended tutorial does it too. My method might be a bit easier, but it will only work with MX.

    I have a .fla with three symbols in the library. One is a tall rectangle placed on the stage with an instance name of "content_mc" (this is what will be scrolled). The other two are standard buttons named "up_btn" and "down_btn" respectively. The two buttons can be anywhere on the stage, as can the "content_mc".

    (the .fla is zipped and attached below)

    Then you simply paste in this code:

    PHP Code:
    // -----------------------------------------------------------
    // click handlers for the mouse buttons
    // -----------------------------------------------------------

    // do this when up_btn is clicked
    _root.up_btn.onPress = function() {
        
    pressInterval setInterval(moveUp,10); // execute moveUp() every 10 milliseconds
    // end onPress() function

    // do this when down_btn is clicked
    _root.down_btn.onPress = function() {
        
    pressInterval setInterval(moveDown,10); // execute moveDown() every 10 milliseconds
    // end onPress() function

    // -----------------------------------------------------------
    // functions which control the movement of content_mc
    // -----------------------------------------------------------

    // move content_mc up 5 px
    function moveUp() {
        
    _root.content_mc._y _root.content_mc._y 5;
    // end moveUp() 

    // move content_mc down 5 px
    function moveDown() {
        
    _root.content_mc._y _root.content_mc._y 5;
    // end moveUp() 

    // -----------------------------------------------------------
    // define the mouse listener
    // -----------------------------------------------------------

    // create an object which will serve as the "listener"
    var mouseListener = new Object();
    // create an event to "listen" for (in this case, when the mouse button is released)
    mouseListener.onMouseUp = function() {
        
    clearInterval(pressInterval); // stop pressInterval from executing every 100 milliseconds    
    // end onMouseUp()
    // register the listener with the Mouse object
    Mouse.addListener(mouseListener);

    // end of code // 
    It makes use of two important functions: (1) "setInterval()" and (2) a "listener".

    (1) setInterval() simply executes a function every x number of seconds. In this case, the function "moveUp()" or "moveDown()" (depending on which button is clicked) is executed every 10 milliseconds, so content_mc is moved 5px in the proper direction each iteration.


    At this point the trick is to get the setInterval() to stop doing this every 10 milliseconds. You'll notice that I named the setInterval() process as "pressInterval". To stop an Interval from executing, you use the command "clearInterval(name_of_interval);".

    (2)However, we need to stop the Interval only when the mouse button is released. That's where the "listener" comes in. This last part may be a little tricky to follow, but don't worry about it if that's the case. It works, so just copy the code. In any case, here's an explanation:

    First we create an object which we will use as a "listener" (called "mouseListener"). Then we add an event to that object: onMouseUp(). Finally, we register this object with the Mouse object as a "listener" with the last line of code. Once registered, the Mouse object will keep its eye on "mouseListener", watching for "onMouseUp" to happen. When it occurs, then the code in the .onMouseUp() function will be executed (in this case, it clears pressInterval, hence the scrolling stops).

    (Technically, .onMouseUp() is a global listener event, so it will execute anytime the mouse button goes up. However, unless the user has clicked on a button, no pressInterval will have been defined, so nothing happens. But that's exactly what we want.)

    Anyways, as you can see, the code can all be located on one frame rather than strewn all over the place like the tutorial mentioned above has it. This makes it much easier to debug and use again in other .flas.

    Well, I'm probably too late since you guys been chatting here for a while, but that's the way I do the scrolling thing.

    retrotron
    Attached Files Attached Files

    absconditus.com // experiments in actionscripted design

    "I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass

  6. #26
    Member
    Join Date
    Apr 2003
    Location
    Brisbane, Australia
    Posts
    53
    thats really cool retrotron.
    i'll see if i can incorporate it with all the other stuff that is going on in my movie

  7. #27
    thinking is design retrotron's Avatar
    Join Date
    Apr 2003
    Location
    Utah
    Posts
    141
    Just for future fun, check out how the scrollbar was done on this site:

    http://www.themet.co.uk/flash-pieces/metmorning.swf

    Click on the "Resident" link to see the scrollbar. I believe this can be done by "skinning" the components. Or if not, it could easily be done via the coding logic we've covered in this thread. It's not a wild departure from linear design, but it's a start!

    absconditus.com // experiments in actionscripted design

    "I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass

  8. #28
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Just made this for somebody this morning to scroll movieclips before I saw this thread, just for completeness. Can be adapted to any movieclip.

    http://can_info_guide.tripod.com/com...rollerfla.html
    - The right of the People to create Flash movies shall not be infringed. -

  9. #29
    Member
    Join Date
    Apr 2003
    Location
    Brisbane, Australia
    Posts
    53
    retrotron: thats pretty cool! thanks for the link

    cencerinform: where were you 3 days ago? hehehe



    PS, anyone know what the deal is with displaying system font text in flash?
    i posted another thread about it, but no one seems to know much...

    for some reason system fonts dont show up for me when i export the movie

  10. #30
    thinking is design retrotron's Avatar
    Join Date
    Apr 2003
    Location
    Utah
    Posts
    141
    Kirin,

    Did you ever get this site working? I'd love to see it if you did!

    absconditus.com // experiments in actionscripted design

    "I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass

  11. #31
    Member
    Join Date
    Apr 2003
    Location
    Brisbane, Australia
    Posts
    53
    hey retrotron!
    sorry i forgot to keep you updated!

    well i got the scroller working and stuff. unfortunately i got really busy doing 3D and other stuff, so i still didnt manage to finish all the design and content (actually there is almost no content yet)

    but im still doing it once i can get some time.

    well if you want to have a look at the progress so far you can, but remember its still at a very simple stage.

    the only section of the navigation that works now is "background".
    by the way, this site is a support website for what will be my final project in my course if you are wondering what its about

    if you remember, we talked about the design being inspired by kanji...
    you can see that the shape of the navigation and content area is defined by the kanji meaning "to make" (tsukuru)
    as this is a production report site for the short film i will make.

    anyway, here is the link:
    http://student.ci.qut.edu.au/~n2753685/ue/reports.html


    i hope to make it much better soon.

    and again, very much thanks for your help in getting the scroller going

  12. #32
    thinking is design retrotron's Avatar
    Join Date
    Apr 2003
    Location
    Utah
    Posts
    141
    I love it! Bravo! Very cool!

    (as you can tell, I very much like your idea to use the character as the layout inspiration).

    In the meantime I've pursued other ways of doing the scrolling thing, and one simple way is using a simple onRollOver to start a setInterval which moves the desired content, and a simple OnRollOut to clear that interval. It's much simpler than all the stuff we figured out before:
    code:

    myBtn_btn.onRollOver = function() {
    scrollInterval = setInterval(moveContent, 5);
    } // end onRollOver()

    myBtn_btn.onRollOut = function() {
    clearInterval(scrollInterval);
    } // end onRollOut()

    function moveContent() {
    myContent_mc._y += 5;
    } // end moveContent()


    Anyways, I've attached two separate scrolling studies if you wish to look at/use the code. One rotates the content (_rotation += 5), the other just scrolls it (_y += 5).

    I hope your time allows you to finish well. Good luck!
    Attached Files Attached Files

    absconditus.com // experiments in actionscripted design

    "I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass

  13. #33
    Member
    Join Date
    Apr 2003
    Location
    Brisbane, Australia
    Posts
    53
    cool!
    thanks very much, i'll see if i cam put some of that stuff to good use
    and i'll keep you updated with my progress if you want. im gunna try and do some cool interactive stuff when i have time.

    if you want, pm me with your email or icq/msn detail

  14. #34
    thinking is design retrotron's Avatar
    Join Date
    Apr 2003
    Location
    Utah
    Posts
    141
    I'll do that.

    absconditus.com // experiments in actionscripted design

    "I really must get a thinner pencil. I ca'n't manage this one a bit: it writes all manner of things that I don't intend". // Alice, Through the Looking Glass

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