Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-10-2007, 10:08 PM   #1
soggybag
Snarfarious
 
Join Date: Jan 2002
Posts: 203
Default Buttons with Dynamic Text in AS3?

I have been in the habit of making buttons with a dynamic text field. This way assigning a value to the var property of the text field would allow me to reuse the button symbol and assign different text to each.

In AS3 it looks like the text field Var property does not exist any longer.

Does anyone have a suggestion for a work around? I would like to avoid having to make a new symbol for each button.

The var property worked well because it allowed you to change the text field on different frames of a movie clip button. If each text field had the same Var name it would display the same text label.
soggybag is offline   Reply With Quote
Old 07-11-2007, 12:02 AM   #2
johnnyWeiss
Registered User
 
Join Date: Jul 2007
Posts: 7
Default

take a look at my posting earlier today. you may have a suggestion on how to solve my problem while you get what you need.
johnnyWeiss is offline   Reply With Quote
Old 07-11-2007, 12:05 AM   #3
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

give the text field an instance name You shouldn't have been using the var property since flash 5!
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 07-11-2007, 02:58 AM   #4
soggybag
Snarfarious
 
Join Date: Jan 2002
Posts: 203
Default

Thanks for the reply. This is not a good solution. Using the TextField.text property doesn't allow you to create a label at frame the button may display.

For example, let's say you have a movie clip button with a text field inside. the text field is on a layer with two key frames. One key frame at the _up frame and another at the _over frame. This allows you to adjust the color and other properties of the text field for the rollover effect. The text field is dynamic and has myLabel set as the var.

Setting the myLabel property of the container movie clip allows the text field to display the value at all of it's key frames.

Using the text property, the text field loses it's assigned text when go to the next key frame.

Another thing I noticed is that a button with a text field inside doesn't show the finger or the rollover when you are over the text field.
soggybag is offline   Reply With Quote
Old 07-11-2007, 03:47 AM   #5
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

maybe not a good solution, but it is your only one
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 07-11-2007, 04:29 AM   #6
soggybag
Snarfarious
 
Join Date: Jan 2002
Posts: 203
Default

What do you mean? Which solution is not good and what do think is a better solution?
soggybag is offline   Reply With Quote
Old 07-11-2007, 05:13 AM   #7
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 2,060
Send a message via AIM to Mazoonist
Default

soggybag,

Here's a solution for you (attached). Hope it helps.

Inside the button, the lines:
ActionScript Code:
this.buttonMode = true; this.mouseChildren = false;
(on frame 1)
...will allow the movie clip to behave as a button, and the second line will cause the hand cursor to still show over the top of the dynamic text box.

There's always a way to accomplish what you want, and the var box is gone from the properties inspector, anyway. It wasn't a really great idea to begin with. Why not? Because it allowed you to set a variable, but do it in a kind of hidden way, so someone else viewing your file (or you two months or so down the road) might have difficulty finding the darned thing. That makes it hard to figure out how something works.
Attached Files
File Type: zip as3_custom_button_dynamic_text.zip (5.3 KB, 1072 views)
Mazoonist is offline   Reply With Quote
Old 07-11-2007, 05:30 AM   #8
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 2,060
Send a message via AIM to Mazoonist
Default

I was wondering what you meant by the text field not retaining the text on it's different keyframes. If you want it to always retain the text you assign it, don't give it different keyframes, just one. Then fill the rest of the space with frames (F5).
Mazoonist is offline   Reply With Quote
Old 07-11-2007, 06:06 AM   #9
soggybag
Snarfarious
 
Join Date: Jan 2002
Posts: 203
Default

Thanks for the reply.

I have already used the buttonMode property.

The mouseChildren property I had seen. This fixes the problem with the text field taking focus.

The problem with only adding frames is that the text can not change. If you've designed a button where the style of the text changes you'd need a key frame.

Imagine you have a movie clip that you've set up as a button using the _up and _over frames. At the _up frame your text field shows the button label in black. At the _over frame you'd like the color to be red.

Using the text property you'd need to add some cumbersome actionscript to set the text property when ever your button changed frames.

Using Actionscript to dynamically generate or modify the text field is in-flexible. You'd have to rewrite the code if the design changed. You also have to write extra code.

Using the var property of the text field allows you to make a button that can display any text in any style at any key frame within the button movie clip. Modifying the look of the button is as easy as editing the text field.

Making a button like this allows you to make a button that can be used anywhere in your movie with any label you might need. This way you make a single clip to cover all of your button needs.

There must be a solution in AS 3.
soggybag is offline   Reply With Quote
Old 07-11-2007, 06:36 AM   #10
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 2,060
Send a message via AIM to Mazoonist
Default

Ok, I see more clearly now what you mean. Interesting. I'll be working on it.
Mazoonist is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML.txt ----> dynamic text box jerryCLEMENT ActionScript 2.0 3 09-23-2009 06:56 PM
Loading in external text vars from dynamic buttons designues ActionScript 2.0 4 11-29-2006 11:21 PM
sending multiple 'loadvariables' to 'dynamic text' Yorgo12345 ActionScript 1.0 (and below) 6 03-22-2005 12:26 PM
If anyone's bored, a custom class . . . retrotron ActionScript 1.0 (and below) 22 05-24-2003 11:01 PM
dynamic text, anchors, and images spoonyg ActionScript 1.0 (and below) 7 11-26-2002 10:08 PM


All times are GMT. The time now is 08:28 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.