A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: simple scroll problems with onMouseDown

  1. #1
    Junior Member
    Join Date
    Feb 2003
    Posts
    9

    simple scroll problems with onMouseDown

    ok i used one of the tutorial on here regarding a simple scroll, using two buttons and a box of dynamic text. the code for the buttons is:

    on (release) {
    scrolltext.scroll += 1;
    }

    and


    on (release) {
    scrolltext.scroll -= 1;
    }


    what i really want to do is be able to use onMouseDown or anything that will let it scroll by holding the button down instead of have to click it repeatadly, any help would be amazing.

  2. #2
    Sergei A. Kornev Maestro_cK's Avatar
    Join Date
    Jul 2002
    Location
    Saint Petersburg
    Posts
    155
    Here it is:


    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Feb 2003
    Posts
    9
    it let me download it and open it, and i can view the swf but the fla wont open for me. :/ i have no idea why. thanks for the quick help though.

  4. #4
    Sergei A. Kornev Maestro_cK's Avatar
    Join Date
    Jul 2002
    Location
    Saint Petersburg
    Posts
    155
    what is version of Flash You use ?

  5. #5
    Junior Member
    Join Date
    Feb 2003
    Posts
    9
    mx. im on a mac as well, but even so it hasnt ever been an issue before.

  6. #6
    Senior Member Adam14's Avatar
    Join Date
    Feb 2004
    Location
    Ontario Canada
    Posts
    1,116
    on(press){
    onEnterFrame=function(){
    scrolltext.scroll += 1;
    }
    }

    try that...or maybe this, as a frame action:

    btnInstanceName.onEnterFrame=function(){
    this.onPress=function(){
    scrolltext.scroll += 1;
    }
    }

    Adam

  7. #7
    Junior Member
    Join Date
    Feb 2003
    Posts
    9
    this is the error i get when using the first code:

    Scene=Scene 1, Layer=CONTENT, Frame=15: Line 1: Statement must appear within on handler
    btnInstanceName.onEnterFrame=function(){

    i thought for sure that would do it, hmph.

  8. #8
    Senior Member Adam14's Avatar
    Join Date
    Feb 2004
    Location
    Ontario Canada
    Posts
    1,116
    You must be using the second code there...to get that error...use that code, but put it on a frame.

    **Edit, oh, and you have to give your button an instance name and use that instead of:

    btnInstanceName

    Adam

  9. #9
    Junior Member
    Join Date
    Feb 2003
    Posts
    9
    haha my fault yes that wa steh second code, and its obvious why it wasnt working. so i used the first code and it works great BUT, when you click it starts scrolling and doesnt stop until it scrolls teh length haha. speed reading style. any idea how to haveit only scroll while its being pressed? thanks a ton.

  10. #10
    Senior Member Adam14's Avatar
    Join Date
    Feb 2004
    Location
    Ontario Canada
    Posts
    1,116
    The second code should work only while the button is pressed.

    Adam

  11. #11
    Junior Member
    Join Date
    Feb 2003
    Posts
    9
    i tried the second with this code in the frame actions:

    up.onEnterFrame=function(){
    this.onPress=function(){
    scrolltext.scroll -= 1;
    }
    }

    down.onEnterFrame=function(){
    this.onPress=function(){
    scrolltext.scroll += 1;
    }
    }

    and i got no movement. im sorry this is such a hassle seems like itd be so simple.

  12. #12
    Senior Member Adam14's Avatar
    Join Date
    Feb 2004
    Location
    Ontario Canada
    Posts
    1,116
    Actually it was my mistake, so don't feel so bad

    up.onEnterFrame=function(){
    scrolltext.scroll.onPress=function(){
    scrolltext.scroll -= 1;
    }
    }

    down.onEnterFrame=function(){
    scrolltext.scroll.onPress=function(){
    scrolltext.scroll += 1;
    }
    }


    I had "this" in there which was referencing the button and not the text...hope this is better.

    Adam

  13. #13
    Sergei A. Kornev Maestro_cK's Avatar
    Join Date
    Jul 2002
    Location
    Saint Petersburg
    Posts
    155
    Try this.

    Attached Files Attached Files

  14. #14
    Junior Member
    Join Date
    Feb 2003
    Posts
    9
    the latter one works if my text is a movieclip but its a box of dynamic text and doenst want to work. and this one

    up.onEnterFrame=function(){
    scrolltext.scroll.onPress=function(){
    scrolltext.scroll -= 1;
    }
    }

    down.onEnterFrame=function(){
    scrolltext.scroll.onPress=function(){
    scrolltext.scroll += 1;
    }
    }


    shows up and everything but i get no movement. im going nuts haha.

  15. #15
    Senior Member Adam14's Avatar
    Join Date
    Feb 2004
    Location
    Ontario Canada
    Posts
    1,116
    ok...let scrap the whole thing....lol....try this in your first frame:

    code:


    onLoad=function(){
    _root.scrollUp=false;
    _root.scrollDown=false;
    }

    onEnterFrame=function(){
    if (_root.scrollUp==true){
    scrolltext.scroll -= 1;
    }else if (_root.scrollDown==true){
    scrolltext.scroll += 1;
    }
    }



    and on your up button put this:
    code:

    on(press){
    _root.scrollUp=true
    }
    on(release){
    _root.scrollUp=false
    }



    and this on your down button:
    code:

    _root.scrollDown=true
    }
    on(release){
    _root.scrollDown=false
    }



    keeping my fingers crossed on this one.

    Adam

  16. #16
    Junior Member
    Join Date
    Feb 2003
    Posts
    9
    with the frame script it says:

    Scene=Scene 1, Layer=CONTENT, Frame=15: Line 2: ';' expected
    } onEnterFrame =function (){ if (_root .scrollUp== true ){

    :/ haha im such a nuisance

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