Mmad Lab Weeks
Mmad Lab Weeks
object-----circle) Procedure: 1) open flash document 2) create one object using tool box and assign instance name as cir 3) write the below actions in action panel (press F0 to open action panel) cir.onEnterFrame=function() { xdist=_xmouse-290; ydist=_ynmouse-190; j=0; while(j<0) { j++; _root[circle+j+_mc]._x=290+(xdist+j/10); _ root[circle+j+_mc]._x=290+(ydist+j/10); } } var i:NUMBER=0; var j:NUMBER=0; var xdist:NUMBER=0; var ydist:NUMBER=0; while(i<0) { i++; duplicateMovieclip(circle,circle+i+_mc,i); } Conclusion: Looping effect for an object is obtained 13)Objective: create a movie that draws a circle dynamically(using ActionScript) Procedure: 1) Open a New Flash Documemt 2) Write the below ActionScript at Frame 1 of Layer 1
// r = radius of circle // x, y = center of circle MovieClip.prototype.drawCircle = function (r, x, y) { var TO_RADIANS:Number = Math.PI/180; // begin circle at 0, 0 (its registration point) -- move it when done this.moveTo(0, 0); this.lineTo(r, 0); // draw 12 30-degree segments // (could do more efficiently with 8 45-degree segments) var a:Number = 0.268; // tan(15) for (var i=0; i < 12; i++) { var endx = r*Math.cos((i+1)*30*TO_RADIANS); var endy = r*Math.sin((i+1)*30*TO_RADIANS); var ax = endx+r*a*Math.cos(((i+1)*30-90)*TO_RADIANS);
var ay = endy+r*a*Math.sin(((i+1)*30-90)*TO_RADIANS); this.curveTo(ax, ay, endx, endy); } this._x = x; this._y = y; } // use the method to draw a circle in movieclip c // at x=100, y=100 with a 70-pixel radius createEmptyMovieClip("c", 1); c.beginFill(0x000055, 60); c.drawCircle(70, 100, 100); c.endFill();
(OR) // r1 = radius of outer circle // r2 = radius of inner circle (cutout) // x, y = center of donut // This creates a donut shape that can be used as a mask MovieClip.prototype.drawDonut2 = function (r1, r2, x, y) { var TO_RADIANS:Number = Math.PI/180; this.moveTo(0, 0); this.lineTo(r1, 0); // draw the 30-degree segments var a:Number = 0.268; // tan(15) for (var i=0; i < 12; i++) { var endx = r1*Math.cos((i+1)*30*TO_RADIANS); var endy = r1*Math.sin((i+1)*30*TO_RADIANS); var ax = endx+r1*a*Math.cos(((i+1)*30-90)*TO_RADIANS); var ay = endy+r1*a*Math.sin(((i+1)*30-90)*TO_RADIANS); this.curveTo(ax, ay, endx, endy); } // cut out middle (go in reverse) this.moveTo(0, 0); this.lineTo(r2, 0); for (var i=12; i > 0; i--) { var endx = r2*Math.cos((i-1)*30*TO_RADIANS); var endy = r2*Math.sin((i-1)*30*TO_RADIANS); var ax = endx+r2*(0-a)*Math.cos(((i-1)*30-90)*TO_RADIANS); var ay = endy+r2*(0-a)*Math.sin(((i-1)*30-90)*TO_RADIANS); this.curveTo(ax, ay, endx, endy); } 3) test the movie. Conclusion: A Movie that creates a Circle (dynamically) is obtained.
// Draw four lines to form the perimeter of the rectangle. rectangle_mc.lineTo(100, 0); rectangle_mc.lineTo(100, 50); rectangle_mc.lineTo( 0, 50); rectangle_mc.lineTo( 0, 0); 3) test the movie.
Conclusion: A Movie that creates a Rectangle (dynamically) is obtained 15) Objective: create a movie that fills a Shape with Gradient Effect (using Action Script Procedure 1) Open A New Flash Document 2) Click on the first key frame then open the actions panel" and write the below code fillType = "linear"; colors = [0xF83680, 0x5844EA]; alphas = [100, 100]; ratios = [0, 255]; matrix = {matrixType:"box", x:50, y:50, w:150, h:100, r:0/180*Math.PI}; _root.lineStyle(2, 0x666666, 100); _root.beginGradientFill(fillType, colors, alphas, ratios, matrix); _root.moveTo(50, 50); _root.lineTo(200, 50); _root.lineTo(200, 150); _root.lineTo(50, 150); _root.lineTo(50, 50); _root.endFill(); 3) Save it and Test the move(Ctrl+ENTER). Conclusion: A Movie that creates a shape with Gradient Effect is obtained
16) Objective: Create a Text Field dynamically (using ActionScript) Procedure: 1) Open a new flash document 2) Create one input texfield using tool box and give instance name as input . 3) Click on the stage and open action panel(press F9) and the below code: _root.createTextField(loading_txt, 10); loading_txt. autoSize= true; loading_txt.text=haiii.; loading_txt.text=input.text; 4) test the movie(ctrl+ENTER) Conclusion: A dynamic textfiled is obtained