Actionscript是什么时间格式?

时间:2012-08-01 22:08:59

标签: flash actionscript actionscript-2

我有从XML文档动态加载的提示点。

    <cuepoints>
        <one name="bullet1" time="4.000" type="actionscript" said="Konnektivität"></one>
        <two name="bullet2" time="6.500" type="actionscript" said="Internet"></two>
        <three name="bullet3" time="7.500" type="actionscript" said="Bilder und Video"></three>
        <four name="bullet4" time="9.000" type="actionscript" said="Gaming"></four>
        <five name="bullet5" time="10.000" type="actionscript" said="Akkulaufzeit"></five>
    </cuepoints>

这是我的AS2代码:

import mx.transitions.Tween;
import mx.transitions.easing.*;

//var playback1:mx.video.FLVPlayback;

/*////////////////////////////////////////////////////////////////
Load the video content paths
/////////////////////////////////////////////////////////////////*/
playback1.contentPath = getNodeValue(findNode(videos, "one"));

//turn off the visibilit of the bullet mc
bullet_bg._alpha = 0;
bullet_one._alpha = 0;
bullet_two._alpha = 0;
bullet_three._alpha = 0;
bullet_four._alpha = 0;
bullet_five._alpha = 0;

// Assign the mySeekBar instance to the flvPlayback instance
playback1.playPauseButton = playpause;
playback1.backButton = myrewind;
playback1.seekBar = seekbar_container.myseek;
playback1.bufferingBar = mybuffer; 

/*////////////////////////////////////////////////////////////
Create the Cuepoints for the video
///////////////////////////////////////////////////////////*/
var bullet1:Object = new Object();
bullet1.time = findNode(cuepoints, "one").attributes.time;
bullet1.name = findNode(cuepoints, "one").attributes.name; 
bullet1.type = "actionscript";

var bullet2:Object = new Object();
bullet2.time = findNode(cuepoints, "two").attributes.time;
bullet2.name = findNode(cuepoints, "two").attributes.name; 
bullet2.type = "actionscript";

var bullet3:Object = new Object();
bullet3.time = findNode(cuepoints, "three").attributes.time;
bullet3.name = findNode(cuepoints, "three").attributes.name; 
bullet3.type = "actionscript";

var bullet4:Object = new Object();
bullet4.time = findNode(cuepoints, "four").attributes.time;
bullet4.name = findNode(cuepoints, "four").attributes.name; 
bullet4.type = "actionscript";

var bullet5:Object = new Object();
bullet5.time = findNode(cuepoints, "five").attributes.time;
bullet5.name = findNode(cuepoints, "five").attributes.name; 
bullet5.type = "actionscript";


playback1.addASCuePoint(bullet1);
playback1.addASCuePoint(bullet2);
playback1.addASCuePoint(bullet3);
playback1.addASCuePoint(bullet4);
playback1.addASCuePoint(bullet5);


/*///////////////////////////////////////////////////////////
 CUE POINT LISTENER
///////////////////////////////////////////////////////////*/
var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object) {
    var cuePtName = eventObject.info.name;
    if (cuePtName == "bullet1") {
        var b1:Tween = new Tween(bullet_one, "_alpha", Strong.easeInOut, 0, 100, 1, true);
        var b1x:Tween = new Tween(bullet_one, "_x", Strong.easeInOut, 100, 115, 1, true);
        trace(bullet1.time);
    }
    if (cuePtName == "bullet2") {
        var b2:Tween = new Tween(bullet_two, "_alpha", Strong.easeInOut, 0, 100, 1, true);
        var b2x:Tween = new Tween(bullet_two, "_x", Strong.easeInOut, 100, 115, 1, true);
        trace(bullet2.time);
    }
    if (cuePtName == "bullet3") {
        var b3:Tween = new Tween(bullet_three, "_alpha", Strong.easeInOut, 0, 100, 1, true);
        var b3x:Tween = new Tween(bullet_three, "_x", Strong.easeInOut, 100, 115, 1, true);
        trace(bullet3.time);
    }
    if (cuePtName == "bullet4") {
        var b4:Tween = new Tween(bullet_four, "_alpha", Strong.easeInOut, 0, 100, 1, true);
        var b4x:Tween = new Tween(bullet_four, "_x", Strong.easeInOut, 100, 115, 1, true);
        trace(bullet4.time);
    }
    if (cuePtName == "bullet5") {
        var b5:Tween = new Tween(bullet_five, "_alpha", Strong.easeInOut, 0, 100, 1, true);
        var b5x:Tween = new Tween(bullet_five, "_x", Strong.easeInOut, 100, 115, 1, true);
        trace(bullet5.time);
    }
}

/*/////////////////////////////////////////////
//// LISTENERS for FLVPlayback component
////////////////////////////////////////////*/ 
var alreadyShown:Boolean;

var startObject:Object = new Object();
startObject.playing = function(eventObject:Object): Void {   
    trace("FLV is playing");
    if(alreadyShown != true) {
        var laserFadeIn:Tween = new Tween(bullet_bg, "_alpha", Strong.easeInOut, 0, 100, 3.4, true);
        alreadyShown = true;
    } 
}

playback1.addEventListener("cuePoint", listenerObject);
playback1.addEventListener("playing", startObject);

问题在于,由于某些原因,当我的时间为“10.000”秒时,提示点顺序就会失败,并且它们都会同时出现。时间格式有问题吗?

更新:当我硬编码10.000秒后,一切正常。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我认为您遇到的问题是因为您将提示点的time属性设置为strings而不是numbers。尝试将您从XML获得的值转换为int,然后将其分配给您的提示点,如下所示:

var bullet1:Object = new Object();
bullet1.time = parseInt(findNode(cuepoints, "one").attributes.time);
bullet1.name = findNode(cuepoints, "one").attributes.name; 
bullet1.type = "actionscript";