0% found this document useful (0 votes)
33 views4 pages

Mmad Lab Weeks

The document provides code samples for creating various shapes and fields dynamically using ActionScript in Flash. This includes scripts to create looping object movement, circles, rectangles, shapes filled with gradients, dynamic text fields, and password fields. The scripts demonstrate using ActionScript's drawing and field creation capabilities to generate graphic elements programmatically without using the Flash authoring interface.

Uploaded by

dasariorama
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views4 pages

Mmad Lab Weeks

The document provides code samples for creating various shapes and fields dynamically using ActionScript in Flash. This includes scripts to create looping object movement, circles, rectangles, shapes filled with gradients, dynamic text fields, and password fields. The scripts demonstrate using ActionScript's drawing and field creation capabilities to generate graphic elements programmatically without using the Flash authoring interface.

Uploaded by

dasariorama
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

12)Objective: Write a Script that creates looping effect for an object (ex:

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.

14)Objective: create a movie that draws a Rectangle dynamically (using Action


Script) Procedure: 1) Open A New Flash Document 2) Write the below ActionScript code at Frame 1 of Layer 1
// Create rectangle_mc with a depth of 1 on the main timeline. _root.createEmptyMovieClip("rectangle_mc", 1);
rectangle_mc.lineStyle(1, 0x000000, 100);

// 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

17)Objective: Create a password Field dynamically(using ActionScript)


Procedure: 1) Open a new flash document 2) Create one input textfield using tool box and give instance name as pwd . 3) Click on the stage ,open the action panel and write the below code Pwd. displayAsPassword =true; 4) Test the movie(ctrl+ENTER) Conclusion: A dynamic password field is obtained

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy