mercredi 19 avril 2017

How to create a EASY custom seekbar for music player in actionscript 3.0

Code in the form of connecting a melody and creating instances ..

import flash.events.Event;
var mySound:Sound = new MyFavSong();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0; 
var myTransform = new SoundTransform();
myChannel = mySound.play();
myTransform.volume = 1; 
myChannel.soundTransform = myTransform; 
stop();

And then play buttons, pauses, sound stops + volume Stop

 stop_btn.addEventListener(MouseEvent.CLICK, onClickStop);
    function onClickStop(e:MouseEvent):void{
    myChannel.stop();
    lastPosition = 0;
    stop();
    }

Pause

pause_btn.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void{
lastPosition = myChannel.position;
myChannel.stop();
stop();
}

Play

 play_btn.addEventListener(MouseEvent.CLICK, onClickPlay);
    function onClickPlay(e:MouseEvent):void{
    myChannel = mySound.play(lastPosition);
    myChannel.soundTransform = myTransform;
    play();
    }

Volume

up_btn.addEventListener(MouseEvent.CLICK, onClickUp);
function onClickUp(e:MouseEvent):void{
myChannel.soundTransform = myTransform;
myTransform.volume = myTransform.volume + 1;
}

Please, help me

Aucun commentaire:

Enregistrer un commentaire