Skip to main content
Participant
November 10, 2008
Question

Button text to change colour while sound streams

  • November 10, 2008
  • 4 replies
  • 356 views
Hi guys/gals, I am an extreme newbie to ActionScript, and was hoping I could catch some help. I am streaming sound files for a customer with a simple button I created using text, using this stock behaviour code below. I would like the text in the button to change colour while the audio streams and return to its previous state when the audio is finished streaming. Is this possible? And if so, is there anyone who could offer up some sample code to to get me started?

Thanks very much for anyone's time who reads this or responds.

Cheers

on (release) {

//Load Streaming mp3 behavior
if(_global.Behaviors == null)_global.Behaviors = {};
if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
if(typeof this.createEmptyMovieClip == 'undefined'){
this._parent.createEmptyMovieClip('BS_waltz',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.waltz = new Sound(this._parent.BS_waltz);
} else {
this.createEmptyMovieClip('_waltz_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.waltz = new Sound(this.BS_waltz);
}
_global.Behaviors.Sound.waltz.loadSound(" http://www.langleyukes.com/LUE/MP3/Recordings/Classical_Ukuleles/sound_files/Danube_Waltz_clip.mp3",true);

}
This topic has been closed for replies.

4 replies

kglad
Community Expert
Community Expert
November 11, 2008
you're welcome.

no, i haven't seriously considered teaching actionscript. i already have 1 full-time job and 2 part-time jobs. i don't think i could manage another part-time job.
ebodabaAuthor
Participant
November 11, 2008
Hi again kglad, thank you very much for your time and consideration in helping me with this task. I will be working on a solution this weekend when I have more time, and if successful I will post the solution to the proper forum along with comments explaining the functionality.

Thanks again.

PS. Cool site at www.kglad.com. Have you ever considered teaching ActionScript?

Cheers.
kglad
Community Expert
Community Expert
November 10, 2008
you must create a color instance for each object whose color you want to control. you can then manipulate the color instance and effect color changes on the corresponding object:

var c:Color = new Color(yourObject);
c.setRGB(0xaa0000); // change yourObject to color 0xaa0000
kglad
Community Expert
Community Expert
November 10, 2008
that should be posted in the as1/as2 forum. it's also terrible coding that you lifted.

but you can use the onSoundComplete() method of your sound instance (_global.Behaviors.Sound.waltz) to detect when your sound stops. you can use the onLoad() method of your sound instance to detect when your sound starts to load.
ebodabaAuthor
Participant
November 10, 2008
Hi kglad, thank you for the quick and informative response. Sorry if I posted to the wrong forum, but as I mentioned I am brand new to AS and this was also my first post. I apologize for my ignorance regarding classification and protocol. Perhaps the mods could move it to the proper forum.

That cleared up the methods used to detect when the MP3 begins to stream and ends, do you have any hints on how to access the colour property of the button text? If I can figure this out, I will post the entire code for others to use to try to help the community and save you from responding to similar questions.

As an aside, I didn't lift the code I posted. The code was generated automatically by Flash 8 Professional. I used Behaviours >>Add Behaviours >> Sound >> Load Streaming MP3 file and just added the url for the MP3 to the proper text box that asks for the that parameter.

I find that code generated automatically by most apps is usually bloated and generally inelegant. I have chalked it up to an acceptable trade-off for convenience, but understand your frustration. Perhaps you could pass your critique and suggestions onto the Flash Development Team and they will modify it.

Thanks again.

Cheers.