A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: scrolling text

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Location
    Wonder Lake, Ill-i-NOISE
    Posts
    19

    scrolling text

    i am having trouble that i hope somebody may be able to help me with. i have a text field that i can have scroll 1 line at a time, each time i click the scroll button. what i would like to do is have the text be able to continue scrolling while the button is being depressed. any help would be greatly appreciated. below is the code i already have implemented. thanks.

    //-------------scroll buttons--------------\\

    upButtonContact.addEventListener(MouseEvent.CLICK, scrollUp);
    downButtonContact.addEventListener(MouseEvent.CLIC K, scrollDown);

    function scrollUp(event:MouseEvent):void
    {
    textBox.scrollV --;
    }

    function scrollDown(event:MouseEvent):void
    {
    textBox.scrollV ++;
    }

    //-------------/scroll buttons--------------\\

  2. #2
    Junior Member
    Join Date
    Jun 2007
    Posts
    24
    It seems to me that you could use a loop to keep repeating the scroll up or down command untill the mouse is released.

  3. #3
    Junior Member
    Join Date
    Jun 2007
    Location
    Wonder Lake, Ill-i-NOISE
    Posts
    19
    i attempted to do that but i was unsuccessful. do you have any suggestions. i defined a variable to repeat 20 times, just for a test run. and instead of putting ++ or -- i tried imputing the variable a few different ways, but still no luck.

  4. #4
    Junior Member
    Join Date
    Jun 2007
    Posts
    24
    The logic behind it would be...

    When mouse is depressed {

    Declare var counter = 0
    While counter <1000
    scoll down or up

    the length should cover for as long as it would take to scroll the text.

    Alternativly...you could link the loop statement so that it loops untill the mouse is released...Im still at the point where I can think of ways to solve things...but Im not very good at using AS to implement them yet...

    hopefully this helps a bit, but I do not think I can be of much more help

  5. #5
    Junior Member
    Join Date
    Jun 2007
    Location
    Wonder Lake, Ill-i-NOISE
    Posts
    19
    i haven't tried it yet, but thanks for all your input. im basically at the same point as you. i know what i want to do and how to go about it. but not really sure how to make it work.

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    function upscroll(e:Event)
    {
    e.currentTarget.scrollV ++;
    }
    textBox.addEventListener(Event:ENTER_FRAME, upscroll);


    Do the same for the other direction.

    Then add

    function mouseUp(e:MouseEvent)
    {
    textBox.removeEventListener(Event.ENTER_FRAME, upScroll);
    }
    upButtonContact.addEventListener(MouseEvent.MOUSE_ UP, mouseUp);
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Junior Member
    Join Date
    Jun 2007
    Location
    Wonder Lake, Ill-i-NOISE
    Posts
    19
    is ENTER_FRAME what i would actually put in or do i put the frame number that im trying to command?

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    That is an event, which will continously let your scroll move.
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Junior Member
    Join Date
    Jun 2007
    Location
    Wonder Lake, Ill-i-NOISE
    Posts
    19
    when i run the movie with the text as is. it says there is an error in the following line:

    textBox.addEventListener(Event:ENTER_FRAME, upscroll);

    it says:

    1084: Syntax error: expecting rightparen before colon.

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Sorry, must be Event.ENTER_FRAME
    - The right of the People to create Flash movies shall not be infringed. -

  11. #11
    Junior Member
    Join Date
    Jun 2007
    Location
    Wonder Lake, Ill-i-NOISE
    Posts
    19
    so. i hope this isn't getting to be a huge pain for you. but now it kind of works. i've copied the code for each button and made the appropriate changes. now......only the down button works, and when it does, it scrolls all the way to the bottom of the text file even when you click and release right away. below is the script i'm using now. thanks for all the help so far.



    function downscroll(e:Event)
    {
    e.currentTarget.scrollV ++;
    }
    textBox.addEventListener(Event.ENTER_FRAME, downscroll);


    function mouseUp(e:MouseEvent)
    {
    textBox.removeEventListener(Event.ENTER_FRAME, downscroll);
    }
    upButtonContact.addEventListener(MouseEvent.MOUSE_ DOWN, mouseUp);



    function upScroll(e:Event)
    {
    e.currentTarget.scrollV --;
    }
    textBox.addEventListener(Event.ENTER_FRAME, upScroll);


    function mouseDown(e:MouseEvent)
    {
    textBox.removeEventListener(Event.ENTER_FRAME, upScroll);
    }
    downButtonContact.addEventListener(MouseEvent.MOUS E_DOWN, mouseDown);

  12. #12
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I had only made a suggestion. The implementation is more complex:
    PHP Code:
    var isScroll:Boolean;
    function 
    mouseDownScroll (e:MouseEvent)
    {
        
    isScroll true;
        function 
    downscroll (e:Event)
        {
            if (!
    isScroll)
            {
                
    e.target.removeEventListener (Event.ENTER_FRAMEdownscroll);
            }
            
    e.target.scrollV++;
        }
        
    textBox.addEventListener (Event.ENTER_FRAMEdownscroll);
    }


    function 
    mouseUpscroll (e:MouseEvent)
    {
        
    isScroll true;
        function 
    upScroll (e:Event)
        {
            if (!
    isScroll)
            {
                
    e.target.removeEventListener (Event.ENTER_FRAMEupScroll);
            }
            
    e.target.scrollV--;
        }
        
    textBox.addEventListener (Event.ENTER_FRAMEupScroll);
    }

    function 
    mouseUpEvent (e:MouseEvent)
    {
        
    isScroll false;
    }
    upButtonContact.addEventListener (MouseEvent.MOUSE_DOWNmouseDownScroll);
    downButtonContact.addEventListener (MouseEvent.MOUSE_DOWNmouseUpscroll);
    addEventListener (MouseEvent.MOUSE_UPmouseUpEvent); 
    - The right of the People to create Flash movies shall not be infringed. -

  13. #13
    Junior Member
    Join Date
    Jun 2007
    Location
    Wonder Lake, Ill-i-NOISE
    Posts
    19
    thanks so much for your help. it works great. thats one of the final headaches i have left.

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