PDA

View Full Version : dynamic text variables


temptation
06-26-2002, 01:47 PM
Hi all,

I have a scene into which I have dropped some instances of checkboxes.

Within each instance of checkbox (button1,2 etc) I assign the values "I am on" or "I am off" to the variable 'boxstatus' to reflect its condition.

On the main timeline I have a dynamic textbox with the variable _root.button1.boxstatus and this works fine.

What I want is another textbox on the same timeline to which I can put some text and add _root.button1.boxstatus.

I have tried to script as follows on a new layer in th emain timeline:-

Newtext = _root.button1.boxstatus + "extra text" It only shows "extra text" in the box.

Where am I going wrong?

CyanBlue
06-26-2002, 02:49 PM
Hi...

Newtext being the name of your new text field, right??? I just tried that and worked just fine...
Where is your script 'Newtext = _root.button1.boxstatus + "extra text"' located and is that a frame script??? Try moving it to some other layer and add trace command to see if that one is working or not...

temptation
06-26-2002, 03:36 PM
Thanks for the reply Jason,

I have tried on different layers and using the trace command just gave me an empty box.

As a newbie, I'm still getting used to how the timeline works. It looks to me like thistext is not updating itself becuase I have the script in the wrong place like you say but I can't see anywhere else to put it.

I have attached the file (3k only) if you wouldn't mind having a look.

I have spent hours trying to sort this out!

Patrick

pinkaboo
06-26-2002, 03:56 PM
hmm, at the moment you set your textbox on the main timeline with no loop, which means that it the code is activated before boxstatus is set and then isn't returned to again.
If you want that textbox to be updated every time the button is pressed you could stick your code within the button, at the same time you set box status. ie:



//frame 1
boxstatus = "I am off"
_root.thistext = boxstatus+ " extra text" ;
stop ();

//frame 2
boxstatus = "I am on"
_root.thistext = boxstatus+ " extra text" ;
stop ();


pinK

temptation
06-26-2002, 04:17 PM
Thanks Pinkaboo,

What I am trying to do is make sure that I can use and manipulate the state of the checkboxes to perform a different task. If I can't get this right what chance have I got when it gets more complicated!

What I will be trying to do is create a set of 12 checkboxes within a clip, of which only 3 can be checked at any one time (if the user tries to check a fourth they will be asked to deselect one of the others first). I then need to identify the three that are finally decided upon.

I guessed if I could get the 'thistext' bit to work I could then get the other stuff to work - it was just a double check.

You mention a loop - I tried that as I see that somehow I need to keep refreshing 'thistext' but kept getting endless loops. Any suggestions?

BTW I hve seen how much of a contribution you make to this board - you ROCK!

pinkaboo
06-26-2002, 04:25 PM
hmm, am having a think about what you are trying to do, however with regards the loop you could use an onClipEvent (enterFrame) I guess. Basically stick an empty mc on the stage then just slap this onto it:


onClipEvent (enterFrame) {
_root.thistext = _root.button1.boxstatus + "extra text";
}


pinK

BTW I hve seen how much of a contribution you make to this board - you ROCK!

*blush*

ps I don't know if it's relevant or if you are aware of it but there is a handy action called _name that returns the name of an instance, for example try replacing


boxstatus = "I am on"
//with
boxstatus = this._name + "I am on"


and then you'll get button1 returned too

temptation
06-26-2002, 05:10 PM
Hee Hee,

Top solution

onClipEvent worked better than a thing that works better than a thing that works really well.

Looks like it will handle most of what I want to do now

Thanks Pinkaboo.

Shedding a bit more light on why I am doing this (maybe there is a really easy way to do it): -

I am putting together a personal development movie so the checkboxes will be part of this question: -

Ask someone you trust to choose three words from those below to describe you : 1)friendly, 2)reserved, 3)quiet, 4)talkative...etc.

I have to make sure that only three boxes get checked (and chopped and changed if the user wants to) and then use the selections to create the text - "Other peole often describe me as 'var1','var2' and 'var3'. This will then be added to other text that has been created using simple radio button questions to produce a personality/preferences analysis report.





:)

thomasreimer
06-26-2002, 11:15 PM
I have read this discussion with great interest, since i´ve been strggling to make the form elements pass their value to the "load variables" command, that sends off the data to Matt FormMail.pl script.

It works fine with the ordinary text variables, but it seems I`m missing out on something completely elemetary here.

So in plain english: what do I have to do, to make the userchoice get passed on like the text variables, when using the form elements like radiobuttons, drop down menus, and checkboxes.( in fla5.)

Is it that I, somewhere have to trace the state of that instance of the checkbox, since there is nowhere in the clipparameters, that i can "set variable to the state of the checkbox"

the help text in the clipparametbox is as follows, and i cant figure out if the last part has to do with some actions that i can use somewhere else to pull the value and pass it on as i wish to.:

Parameter info:
_name - make sure is set to unique instance name
checked - set to true to start out checked
label - the wording that the end user sees


API Method Summary (ex: _name.setLabel("This is cool");)
Name Description
================================================== ====
getLabel() Gets the label of this check box.
getState() Determines whether this check box is in the "on" or "off" state.
setLabel(String) Sets this check box's label to be the string argument.
setState(boolean) Sets the state of this check box to the specified state.


I sure hope someone can help, since i´m going nuts over this aparrantly simple thing that is so easy to do in plain html.

Thomas

temptation
06-27-2002, 04:40 PM
Finally Cracked it.

Pinkaboo's tip on this._name helped a lot and I used _parent. with the variables in the button movies so that everything on the main stage updated automatically.

Thomas, I've attached the file and hope it is of some help to you.

For my purposes an error box comes up if you try to check more than 3 boxes.

Happy Flashing.

Patrick.

Abelius
06-27-2002, 04:44 PM
Extra points for Pinkaboo...! LOL :) (I was following this thread to see who would make it, LOL)