02-06-2007, 05:35 PM | #1 (permalink) |
Location: up north
|
flash script question.
I'm making a flash for a website and i have a quick question that i cannot find anywhere. i know it's possible so maybe you can help?
i have 5 dynamic text box. each has a value loaded up in them. They are named UVR_txt1 UVR_txt2 etc... now my problem is that i need my action to tell my main text to = the UVR_txt that i need. how can i write it down so that it accepts the #? example: Code:
variable1 = 2 variable2 = uvr_txt(variable1).text Code:
variable2 = uvr_txt2.text
__________________
Last edited by MexicanOnABike; 02-06-2007 at 05:39 PM.. |
02-07-2007, 06:19 AM | #2 (permalink) |
paranoid
Location: The Netherlands
|
Note: I have zero experience in Flashscript, but...
Not every programming language has (easy) constructs for what you want. Basically you're trying to reference an object by name by joining 2 strings. In other languages I've used one of 2 methods: 1. create an array (or linked list or whatever) with the objects in question. 2. construct the name of the object (string3=string1+string2) then use a GetObjectByName(string3) Whichever method is applicable depends on Flashscript, but as I said, I've never programmed in Flash. At least this post bumps your thread back up. Hope it helps
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
02-07-2007, 11:22 AM | #4 (permalink) |
Lover - Protector - Teacher
Location: Seattle, WA
|
It's very difficult to transform a string into an array indexing command, which is what you're basically trying to do.
If all else fails, couldn't you just hard code it, since you only have 5 boxes? Code:
if (variable1 == 1) variable2 = UVR_txt1.text else if (variable1 == 2) variable2 = UVR_txt2.text else if (variable1 == 3) variable2 = UVR_txt3.text else if (variable1 == 4) variable2 = UVR_txt4.text else if (variable1 == 5) variable2 = UVR_txt5.text
__________________
"I'm typing on a computer of science, which is being sent by science wires to a little science server where you can access it. I'm not typing on a computer of philosophy or religion or whatever other thing you think can be used to understand the universe because they're a poor substitute in the role of understanding the universe which exists independent from ourselves." - Willravel |
02-07-2007, 12:47 PM | #5 (permalink) |
Location: up north
|
hmm. that works for not i guess.
but i'm sure there was a way to do this in the dynamic instance name to somehow say it's uvr_txt#... but isn't there a way to say: uvr_txt(variable).text? i was sure it was doable somehow. maybe it's [ ] or with some sort of other technique? i will use your idea for now Jinn. thanks!
__________________
|
02-08-2007, 02:50 PM | #6 (permalink) |
Lover - Protector - Teacher
Location: Seattle, WA
|
Did a little research, and Flash script actually supports this kinda of dereferencing. Kinda unique, actually.
There's two ways to do what you're talking about. You can either use the array indexing brackets [] or the eval() command. Their documentation gives: eval("piece" + x); If you did Code:
variable2 = eval("UVR_txt" + variable1).text Similarly, you can use the bracket notation to do it: Code:
variable2 = UVR_txt[variable1].text;
__________________
"I'm typing on a computer of science, which is being sent by science wires to a little science server where you can access it. I'm not typing on a computer of philosophy or religion or whatever other thing you think can be used to understand the universe because they're a poor substitute in the role of understanding the universe which exists independent from ourselves." - Willravel |
Tags |
flash, question, script |
|
|