Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.display.*;
- import flash.events.*;
- import flash.text.*;
- public class Lesson2 extends MovieClip {
- public function Lesson2(){
- //Variables
- var cloneText:TextField = new TextField()
- var andro:android = new android()
- var textBox:TextField = new TextField()
- var bLeft:buttonLeft = new buttonLeft()
- var bRight:buttonRight = new buttonRight()
- var numInput:TextField = new TextField()
- //Android
- andro.scaleX = 5
- andro.scaleY = 5
- andro.x += (andro.width) / 2 + 100
- andro.y += (andro.height) / 2 + 100
- addChild(andro)
- andro.addEventListener(KeyboardEvent.KEY_UP, checkForLeft)
- function checkForLeft(event:KeyboardEvent) {
- if (event.charCode == 37) {
- andro.x += -50
- }
- }
- andro.addEventListener(KeyboardEvent.KEY_UP, checkForRight)
- function checkForRight(event:KeyboardEvent) {
- if (event.charCode == 39) {
- andro.x += 50
- }
- }
- andro.addEventListener(KeyboardEvent.KEY_UP, checkForUp)
- function checkForUp(event:KeyboardEvent) {
- if (event.charCode == 38) {
- andro.y += 50
- }
- }
- andro.addEventListener(KeyboardEvent.KEY_UP, checkForDown)
- function checkForDown(event:KeyboardEvent) {
- if (event.charCode == 40) {
- andro.y += -50
- }
- }
- //Instructions
- textBox.text = " Rotate the android left or right"
- textBox.width = 201
- textBox.height = 65
- textBox.border = true
- textBox.selectable = false
- textBox.x = 274
- textBox.y = 285
- cloneText.text = "How many Clones to you want?"
- cloneText.x = 300
- cloneText.y = 225
- cloneText.width = 200
- addChild(cloneText)
- addChild(textBox)
- //LeftButton
- bLeft.addEventListener(MouseEvent.CLICK, clickLibraryButtonLeft)
- function clickLibraryButtonLeft(event:MouseEvent) {
- andro.rotation -= 15
- }
- bLeft.x = 275
- bLeft.y = 300
- addChild(bLeft)
- //RightButton
- bRight.addEventListener(MouseEvent.CLICK, clickLibraryButtonRight)
- function clickLibraryButtonRight(event:MouseEvent) {
- andro.rotation += 15
- }
- bRight.x = 375
- bRight.y = 300
- addChild(bRight)
- //Accept Text Input
- numInput.type = TextFieldType.INPUT
- numInput.border = true
- numInput.height = 20
- numInput.x = 325
- numInput.y = 250
- addChild(numInput)
- numInput.addEventListener(KeyboardEvent.KEY_UP, checkForReturn)
- function checkForReturn(event:KeyboardEvent) {
- if (event.charCode == 13) {
- acceptInput()
- }
- }
- function acceptInput() {
- var inputText:String = numInput.text
- removeChild(numInput)
- removeChild(cloneText)
- //Make Android Clones
- for(var i=0;i<inputText;i++) {
- var androC:android = new android()
- androC.x = 32*i+32
- androC.y = 16
- androC.scaleZ = .3
- addChild(androC)
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement