all groups > flash (macromedia) > september 2006 >
You're in the

flash (macromedia)

group:

Somewhat Newbie: creating instances of button


Somewhat Newbie: creating instances of button spherop
9/4/2006 7:17:48 PM
flash (macromedia):
I am new to Flash but not to programming.

I want to use a button symbol for many buttons I will create that will have
different visible text, and also different behaviors. However, the visual style
of the buttons will be the same (ie., the font, highlighting etc).

I have on button working fine - and have it as a symbol in my library.

I would assume that I can drag different instances onto my stage and then
apply different actioscripts? or is that not how it works? I was hoping to
change the text of each instance at runtime. And basiaclly each button would
play a different streaming mp3 file.
---
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_Rahu',new
Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.Rahu = new Sound(this._parent.BS_Rahu);
} else {
this.createEmptyMovieClip('_Rahu_',new Date().getTime()-(Math.floor((new
Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.Rahu = new Sound(this.BS_Rahu);
}
_global.Behaviors.Sound.Rahu.loadSound("http://....some.mp3",true);

}

Any tips, questions, or links to good tutorials for this kind of thing much
appreciated. Just getting my feet wet :)
Re: Somewhat Newbie: creating instances of button 2m
9/4/2006 8:58:41 PM
boy (or is it girl?) you've got a strnge way of asigning depths to a clip what
about _parent.getNextHighestDepth()? well it's up to you.
Just make a dynamic textfield with an instance name of say label_txt in your
button symbol, and the apply your label text via

my_buttonNO_n.label_txt.text = "hello world";

That shoud do.
Re: Somewhat Newbie: creating instances of button 2m
9/5/2006 12:00:00 AM
If it's code/behavior of Flash 8, that explains a lot ;-) brrrrr!

Concerning your question about the individual sound: You could for example
dynamically attache a sound object to each button while instanciating it, and
just make the button play its own sound.
Re: Somewhat Newbie: creating instances of button spherop
9/5/2006 12:40:08 AM
thanks.

btw-the strange code you're reading is code/behavior of flash 8. I simply
selected it from inside the behavior menu... ;)

so that helps as far as the label - how about getting each button to load a
different sound?
Re: Somewhat Newbie: creating instances of button spherop
9/5/2006 1:51:39 PM
AddThis Social Bookmark Button