Flash Question

  • Started
  • Last post
  • 1 Response
  • nearestexit

    Hey, here's a snippet of code i have that will draw rectangles on stage. Right now, the rectangles are solid in color but I'd like them to fade in and fade out. Anyone have any simple suggestions on how t do this?

    function DrawRect() {
    var x:Number, y:Number;
    var cx:Number, cy:Number;
    var myW:Number, myH:Number;

    this.clear();
    myW = System.capabilities.screenResolu...
    myH = System.capabilities.screenResolu...

    trace( "WIDTH: " + myW + " HEIGHT: " + myH );
    cx = (myW / this.m_gridX);
    cy = (myH / this.m_gridY);
    x = Math.floor(( Math.random() * this.m_gridX ));
    y = Math.floor(( Math.random() * this.m_gridY ));
    trace( "GRID: " + x + "," + y );
    x *= cx;
    y *= cy;
    trace( "REALGRID: " + x + "," + y );

    // Now, adjust the x,y position to take into account the difference between the screen and the stage.
    x -= (( myW - Stage.width ) / 2 );
    y -= (( myH - Stage.height ) / 2 );

    cx += x;
    cy += y;

    // Now I have a rectangle to draw, x,y-cx,cy
    trace( "DRAW: " + x + "," + y + " - " + cx + "," + cy );
    var colorIndex:Number = Math.floor(Math.random() * this.m_aColors.length );
    this.beginFill( this.m_aColors[colorIndex] );
    this.moveTo( x, y );
    this.lineTo( cx, y );
    this.lineTo( cx, cy );
    this.lineTo( x, cy );
    this.endFill();

    this.pm_curRect ++; // increment rect ctr.
    if( this.pm_curRect > this.m_drawRects ) { // Are we done drawing rects?
    clearInterval( this.pm_intervalID );
    this.clear();
    this.m_fCallback();
    }
    }

  • st33d0