0

私は Actionscript 3 を使用して Flash MP3 プレーヤーに取り組んでいます。再生、一時停止などのボタンの横にあるステージに、「timerText」というインスタンス名の動的テキストボックスがあります。

timerText フィールドを現在の分と秒で更新するためのコードは、EnterFrame イベント リスナーに関連付けられている onEnterFrame という関数から呼び出されます。

ダイナミック テキスト ボックスにフォントを埋め込んでいます。トレース関数を呼び出してダイナミック テキスト ボックスから現在のテキストを出力すると、必要な時刻が出力されます。ただし、テキスト ボックス自体はまったく変更されません。

私のタイムラインには 1 つのフレームがあり、次のアクションが添付されています。

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundLoaderContext;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.events.Event;

// Stop the Player
stop();

/**
* Declare some Variables
*/

// Get the MP3 File
var req:URLRequest = new URLRequest('audio/alice-track-1.mp3');

// Create a Sound Object
var snd:Sound = new Sound();

// Create a Sound Channel
var channel:SoundChannel;

// Initialise the Pause Position
var pausePosition:int = 0;

// Boolean for Is Playing(?)
var isPlaying:Boolean = false;

// Set the Play Buffer to 5 Seconds
var context:SoundLoaderContext = new SoundLoaderContext(5000, true);

// Load the Requested URL into the Snd Var, along with the Context
snd.load(req, context);

// Create the Play Channel
channel = snd.play();

// Set IsPlaying to TRUE initially
isPlaying = true;

/**
* Play Music Function
*/
function playSound(event:MouseEvent):void {
    if (isPlaying == false) {
        channel = snd.play(pausePosition);
        isPlaying = true;
    }
}

/**
* Stop Music Function
*/
function stopSound(event:MouseEvent):void {
    channel.stop();
    pausePosition = 0;
    isPlaying = false;
}

/**
* Pause Music Function
*/
function pauseSound(event:MouseEvent):void {
    pausePosition = channel.position;
    channel.stop();
    isPlaying = false;
}

// Add the Button Event Listeners
playBtn.addEventListener(MouseEvent.CLICK, playSound);
stopBtn.addEventListener(MouseEvent.CLICK, stopSound);
pauseBtn.addEventListener(MouseEvent.CLICK, pauseSound);

// Add the OnEnterFrame Event Listener
addEventListener(Event.ENTER_FRAME, onEnterFrame);

/**
* Initialisation / OnEnterFrame Function
*/
function onEnterFrame(event:Event):void {
    var totalSeconds:Number = channel.position / 1000;
    var minutes:Number = Math.floor(totalSeconds / 60);
    var seconds = Math.floor(totalSeconds) % 60;

    if (seconds < 10) {
        seconds = '0' + seconds;
    }

    timerText.text = (minutes + ':' + seconds);
trace(timerText.text);
}
4

2 に答える 2

0

フォントの埋め込みの問題である可能性があります。

フォント埋め込みオプションですべてのボタンが有効になっていることを確認してください。この画像を見てください - http://i.imgur.com/F5ufM.png

また、フォントの色が背景色と同じでないことを確認してください。

于 2013-02-07T21:10:38.953 に答える