SunQuest
           Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 27th, 2003, 12:25 AM
pramenjatchek pramenjatchek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 6 pramenjatchek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Controlling speed of movement with actionscript

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);

}

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Controlling speed of movement with actionscript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway