本文介绍了如何播放一首歌曲从库时的preloader是英寸×"%共装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前从事的基础上脱机组合的presentation期末考试,我需要做一个preloader,就是当加载的过程字节总数的25%,发挥的声音,导入到库中。我尝试了几种方法,并不能做到这一点。

我将离开你的$ C $下我的preloader。

  //(也是这个code是鼠标装载机以文本形式)

this.loaderInfo.addEventListener(使用ProgressEvent.PROGRESS,checkingProgress);

功能checkingProgress(事件:ProgressEvent):无效{
    VAR procentLoaded:数= event.bytesLoaded / event.bytesTotal * 100;

    ptxt.text = INT(procentLoaded)+%;
    如果(procentLoaded == 100){
        this.gotoAndPlay(1,视频 - 诠释);
    }
}

stage.addChild(ptxt);
ptxt.mouseEnabled = FALSE;
ptxt.addEventListener(Event.ENTER_FRAME,fl_CustomMouseCursor);

功能fl_CustomMouseCursor(事件:事件){
    ptxt.x = stage.mouseX;
    ptxt.y = stage.mouseY;
}
Mouse.hide();

this.addEventListener(Event.ENTER_FRAME,装载);

功能加载(五:事件):无效{
    VAR总:数= this.stage.loaderInfo.bytesTotal;
    VAR装:数= this.stage.loaderInfo.bytesLoaded;

    prel.scaleX =加载/总;
    如果(总装==){
        玩();
        this.removeEventListener(Event.ENTER_FRAME,装载);
    }
}
 

解决方案

您需要在您的库中的声音文件可以动作。
给它一个类名前。为mySound

  ...
VAR为mySound:为mySound =新为mySound();
VAR soundPLaying:布尔= FALSE;

功能checkingProgress(事件:ProgressEvent):无效{
VAR procentLoaded:数= event.bytesLoaded / event.bytesTotal * 100;

ptxt.text = procentLoaded +%;
如果(procentLoaded> 25安培;&安培;!soundPlaying){//检查是否加载铁道部则25%和声音是不是在玩
    mysound.play();
    soundPlaying = TRUE;
}
如果(procentLoaded == 100){
    this.gotoAndPlay(1,视频 - 诠释);
   }
}
...
 

如果你需要做一些额外的东西一样暂停,换卷等,您将需要一个 SoundChannel对象

I am currently undertaking a final exam based on the presentation of an offline portfolio and I need to make a preloader, where when the process of loading is 25% of total bytes, to play a sound that is imported into the library. I've tried several ways and can’t do it.

I'll leave you the code for my preloader.

//(also this code is a mouse loader in text form)

this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,checkingProgress);

function checkingProgress(event:ProgressEvent):void{
    var procentLoaded:Number = event.bytesLoaded/event.bytesTotal*100;

    ptxt.text=int(procentLoaded)+"%";
    if(procentLoaded == 100){
        this.gotoAndPlay(1,"Video-Int");
    }
}

stage.addChild(ptxt);
ptxt.mouseEnabled = false;
ptxt.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);

function fl_CustomMouseCursor(event:Event) {
    ptxt.x = stage.mouseX;
    ptxt.y = stage.mouseY;
}
Mouse.hide();

this.addEventListener(Event.ENTER_FRAME, loading);

function loading(e:Event):void {
    var total:Number = this.stage.loaderInfo.bytesTotal;
    var loaded:Number = this.stage.loaderInfo.bytesLoaded;

    prel.scaleX = loaded/total;
    if (total == loaded){
        play();
        this.removeEventListener(Event.ENTER_FRAME, loading);
    }
}
解决方案

You need to make the sound file in your library available for actionscript.
Give it a Class name ex. MySound

...
var mysound:MySound = new MySound();
var soundPLaying:Boolean = false;

function checkingProgress(event:ProgressEvent):void{
var procentLoaded:Number = event.bytesLoaded/event.bytesTotal*100;

ptxt.text= procentLoaded +"%";
if(procentLoaded > 25 && !soundPlaying){ //check if loaded mor then 25% and sound isn't playing
    mysound.play();
    soundPlaying = true;
}
if(procentLoaded == 100){
    this.gotoAndPlay(1,"Video-Int");
   }
}
...

if you need to do some extra stuff like pause, change volume etc you will need a SoundChannel Object

这篇关于如何播放一首歌曲从库时的preloader是英寸×"%共装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-08 19:27