Created
February 15, 2012 16:43
-
-
Save Gi133/1837191 to your computer and use it in GitHub Desktop.
Lab2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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