Skip to content

Instantly share code, notes, and snippets.

@Gi133
Created February 15, 2012 16:43
Show Gist options
  • Save Gi133/1837191 to your computer and use it in GitHub Desktop.
Save Gi133/1837191 to your computer and use it in GitHub Desktop.
Lab2
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.geom.ColorTransform;
import flash.geom.Transform;
import flash.display.Shape;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
public class Main extends Sprite
{
private var square:Shape = new Shape;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
square.graphics.beginFill(0x0000ff);
square.graphics.drawRect(-32, -32, 64, 64);
square.graphics.endFill();
this.addChild(square);
stage.addEventListener(MouseEvent.CLICK, ColorChange);
}
public function ColorChange (e:MouseEvent):void
{
var myColour:ColorTransform = new ColorTransform;
myColour.color = 0xff0000;
square.transform.colorTransform = myColour;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment