Mmad Lab Weeks

Embed Size (px)

Citation preview

  • 8/3/2019 Mmad Lab Weeks

    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 cir3) 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

  • 8/3/2019 Mmad Lab Weeks

    2/4

    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.

  • 8/3/2019 Mmad Lab Weeks

    3/4

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

    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 ActionScript

    Procedure

    1) Open A New Flash Document2) 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

  • 8/3/2019 Mmad Lab Weeks

    4/4

    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 document2) 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