PDA

View Full Version : Library Buttons - multiple instances


mark_anderson_u
10-16-2002, 06:44 PM
Hi All

I'm building a web site for a client and wanted to try and compare the building it in Flash vs. HTML.

Take a look at

http://www.michaela-yakov.com/english/home.html

I have made a menu with a button from the library. I created the bullet, as a lib item, made the color transition as a lib item, and used static text for the labels. This means I have to duplicate the button for every menu item and change the "up" and "over" text manually.

The problem I have with this approach is that if I want to change the button or the text style, I have to make the same changes to all 5 items.

I figure there has to be way to use the same SINGLE library item and somehow set the text with ActionScript in the first frame, but I can't figure out how.

The only way I can assign text to the label is to use '_root.txtMenu = "varText" '

Where var text is the variable used in the library item.

What I don't understand is why I can't assign text using the instance name as part of a path e.g. '_root.btnHome.txtMenu = "Home" ', '_root.btnContact.txtMenu = "Contact" ', etc.

Can someone give me some pointers (if it's possible)

I attached 2 fla files showing the static version that I've done and the dynamic version that I want to do.

Also, can anyone recommend a good book for Flash MX. I've done all the lessons and tutorials, but still feel a bit "lost".

Thanks

Mark

farafiro
10-17-2002, 01:37 PM
Hey, I've seen the files and felt a bit lost too, try this. but first for the buttons: Just u can make a button in the library with out no text, and then make your text box beside it and group them
so u have only one instance of the button in the library but 5 copies of it on the stage.
Also I think a part of your problem that u r giving the button's text boxes and instance name and a variable name
anyway://now we should have anu amout of buttons on the stage
//each one should has an instance name
//now we are going to create the text fields dynamicly
//the button name that I will use is "homeButton"
_root.createTextField("home", 10, homeButton._x+homeButton._width, homeButton._y, 10, 30);
home.text = "Home";
home.autoSize = true
U can do that for all the buttons

red penguin
10-17-2002, 01:51 PM
In the duplication process, just have your 'titles' for the buttons in an array. As it's being duped, use the itinerator to match the title to the button.

If I am wrong in what you are trying to achieve, I blame faffy there. He confuses me every time.

farafiro
10-17-2002, 01:59 PM
Originally posted by red penguin
If I am wrong in what you are trying to achieve, I blame faffy there. He confuses me every time. Why man??

red penguin
10-17-2002, 02:10 PM
That's just the way it is, mayn.

farafiro
10-17-2002, 02:13 PM
Have u seen the file the posted here??

red penguin
10-17-2002, 02:16 PM
Nope. Don't think I need to. From what I read, (s)he wants to have different text for five different buttons. That's how I'd do it.

farafiro
10-17-2002, 02:28 PM
and that's what I told him

mark_anderson_u
10-17-2002, 02:54 PM
Hi Guys

Thanks for the replies. I'm not sure I understand red penguin's answer.

farafiro, I can see that I could get the text into the nexly created fields that way, but I loose the "over" effect for the text. When the mouse goes over the text, I want to change it's color, which I'd normally do in the "over" state for the button.

i guess I could probably script the same thing, but it seems a bit long-winded.

I found another problem with the dynamic text fields: they don't resize horizontally automatically, even though they're set to single line auto expand on the stage. I can't figure out how to get to their properties in the script.

I have button called "btnHome" and it contains a dynamic text field called btnHomeUp. In the movie explorer and the target path selecter, I cannot see the text field. I tried "_root.btnHome.btnHomeUp.autosize=true;" but nothing happens. Any ideas?

Regards

Mark

farafiro
10-17-2002, 03:13 PM
for the autoSize I think it works only for the dynamicly created text fields