SHOW:
|
|
- or go back to the newest paste.
| 1 | - | import flash.geom.*; |
| 1 | + | import flash.geom.*; |
| 2 | ||
| 3 | - | var carregarImg01:Loader = new Loader(); |
| 3 | + | |
| 4 | - | var enderecoImg01:URLRequest = new URLRequest("relogio.png");
|
| 4 | + | /* var carregarImg01:Loader = new Loader(); |
| 5 | - | carregarImg01.load(enderecoImg01); |
| 5 | + | var enderecoImg01:URLRequest = new URLRequest("relogio.png");
|
| 6 | - | addChild(carregarImg01); |
| 6 | + | carregarImg01.load(enderecoImg01); |
| 7 | addChild(carregarImg01);*/ | |
| 8 | - | var ponteiro_segundos:Sprite = new Sprite(); |
| 8 | + | |
| 9 | - | ponteiro_segundos.graphics.lineStyle(2, 0x000000, 0.75); |
| 9 | + | |
| 10 | - | ponteiro_segundos.graphics.beginFill(0x000000); |
| 10 | + | //Variavel X e Y para posicionar os objetos no palco |
| 11 | - | ponteiro_segundos.graphics.moveTo(200, 20); |
| 11 | + | var xpos = 320; |
| 12 | - | ponteiro_segundos.graphics.lineTo(200, 200); |
| 12 | + | var ypos = 240; |
| 13 | - | ponteiro_segundos.graphics.endFill(); |
| 13 | + | |
| 14 | var relogio:Sprite = new Sprite(); | |
| 15 | - | this.addChild(ponteiro_segundos); |
| 15 | + | relogio.graphics.lineStyle(0,0xFF0000); |
| 16 | relogio.graphics.beginFill(0xBBDEE6); | |
| 17 | - | var ponteiro_minutos:Sprite = new Sprite(); |
| 17 | + | relogio.graphics.drawCircle(0,0,200); |
| 18 | - | ponteiro_minutos.graphics.lineStyle(7, 0x00FF00, 0.75); |
| 18 | + | relogio.graphics.endFill(); |
| 19 | - | ponteiro_minutos.graphics.beginFill(0x00FF00); |
| 19 | + | relogio.x = xpos; |
| 20 | - | ponteiro_minutos.graphics.moveTo(200, 50); |
| 20 | + | relogio.y = ypos; |
| 21 | - | ponteiro_minutos.graphics.lineTo(200, 200); |
| 21 | + | addChild(relogio); |
| 22 | - | ponteiro_minutos.graphics.endFill(); |
| 22 | + | |
| 23 | var ponteiro_segundos:Sprite = new Sprite(); | |
| 24 | - | this.addChild(ponteiro_minutos); |
| 24 | + | ponteiro_segundos.graphics.lineStyle(2, 0x000000, 0.75); |
| 25 | ponteiro_segundos.graphics.beginFill(0x000000); | |
| 26 | - | var ponteiro_horas:Sprite = new Sprite(); |
| 26 | + | //ponteiro_segundos.graphics.moveTo(200, 200); |
| 27 | - | ponteiro_horas.graphics.lineStyle(7, 0xFF0000, 0.75); |
| 27 | + | ponteiro_segundos.graphics.lineTo(150, 150); |
| 28 | - | ponteiro_horas.graphics.beginFill(0xFF0000); |
| 28 | + | ponteiro_segundos.graphics.endFill(); |
| 29 | - | ponteiro_horas.graphics.moveTo(200, 100); |
| 29 | + | ponteiro_segundos.x = xpos; |
| 30 | - | ponteiro_horas.graphics.lineTo(200, 200); |
| 30 | + | ponteiro_segundos.y = ypos; |
| 31 | - | ponteiro_horas.graphics.endFill(); |
| 31 | + | this.addChild(ponteiro_segundos); |
| 32 | ||
| 33 | - | this.addChild(ponteiro_horas); |
| 33 | + | var ponteiro_minutos:Sprite = new Sprite(); |
| 34 | ponteiro_minutos.graphics.lineStyle(7, 0x00FF00, 0.75); | |
| 35 | - | var centro:Sprite = new Sprite(); |
| 35 | + | ponteiro_minutos.graphics.beginFill(0x00FF00); |
| 36 | - | centro.graphics.lineStyle(0,0xFF0000); |
| 36 | + | //ponteiro_minutos.graphics.moveTo(200, 200); |
| 37 | - | centro.graphics.beginFill(0xFF0000); |
| 37 | + | ponteiro_minutos.graphics.lineTo(120, 120); |
| 38 | - | centro.graphics.drawCircle(0,0,7); |
| 38 | + | ponteiro_minutos.graphics.endFill(); |
| 39 | - | centro.graphics.endFill(); |
| 39 | + | ponteiro_minutos.x = xpos; |
| 40 | - | centro.x = 200; |
| 40 | + | ponteiro_minutos.y = ypos; |
| 41 | - | centro.y = 200; |
| 41 | + | this.addChild(ponteiro_minutos); |
| 42 | ||
| 43 | - | addChild(centro); |
| 43 | + | var ponteiro_horas:Sprite = new Sprite(); |
| 44 | ponteiro_horas.graphics.lineStyle(7, 0xFF0000, 0.75); | |
| 45 | - | this.addEventListener(Event.ENTER_FRAME, dispara_relogio); |
| 45 | + | ponteiro_horas.graphics.beginFill(0xFF0000); |
| 46 | //ponteiro_horas.graphics.moveTo(200, 200); | |
| 47 | - | function dispara_relogio(e:Event):void {
|
| 47 | + | ponteiro_horas.graphics.lineTo(100, 100); |
| 48 | - | // armazena data/hora atuais |
| 48 | + | ponteiro_horas.graphics.endFill(); |
| 49 | - | var agora = new Date(); |
| 49 | + | ponteiro_horas.x = xpos; |
| 50 | - | var horas = agora.getHours(); |
| 50 | + | ponteiro_horas.y = ypos; |
| 51 | - | var minutos = agora.getMinutes(); |
| 51 | + | this.addChild(ponteiro_horas); |
| 52 | - | var segundos = agora.getSeconds(); |
| 52 | + | |
| 53 | var centro:Sprite = new Sprite(); | |
| 54 | - | // converte a hora de 24h para 12h |
| 54 | + | centro.graphics.lineStyle(0,0xFF0000); |
| 55 | - | if (horas > 12){
|
| 55 | + | centro.graphics.beginFill(0xFF0000); |
| 56 | - | horas -= 12; |
| 56 | + | centro.graphics.drawCircle(0,0,7); |
| 57 | - | } |
| 57 | + | centro.graphics.endFill(); |
| 58 | centro.x = xpos; | |
| 59 | - | // determina o ângulo dos ponteiros |
| 59 | + | centro.y = ypos; |
| 60 | - | var anguloHoras = 360*horas/12; |
| 60 | + | addChild(centro); |
| 61 | - | var anguloMinutos = 360*minutos/60; |
| 61 | + | |
| 62 | - | var anguloSegundos = 360*segundos/60; |
| 62 | + | this.addEventListener(Event.ENTER_FRAME, dispara_relogio); |
| 63 | ||
| 64 | - | // configura o ângulo dos ponteiros |
| 64 | + | function dispara_relogio(e:Event):void {
|
| 65 | - | ponteiro_horas.rotation = anguloHoras; |
| 65 | + | // armazena data/hora atuais |
| 66 | - | ponteiro_minutos.rotation = anguloMinutos; |
| 66 | + | var agora = new Date(); |
| 67 | - | ponteiro_segundos.rotation = anguloSegundos; |
| 67 | + | var horas = agora.getHours(); |
| 68 | - | } |
| 68 | + | var minutos = agora.getMinutes(); |
| 69 | var segundos = agora.getSeconds(); | |
| 70 | trace(horas,minutos,segundos); | |
| 71 | // converte a hora de 24h para 12h | |
| 72 | if (horas > 12){
| |
| 73 | horas -= 12; | |
| 74 | } | |
| 75 | ||
| 76 | // determina o ângulo dos ponteiros | |
| 77 | var anguloHoras = 360*horas/12; | |
| 78 | var anguloMinutos = 360*minutos/60; | |
| 79 | var anguloSegundos = 360*segundos/60; | |
| 80 | ||
| 81 | // configura o ângulo dos ponteiros | |
| 82 | ponteiro_horas.rotation = anguloHoras; | |
| 83 | ponteiro_minutos.rotation = anguloMinutos; | |
| 84 | ponteiro_segundos.rotation = anguloSegundos; | |
| 85 | } |