Professional Web Applications Themes

vertical scrolling movie clip - Adobe Flash, Flex & Director

i sort of sourced online and created a code that i thought would be suitable for vertical scrolling for a touch screen app am currently building with AS3. it works fairly well, just that when i test it on the touch screen it isn't so fluid and responsive to my touch. its a movie clip (scroll_mc) that has been masked and layered over a border movie clip (stageborder) here's the code Code: var speed:Number; var speedArray:Array; var prevY:Number; var DRAG:Number = 20; var HEIGHT:int = 360; scroll_mc.addEventListener(MouseEvent.MOUSE_DOWN, onDown); function onDown(evt:MouseEvent):void { speedArray = new Array(0,0,0,0,0,0,0,0,0,0); speed = 0; prevY = ...

  1. #1

    Default vertical scrolling movie clip

    i sort of sourced online and created a code that i thought would be suitable for vertical scrolling for a touch screen app am currently building with AS3.
    it works fairly well, just that when i test it on the touch screen it isn't so fluid and responsive to my touch.
    its a movie clip (scroll_mc) that has been masked and layered over a border movie clip (stageborder)

    here's the code

    Code:
    var speed:Number;
     var speedArray:Array;
     var prevY:Number;
    
     var DRAG:Number = 20;
    
     var HEIGHT:int = 360;
    
     scroll_mc.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
    
     function onDown(evt:MouseEvent):void {
     speedArray = new Array(0,0,0,0,0,0,0,0,0,0);
     speed = 0;
     prevY = this.mouseY;
     stageborder.addEventListener(Event.ENTER_FRAME, onDownEnter);
     stageborder.addEventListener(MouseEvent.MOUSE_UP, onUp);
     }
    
     function onDownEnter(evt:Event):void {
     var sp = this.mouseY - prevY;
     scroll_mc.y += sp;
     if (scroll_mc.y < (HEIGHT-scroll_mc.height)) {
     scroll_mc.y = (HEIGHT-scroll_mc.height);
     }
     else if (scroll_mc.y > stageborder.y) {
     scroll_mc.y = stageborder.y;
     }
     speedArray.push(sp);
     speedArray.shift();
     prevY = this.mouseY;
     }
    
     function onUp(evt:MouseEvent):void {
     stageborder.removeEventListener(Event.ENTER_FRAME, onDownEnter);
     stageborder.removeEventListener(MouseEvent.MOUSE_UP, onUp);
    
     speed = 0;
     for (var i:int = 0; i<speedArray.length; i++) {
     speed += speedArray[i];
     }
     speed /= speedArray.length;
    
     addEventListener(Event.ENTER_FRAME, onEnter);
     }
    
     function onEnter(evt:Event):void {
     if (Math.abs(speed) < .5) {
     speed = 0;
     }
     if (speed < 0) {
     if (scroll_mc.y > (HEIGHT-scroll_mc.height) - speed) {
     scroll_mc.y += speed;
     speed -= speed/DRAG;
     }
     else {
     scroll_mc.y = (HEIGHT-scroll_mc.height);
     speed = 0;
     }
     }
     else {
     if (scroll_mc.y < 0-speed) {
     scroll_mc.y += speed;
     speed -= speed/DRAG;
     }
     else {
     scroll_mc.y = 0;
     speed = 0;
     }
     }
     }

    i have also attached the demo file am working on,
    can anybody help me in tweaking it so the scrolling is more fluid?


    thanks in advance

    williams
    Attached Files Attached Files
    Last edited by the_first_noel; May 28th at 10:14 PM.
    the_first_noel is offline Junior Member
    Join Date
    May 2012
    Posts
    1

Similar Threads

  1. Only Vertical Scrolling at Table
    By lou bra in forum Macromedia Dynamic HTML
    Replies: 3
    Last Post: November 4th, 10:03 AM
  2. Replies: 0
    Last Post: February 9th, 11:05 PM
  3. Duplicate Movie Clip in a Duplicated Movie Clip...
    By TommyHilfiger webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 2nd, 08:40 AM
  4. vertical scrolling pointer following cursor
    By Joe Magno webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 8
    Last Post: August 23rd, 05:23 PM
  5. Vertical scrolling layer
    By DannyMiller webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 2
    Last Post: July 24th, 02:21 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139