In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

MoveTo Test

Studying from http://www.flashandmath.com/
Get Adobe Flash player
by vliff 26 Jan 2014
    Embed
/**
 * Copyright vliff ( http://wonderfl.net/user/vliff )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/iEuM
 */

package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            
               
import flash.display.Sprite;

//We will draw line segments in a Sprite 'sp'.
var sp:Sprite = new Sprite();
sp.x = 50;
sp.y = 50;
this.addChild(sp);

/*
graphics.drawPath method takes two parameters: a Vector of coordinates of consecutive points on the path and a Vector of commands. (The last optional parameter 'winding' is not relevant to our experiment.) We create the Vector variables. 
*/

var drawCoords:Vector.<Number> = new Vector.<Number>();
var drawCommands:Vector.<int> = new Vector.<int>();

//We will draw black lines of thickness 12 and alpha 0.2.
sp.graphics.lineStyle(12,0x000000,0.2);

//Drawing the upper left cross. Instersection appears with correct alpha.
sp.graphics.moveTo(0,10);
sp.graphics.lineTo(100,110);
sp.graphics.moveTo(100,10);
sp.graphics.lineTo(0,110);

/*
We populate Vectors to be used with the drawPath method. In the Vector of commands, 1 correponds to moveTo, 2 corresponds to lineTo. Thus, the Vector of commands is: moveTo, lineTo, moveTo, and lineTo. Then, we call the drawPath method. The upper right cross is drawn. The intersection is not correct and it does not correspond to an overlap of two transparent objects. 
*/

drawCoords.push(200,10);
drawCommands.push(1);
drawCoords.push(300,110);
drawCommands.push(2);
drawCoords.push(300,10);
drawCommands.push(1);
drawCoords.push(200,110);
drawCommands.push(2);
sp.graphics.drawPath(drawCommands,drawCoords);

/*
Below we draw the lower figures. In the first figure we use moveTo once and then call lineTo three times. The intersections do not show correctly. For the last figure, we separate lineTo commands by moveTo (even though the pen is not really moving). The intersections show with proper transparency. 
*/

sp.graphics.moveTo(0,310);
sp.graphics.lineTo(100,410);
sp.graphics.lineTo(100,310);
sp.graphics.lineTo(0,410);


sp.graphics.moveTo(200,310);
sp.graphics.lineTo(300,410);
sp.graphics.moveTo(300,410);
sp.graphics.lineTo(300,310);
sp.graphics.moveTo(300,310);
sp.graphics.lineTo(200,410);
        }
    }
}