Creating a Drag and Drop Game In AS3

Take a New File In Flash. Change Stage color to Black in Property pallete

 Create a Star shape using polystar tool.
Select the polystar tool> properties >Inside option select Star
Convert the star shape to Movie Clip
Inside movie Clip advance option> Export for action script
Change the name of class to "star"

Write the given script
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

var A:Array = new Array();
for (var i:uint = 0; i < 5 ; i++) {
        A[i] = new star();
        A[i].x = 540*Math.random();
A[i].y = 400*Math.random();
var s=100*Math.random();
A[i].width=s;
A[i].height=s;
A[i].alpha=Math.random();
var starColor:ColorTransform = new ColorTransform();
            starColor.color = (Math.random() * 0xFFFFFF);
          A[i].transform.colorTransform=starColor;
        addChild(A[i]);
A[i].doubleClickEnabled=true; 
A[i].buttonMode=true;
A[i].addEventListener(MouseEvent.CLICK,fundrag);
A[i].addEventListener(MouseEvent.DOUBLE_CLICK,fundrop);
 }
 function fundrag(e:Event){
 e.currentTarget.startDrag();
}

function fundrop(e:Event){
e.currentTarget.stopDrag();
}


No comments:

Post a Comment

Things Web Developers Must Include in Their Portfolio

1. Need to have Link and Screen shot of their past projects 2. If they are applying for a specific skill like PHP or ASP.Net. Need to...