Ver Mensaje Individual
  #5 (permalink)  
Antiguo 18/06/2011, 12:15
stpy
 
Fecha de Ingreso: junio-2011
Mensajes: 23
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: problema boton as3 y reproductor mp3 xml

parte 3 del código


/////////////// Track Scrubber and Ghost Scrub Knob /////////////////////////////////////////////////////////////////////////////////
// ------------------------------------------------------------------ Along with the follower clip inside the trackScrubber
var isDragging:Boolean;
trackScrubber.ghostKnob.visible = false;
// Set Bounds
var scrubberBounds = new Rectangle(0,trackScrubber.ghostKnob.y,trackScrubbe r.scrubberRect.width,0);
trackScrubber.addEventListener(MouseEvent.MOUSE_DO WN, dragScrub);
stage.addEventListener(MouseEvent.MOUSE_UP, dropScrub);

// Drag scrubber
function dragScrub(evt:Event):void {
trackScrubber.ghostKnob.startDrag(true,scrubberBou nds);
trackScrubber.ghostKnob.visible = true;
isDragging = true;
}
// Drop scrubber
function dropScrub(evt:Event):void {

if (isPlaying == true && isDragging == true) {

stopDrag();
// Calculate full time of this track
var fullTime:int = Math.floor(snd.length / 1000);
// Claim a var for the position the song is where we release the scrubber after dragging
var newPos:Number = fullTime / 100 * Math.floor(trackScrubber.ghostKnob.x * 1000);
// Important to set new pause position here
trackToPlay = list.selectedItem.songString; // Define track to resume
pausePosition = newPos / 2;
channel.stop();
gotoAndPlay(2);
//channel = snd.play(newPos);
isPlaying = true;
isDragging = false;

} else { // if not playing
isDragging = false;
trackScrubber.ghostKnob.visible = false;
//pausePosition = fullTime / 100 * Math.floor(trackScrubber.tBarKnob.x * 1000);

}

}
/////////////// End Track Scrubber and Seek Bar //////////////////////////////////////////////////////////////////////////////////////////////


// Set up the onEnterFrame Event for EQ and other various things we may add later on
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void {

// ANIMATED EQ BARS CODE
eqBarLeft1.gotoAndStop (Math.round(channel.leftPeak * 10) ); // 10 is the amount of frames in our EQbar clips
eqBarRight1.gotoAndStop (Math.round(channel.rightPeak * 8) ); // 10 is the amount of frames in our EQbar clips
eqBarLeft2.gotoAndStop (Math.round(channel.leftPeak * 7) ); // 10 is the amount of frames in our EQbar clips
eqBarRight2.gotoAndStop (Math.round(channel.rightPeak * 7) ); // 10 is the amount of frames in our EQbar clips
eqBarLeft3.gotoAndStop (Math.round(channel.leftPeak * 8) ); // 10 is the amount of frames in our EQbar clips
eqBarRight3.gotoAndStop (Math.round(channel.rightPeak * 10) ); // 10 is the amount of frames in our EQbar clips

// Set and change volume if they drag
var volumeLevel = channel.soundTransform;
var newLevel:Number = (volumeSlider.knob.x) / -100;
volumeLevel.volume = newLevel;
channel.soundTransform = volumeLevel;
volumeSlider.volumeLightBar.width = volumeSlider.knob.x;

// Get full time of the song
var tallytime = (snd.length/1000);
var totalmins:Number = Math.floor(tallytime /60);
var totalsecs = Math.floor (tallytime) % 60;
if (totalsecs < 10){
totalsecs = "0" + totalsecs;
}
displayFullTime.text = ( " " + totalmins+ ":" + totalsecs);
// End get Full time
// Get playing time of the song
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;
}
displayTime.text = ( " " + minutes+ ":" + seconds);
// End get playing time

/// progress bar code...
var estimatedLength:int = Math.ceil(snd.length / (snd.bytesLoaded / snd.bytesTotal));
var playbackPercent:uint = 100 * (channel.position / estimatedLength );
// I want my position bar to be 200 pixels wide on completion so I multiply the percentage x 2
trackScrubber.positionBar.width = playbackPercent * 2;
trackScrubber.follower.x = trackScrubber.positionBar.width;
// make the loaded progress bar that lives under the playhead progress bar grow dynamically
var loadedPercent:uint = 100 * (snd.bytesLoaded / snd.bytesTotal);
trackScrubber.loadedProgressBar.width = loadedPercent * 2;
}