2014-09-21 1 views
-1

임과 지금까지 필자는 그래서 당신은 'btngo'버튼을 클릭 그것을 가지고와 타이머가 볼 오브젝트 동안 시작 난 타이머를AS3 액션 스크립트 3의 새로운 동적 텍스트

를 시작할 때 고갈 번호를 얻기 위해 노력하고 있어요 움직입니다. 감사합니다,

는 또한이 버튼을 클릭하면 100에서 시작하는 동적 텍스트는 0 ~ 10 초까지 고갈 싶어하지만 불행하게도 내가 어떤 도움이 크게 감사합니다

그것을 수행하는 방법에 단서가 없다 당신 :

import flash.utils.Timer; 
import flash.events.TimerEvent; 

stop(); 


var timer1:Timer = new Timer (10,10000); 
var timer2:Timer = new Timer (10,10000); 
timer1.addEventListener(TimerEvent.TIMER, forward); 
timer2.addEventListener(TimerEvent.TIMER, back); 
btngo.addEventListener(MouseEvent.CLICK, green); 
btnstop.addEventListener(MouseEvent.CLICK, red); 

function green(e:MouseEvent):void { 
    timer2.stop(); 
    timer1.start(); 
    trace("timer started"); 
} 

function red(e:MouseEvent):void { 
    timer1.stop(); 
    timer2.start(); 
    trace("timer started"); 
} 

function forward(e:TimerEvent):void { 
    ball.x += 2; 
} 

function back(e:TimerEvent):void { 
    ball.x -= 2; 
} 

답변

0

글쎄, 여기 당신이 찾고있는 것을 얻을 수있는 두 가지 기능이 있습니다.

import flash.text.TextField; 
import flash.text.TextFieldType; 

var dynamic_text:TextField; 
function CreateText() 
{ 
    // You can also replace this part with code that creates a textfield that you have in your library, 
    // in that case just make sure the textfield is set to dynamic in the textfield properties 

    // Create a new textfield. 
    dynamic_text = new TextField(); 

    // Make sure its type is set to Dynamic. 
    dynamic_text.type = TextFieldType.DYNAMIC; 

    // Position it somewhere on the screen. 
    dynamic_text.x = 10; 
    dynamic_text.y = 10; 

    // Set a default text for now. 
    dynamic_text.text = "Time: " + time_left; 

    // Make sure the players cannot select the text. 
    dynamic_text.selectable = false; 

    // Add it to your stage (or other parent, take your pick) 
    stage.addChild(dynamic_text); 
} 

이 두 번째마다 TimerEvent를 호출됩니다 :

function OnTimerChange() 
{ 
    // Update the text based on the new time. 
    dynamic_text.text = "Time: " + time_left; 
} 

당신은 "앞으로"와 "뒤로"자신의 내부에이 OnTimerChange 함수를 호출해야합니다 이것은 첫 번째는 텍스트의 창조 함수를 호출하고이 두 함수에서 경과 한 시간을 계산해야합니다. 이 도움이 actionscript 3 how to keep track of time elapsed?

희망 : 당신이 버튼을 누른 이후 경과 한 시간을 추적하는 방법을 예를 들어

.

관련 문제