homepage Welcome to WebmasterWorld Guest from 54.167.179.48
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
Text in Buttons
Newbie Question!
Balloon

10+ Year Member



 
Msg#: 438 posted 12:08 am on Mar 7, 2005 (gmt 0)

Hi,

I'm primarliy an ASPX developer, but I'm trying to learn a little flash. I've struck a problem, and was wondering if anyone could help!?

I have created a flash movie, and a button symbol. There is a text area in my button which I want to be able to change to say something different for each instance of the button.

I tried to do this by changing the text field in the button symbol to Dynamic Text and assigning it an instance name.

Then, from the action for a frame in the main timeline, I tried something like this...

this.ButtonInstance1.TextInstance.text = "This is a test";

... but this does nothing.

This seems like a really simple thing to want to do - anyone got any pointers on how to change the text for each instance of my button symbol?

Thanks,
- Chris

 

ambolina

10+ Year Member



 
Msg#: 438 posted 12:20 am on Mar 9, 2005 (gmt 0)

If your text properties of the button (color, weight, etc.) aren't going to change when the button is rolled over or clicked, I would suggest just making the actual button, and NOT the text, the actual button symbol. Then in the movie frames you can just use the text tool to place the different text phrases over the various instances of the symbol.

That's the easiest way I can think to do it, short of having to create a different button symbol for each button.

Balloon

10+ Year Member



 
Msg#: 438 posted 12:45 am on Mar 9, 2005 (gmt 0)

Hi,

Thanks for the suggestion, but I only want the text to appear in the over state of the button.

I can't believe that something as simple as this is so complicated! What's the point in creating a 'button' symbol, if every one has to look identical?

- Chris

Balloon

10+ Year Member



 
Msg#: 438 posted 12:51 am on Mar 9, 2005 (gmt 0)

Actually, I suppose the fact that they look the same is exactly the point!

But you should at least be able to change the text on the buttons?! How far would user interface designers get if every dialog box could have buttons, but they all had to say the same thing!

"Would you like to delete this file? Click YES or YES to continue."

... anyway - this has turned into a rant! Any other ideas?!

- Chris

PizdusInc

10+ Year Member



 
Msg#: 438 posted 4:22 pm on Mar 11, 2005 (gmt 0)

You could try using actionscript to change the text of the button. Add a dynamic text box on the button and then just add a script on each button to display different text...

benihana

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 438 posted 4:27 pm on Mar 11, 2005 (gmt 0)

PizdusInc, read the first post ......

Balloon - your AS looks ok, but as your are putting it on the main timeline it maybe the reference to 'this' that is causing the problem.

Try:

_root.ButtonInstance1.TextInstance.text = "This is a test";

Stratus42

10+ Year Member



 
Msg#: 438 posted 5:54 pm on Mar 18, 2005 (gmt 0)

I do something like this with buttons in a flash animation I have.

I define the text in my button dynamic text and give it the variable lvlmenu0text

I put an action in the frame (still in the button_)that says

lvlmenu0text = lglmenu0text;
stop();

then.. in the instances of the button in my main movie .. I set the variable that's to be displayed.. as an action in the keyframe as:

lilmenu01.lglmenu0text = "some button text here";
lilmenu02.lglmenu0text = "more darn text";
etc...

where lilmenu01, lilmenu02 etc.. is the name of the instance of the button.

there are probably easier ways of doing it - but this seems to work for me.. oh.. and I think my button is actually defined as a movie clip - but I'm not sure if this matters..

hope this has helped

Lana

rhamej

5+ Year Member



 
Msg#: 438 posted 7:49 pm on Mar 18, 2005 (gmt 0)

Stratus hit the nail on the head. You can not place text inside a button symbol and have it display dynamic text.It doesnt work. 99.9% of all flashers I know, including myself, build a movieClip with a button inside that. Inside the movieClip is where you put your dynamic text.
So, the AS would be:

the_mc.the_txt.text="yourtext"

The button AS would be:
the_mc.the_btn.onRelease=function(){
//whatever action you want to happen
}

:-)

Josh

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved