Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package {
  2.     import flash.display.*;
  3.     import flash.events.*;
  4.     import flash.text.*;
  5.    
  6.     public class Lesson2 extends MovieClip {
  7.         public function Lesson2(){
  8.            
  9.            
  10.             //Variables
  11.             var cloneText:TextField = new TextField()
  12.             var andro:android = new android()
  13.             var textBox:TextField = new TextField()
  14.             var bLeft:buttonLeft = new buttonLeft()
  15.             var bRight:buttonRight = new buttonRight()
  16.             var numInput:TextField = new TextField()
  17.            
  18.             //Android
  19.             andro.scaleX = 5
  20.             andro.scaleY = 5
  21.             andro.x += (andro.width) / 2 + 100
  22.             andro.y += (andro.height) / 2 + 100
  23.             addChild(andro)
  24.             andro.addEventListener(KeyboardEvent.KEY_UP, checkForLeft)
  25.             function checkForLeft(event:KeyboardEvent) {
  26.                 if (event.charCode == 37) {
  27.                     andro.x += -50
  28.                 }
  29.             }
  30.             andro.addEventListener(KeyboardEvent.KEY_UP, checkForRight)
  31.             function checkForRight(event:KeyboardEvent) {
  32.                 if (event.charCode == 39) {
  33.                     andro.x += 50
  34.                 }
  35.             }
  36.             andro.addEventListener(KeyboardEvent.KEY_UP, checkForUp)
  37.             function checkForUp(event:KeyboardEvent) {
  38.                 if (event.charCode == 38) {
  39.                     andro.y += 50
  40.                 }
  41.             }
  42.             andro.addEventListener(KeyboardEvent.KEY_UP, checkForDown)
  43.             function checkForDown(event:KeyboardEvent) {
  44.                 if (event.charCode == 40) {
  45.                     andro.y += -50
  46.                 }
  47.             }
  48.  
  49.             //Instructions
  50.             textBox.text = "         Rotate the android left or right"
  51.             textBox.width = 201
  52.             textBox.height = 65
  53.             textBox.border = true
  54.             textBox.selectable = false
  55.             textBox.x = 274
  56.             textBox.y = 285
  57.             cloneText.text = "How many Clones to you want?"
  58.             cloneText.x = 300
  59.             cloneText.y = 225
  60.             cloneText.width = 200
  61.             addChild(cloneText)
  62.             addChild(textBox)
  63.            
  64.             //LeftButton
  65.             bLeft.addEventListener(MouseEvent.CLICK, clickLibraryButtonLeft)
  66.             function clickLibraryButtonLeft(event:MouseEvent) {
  67.                 andro.rotation -= 15
  68.             }
  69.             bLeft.x = 275
  70.             bLeft.y = 300
  71.             addChild(bLeft)
  72.            
  73.             //RightButton
  74.             bRight.addEventListener(MouseEvent.CLICK, clickLibraryButtonRight)
  75.             function clickLibraryButtonRight(event:MouseEvent) {
  76.                 andro.rotation += 15
  77.             }
  78.             bRight.x = 375
  79.             bRight.y = 300
  80.             addChild(bRight)
  81.            
  82.             //Accept Text Input
  83.             numInput.type = TextFieldType.INPUT
  84.             numInput.border = true
  85.             numInput.height = 20
  86.             numInput.x = 325
  87.             numInput.y = 250
  88.             addChild(numInput)
  89.             numInput.addEventListener(KeyboardEvent.KEY_UP, checkForReturn)
  90.             function checkForReturn(event:KeyboardEvent) {
  91.                 if (event.charCode == 13) {
  92.                     acceptInput()
  93.                 }
  94.             }
  95.             function acceptInput() {
  96.                 var inputText:String = numInput.text
  97.                 removeChild(numInput)
  98.                 removeChild(cloneText)
  99.                
  100.                 //Make Android Clones
  101.                
  102.                 for(var i=0;i<inputText;i++) {
  103.                     var androC:android = new android()
  104.                     androC.x = 32*i+32
  105.                     androC.y = 16
  106.                     androC.scaleZ = .3
  107.                     addChild(androC)
  108.                 }
  109.             }
  110.         }
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement