Tuesday, 21 August 2012

How to Create a Grid in as3

step 1 : Draw a rectangle
step 2 : Convert to symbol (press F8) or go to modify -> select convert to symbol
step 3 : Under the ActionScript Linkage and select the "Export for ActionScript"
step 4: Give the class name "mc"  and  press OK.
step 5: Delete the movieClip from the stage.

Action Script : Create a 5X5 grid

1. attach movieClip in stage.
    
    var myMc:mc = new mc();
    myMc.x = 100;
    myMc.y = 100;
    addChild(myMc);


www.actionscriptguru.in



2. Here I am explaining how to attach 5 "columns" in a "ROW"

    for(var i=0;i<5;i++){
    var myMc:mc = new mc();
    addChild(myMc);
    myMc.x = 100+i*myMc.width;
    myMc.y = 100;
    }


www.actionscriptguru.in


3 . Here now i'm attach 5 columns and 5 row's

    for(var i=0;i<5;i++){
for(var j=0;j<5;j++){
var myMc:mc = new mc();
addChild(myMc);
myMc.x = 100+i*myMc.width;
myMc.y = 100+j*myMc.height;
}
   }


www.actionscriptguru.in

No comments:

Post a Comment