|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have an interaction where the user pulls the handle on a slider (to the right) to move the bottom part of a line to the left of the screen, 120 pixels from the original position (the top of the line stays put, so the line gets longer and has an increasingly steep angle).
The code below is working aok, but here is the problem: The slider bar is 200 pixels long. For the first 50 pixels, the bottom line point should move three quarters of the total length; for the last 150 pixels, it moves the last quarter. When I use if/else statements, the line jumps erratically depending on how fast the slider handle is pulled. Is there any way to calculate the speed to go fast for the first 50 pixels of the slider, and then slow for the last 150? Any help is much appreciated. Thanks Here is the code: //Global variables _global.startX = 184; _global.startY = 270; _global.endX = 285; _global.endY = 165; _global.curveX = 175; _global.curveY = 167; _global.endPoint = 64; _global.distanceX = startX - endPoint; // 184 - 64 = 120 _global.barLength = _root.slider.bar._width - 2; _global.moveUnit = distanceX/barLength; //original curve start coordinates _global.orgStartX = 184; _global.orgStartY = 240; //this is the line that moves when the slider handle is pulled _root.createEmptyMovieClip("drawing",5); drawing.lineStyle(2,0xFF0000,90); drawing.moveTo(startX,startY); drawing.curveTo(curveX,curveY,endX,endY); //slider drag _root.slider.toggle.onPress = function() { this.startDrag(true,0,0,200,0); }; _root.slider.toggle.onRelease = function() { this.stopDrag(); }; this.createEmptyMovieClip("moveCurve",2); _root.moveCurve.onEnterFrame = function() { if (_root.slider.toggle1._x == 0) { startX = orgStartX; } else { startX = orgStartX - (_root.slider.toggle._x * moveUnit); } drawing.clear(); drawing.lineStyle(2,0xFF0000,90); drawing.moveTo(startX,startY); drawing.curveTo(curveX,curveY,endX,endY); } |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Controlling speed of movement with actionscript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|