Play Button Problems!

  • Jeremy Neumann
  • Born
  • Born
  • Jeremy Neumann
  • Posts: 3
  • Loc: USA, MO

Post 3+ Months Ago

Hello, I have a flash file were that when you click on the play button, it will play a sound from the library. But if you press it more then once it starts the song again. Which causes the song to play against it self.

How do I fix this?

Here is were you can view the flash problem, and the .fla file.

http://www.handsomerob.com/test/index.html

Jeremy Neumann
  • fotbon
  • Novice
  • Novice
  • fotbon
  • Posts: 20

Post 3+ Months Ago

put an if qualifier at the beginning of the button and have a variable switch on after you click it and switch off once the song is done playing.

eg
Code: [ Select ]
on( release ){
if( playing != true ){
  //play song
  playing = true;
}
}
  1. on( release ){
  2. if( playing != true ){
  3.   //play song
  4.   playing = true;
  5. }
  6. }

code for the last frame:
Code: [ Select ]
playing = false;
  • Jeremy Neumann
  • Born
  • Born
  • Jeremy Neumann
  • Posts: 3
  • Loc: USA, MO

Post 3+ Months Ago

Little confused here. Were exactly do I put the code?

I added a behavior to the button to play a song from the library, this is the code it gave me...


Code: [ Select ]
on (release) {
    //Play Internal Sound Behavior
    if(_global.Behaviors == null)_global.Behaviors = {};
    if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
    if(typeof this.createEmptyMovieClip == 'undefined'){
        this._parent.createEmptyMovieClip('BS_testraindownsong',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
        _global.Behaviors.Sound.testraindownsong = new Sound(this._parent.BS_testraindownsong);
    } else {
        this.createEmptyMovieClip('_testraindownsong_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
        _global.Behaviors.Sound.testraindownsong = new Sound(this.BS_testraindownsong);
    }
    _global.Behaviors.Sound.testraindownsong.attachSound("raindown");
    if (true) {
        _global.Behaviors.Sound.testraindownsong.start(0,1);
    }
    //End Behavior

}
  1. on (release) {
  2.     //Play Internal Sound Behavior
  3.     if(_global.Behaviors == null)_global.Behaviors = {};
  4.     if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
  5.     if(typeof this.createEmptyMovieClip == 'undefined'){
  6.         this._parent.createEmptyMovieClip('BS_testraindownsong',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
  7.         _global.Behaviors.Sound.testraindownsong = new Sound(this._parent.BS_testraindownsong);
  8.     } else {
  9.         this.createEmptyMovieClip('_testraindownsong_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
  10.         _global.Behaviors.Sound.testraindownsong = new Sound(this.BS_testraindownsong);
  11.     }
  12.     _global.Behaviors.Sound.testraindownsong.attachSound("raindown");
  13.     if (true) {
  14.         _global.Behaviors.Sound.testraindownsong.start(0,1);
  15.     }
  16.     //End Behavior
  17. }
  • Jeremy Neumann
  • Born
  • Born
  • Jeremy Neumann
  • Posts: 3
  • Loc: USA, MO

Post 3+ Months Ago

Ahh nevermind, I figured it out.

Thanks!

Jeremy

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 2 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.