A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


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

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


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

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


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: 10.00 Votes: 2
Hits: 1265
» 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
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs