Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Actionscripting

Categories Draw Full Line Through Any Two Points
Author: Vernon Morris | Website: http://www.mathwarehouse.com/ |

 
Page 3
«prev 1 2 3

' Line Tutorial Page Three
In the next part, our function will look at the magnitude of our slope. If the slope is vertically oreinted or has an absolute value greater than 1, then we will draw our line 1 way, and if the line ihorizontally oriented a different way. It took me a while to realize why my lines where sometimes blurring, but it was becuase I was drawing them to several thousound pixels beyond the Stage's height, and apparently that is too much for Flash to do without some distortion.
// the next block is how we will draw the line
// if the absolute value of the slope is greater than 1
else if( (Math.abs( _slope )> 1) && (_slope != 0) )
{
// the next few variables will be soon be used
// when we draw our line
var newDeltY:Number;
var newDeltY2:Number;
var _newX:Number;
var _bttmX:Number;
// Since Flash coutns the top of the stage as y =0
// newDeltY = the y value of our clip
newDeltY = myClip1._y;
// Now use our slope and the prior variable to find
//the x to which we want to draw our line
_newX = myClip1._x + (newDeltY/ _slope);
newDeltY2 = Stage.height- myClip1._y;
_bttmX = myClip1._x - (newDeltY2 / _slope);
// Now move pen of line to _btttmX and Stage.height
//the latter point is the bottom most point of our line
drawLineInThisClip.moveTo( _bttmX , Stage.height);
// Drw line to _newX and the top of the stage ('0')
drawLineInThisClip.lineTo(_newX,0);
}
// the final block is how we will draw the line
// if the absolute value of the slope is LESS than 1
else
{
//deltaX is from point to total right (Stage.width)
newDeltX = (Stage.width - myClip1._x);
// endY is the y value corresponding with
//newDeltX on a line with our _slope

endY = ( myClip1._y - ( newDeltX*_slope ));
staRtY = ( myClip1._y )+ (myClip1._x*_slope );
//_totalLeft is at the very top of the function and we initialized it to 0
//because we want to start at the total left of the Stage or x =0
//_totalRight we initialized to Stage.width which is the total right of the stage
// both variables are at the very top of the funtion

drawLineInThisClip.moveTo(_totalLeft, staRtY);
drawLineInThisClip.lineTo(_totalRight,endY);
}
} }//end of draw line function

The last step:
_root.onEnterFrame = function(){ perfectLine(_root.point1, _root.point2, 33, 'myline'); };

«prev 1 2 3

» Level Intermediate

Added: : 2007-01-21
Rating: 9.67 Votes: 3
Hits: 1269
» Author
Webmaster at www.mathwarehouse.com. Visit site to see this line in various Flash based programs.
» Download
Download the files used in this tutorial.
Download (21 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments