A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11261 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: DamIRFiVE100
» Title: Circular Menu
» Description: Another idea for cool menu.
» More by
DamIRFiVE100


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

Featured Site

» Posted in the Flash Kit Links section
» Title: Passinglane
» Comments: Since 1996 Passinglane has been providing compelling communication products for business, enterainment and education.


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

» How to Make 3D Wall Flash Photo Gallery
» How to Make Personalized Multimedia Flash eCard in PowerPoint
» How to Create Grown up Christmas List Photo Story
» How to convert Youtube video(online SWF file) to video for portable devices?
» How to Make Flash Christmas Quizzes with Sounds & Videos
» FLV to PSP - How to convert YouTube video to PSP for mac
» Creating widgets fast and easily with SPAS 3.0
» How to Let PowerPoint Memorize like Man
» How to insert YouTube video (Flash video) into PowerPoint
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Product Designer
Aquent
US-WA-Redmond

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 1
1 2 3 next»

This tutorial assumes you are comfortable creating movie clip symbols and giving them instance names as well as writing basic functions in ActionScript.
  • Step 1: Create a new Flash document and add two movie clips. In the property inspector, name them 'point1' and 'point2' (any names will suffice but my example will use these particular names)
  • Step 2: Let's start writing a function that draws a line from 1 side of the screen through these two points (wherever it is that they may be) and to the other end of the stage.
  • Step 3: Lets right the beginning of our function:

  • function perfectLine(myClip1, myClip2 ,suppliedDepth ){
    //_slope: First let's find the slope of a line between the two clips
    _slope:Number,
    _slope = -(myClip1._y - myClip2._y)/(myClip1._x - myClip2._x);

    //These variables represent the total left, right, top and bottom
    //of the screen to which we will draw a line. We will use the slope that
    //we just found to calculate these variables later on

    var _totalLeft:Number;
    var _totalRight:Number;
    var endY:Number;
    var staRtY:Number,
    var newDeltX:Number;
    // Next is where the movieClip in wich we will house our line.
    //Remember that we need a MovieClip to draw a line
    // (though in Flash 9 it will no longer be necessary to draw in a mc)

    var drawLineInThisClip:MovieClip;

    //The _stringCount is a just a variable that we will append to each line's movieclip
    // Each line needs to be associated with a movieclip. Each clip, of course,
    // requires its own, distinct depth-- we might after all want multiple lines.
    // on the Stage and we can now assign them different depths

    var _stringCount = suppliedDepth;

    //The next 3 variables let you customize the following properties of our
    //humbly named 'perfect lines'
    //They're pretty self-explanatory

    var lineThickNess = 3; // How thick the line is
    var lineRGB = 0x000033; //the color of the line
    var lineAlpa = 90; //The Alpha of the line



    //_totalRight, not surprisingly, represents how far on the right we want to be able to draw
    // Since we want to be able to draw ALL the way to the right we use 'Stage.width'
    //_totalLeft is the x position on the left which is zero. Remember in Flash's
    //coordinate system x values start at zero on the absolute left.

    _totalRight = Stage.width;
    _totalLeft = 0;


    //Here is where we create the movieClip that will house our line.
    drawLineInThisClip =_root.createEmptyMovieClip(('line'+_stringCount), suppliedDepth)


    1 2 3 next»

    » 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.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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