Ultrashock Forums > Flash > ActionScript
prob with text filed and var
Member Blogs
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
FIX prob with lunching Function with a var in it
Old 2008-04-04 Last edited by Lppgfx : 2008-04-11 at 12:04.

Hi guys , i got an other question that look similar ,

luching a function with a var in it ,

example:
Code:
//i need to lunch 
this.Fquestion_single_up();

but need to replace the "up" by the corect state

i got a var that know what state it is "_root.button_states"
but i cant make it work

im trying
Code:
_root.whatFunction = this.Fquestion
_root.whatFunction['_single_' + _root.button_states +'()']
i have thry passing all to "_root.whatFunction "
but dosent seem to work more
Code:
_root.whatFunction = "this.Fquestion_single_" + _root.button_states +"()"
so looks like i need help again ,

thanks in advance guys
plz and tnx





//this prob is fix
Hi , heres my code

Code:
_root.question_sigle_list = ["question_sigle0" , "question_sigle1" , "question_sigle2" , "question_sigle3" , "question_sigle4" , "question_sigle5"]
	
function Fquestion_question_TXT() { 
	var what_text = "_root.Survey_mc.survey_question.survey_question_notebook.survey_question_singlebutton_0"
	var what_button = ".question_singlebutton_ttlabel"
	for (i=00; i<6; i++) {
        var t = what_text + i + what_button 


       trace(t)
       eval("t").TextField = _root.question_sigle_list[i]
}
the prob now , lol,

"t" refere to the text field "_root.Survey_mc.survey_question.survey_question_notebook.survey_question_singlebutton_0*.question_singlebutton_ttlabel"

but when i try to put element from the array "question_sigle_list" the var t change , not the text
ex
Code:
trace(t)
/*
output "_root.Survey_mc.survey_question.survey_question_notebook.survey_question_singlebutton_0*.question_singlebutton_ttlabel"
*/
but after
Code:
eval("t").TextField = _root.question_sigle_list[i]
t output the aray

hope its clear , i know my english is not perfect ,

thanks alot in advance
Lpp
postbit arrow 7 comments | 240 views postbit arrow Reply: with Quote   
Lppgfx
Registered User
Lppgfx is offline
seperator
Posts: 59
2002-02-10
seperator

Ultrashock Member Comments:
Holaso's Avatar Holaso Holaso is offline Moderator Holaso lives in United States 3 Blog Entries 2008-04-04 #2 Old  
I believe you want to do this
Code:
eval("t").text = _root.question_sigle_list[i]
Reply With Quote  
Lppgfx Lppgfx is offline 2008-04-04 #3 Old  
Tnx Holaso,

but ist not working ,
but when im pointing directly to it , its working , so the root is good,
Code:
_root.Survey_mc.survey_question.survey_question_notebook.survey_question_singlebutton_05.question_singlebutton_ttlabel = "yewqubhjczxmnjjjjjust a test"

/*output 
yewqubhjczxmnjjjjjust a test

*/
Reply With Quote  
tiran tiran is offline tiran lives in United States 2008-04-04 #4 Old  
Last edited by tiran : 2008-04-04 at 12:12.
Code:
var what_text =_root.Survey_mc.survey_question.survey_question_notebook; //no quotes
for (i=00; i<6; i++) {
       what_text['survey_question_singlebutton_' + i].question_singlebutton_ttlabel = _root.question_sigle_list[i];
}
Forget that eval junk.

EDIT - Just realized exactly how you were trying to piece together the path...updated the code.
Reply With Quote  
tiran tiran is offline tiran lives in United States 2008-04-04 #5 Old  
Last edited by tiran : 2008-04-04 at 12:13.
PS. It appears you have given your textfield a "Var" name rather than an instance name. When you give it a Var name you do not use textfieldinstance.text = "" ... you just use textfieldvarname = "" like you were. If I am wrong and you have given it an instance name, then you need to use .text="".

Reply With Quote  
Lppgfx Lppgfx is offline 2008-04-04 #6 Old  
wow , tnx alot ,

and i was thinking it was not working too ,

you forgot a zero, lol
what_text['survey_question_singlebutton_0' + i].question_singlebutton_ttlabel = _root.question_sigle_list[i];
yes i have use a a "Var" name
(old fashion , lol)

again , tnx alot
Reply With Quote  
Lppgfx Lppgfx is offline 2008-04-11 #7 Old  
Hi guys , i got an other question that look similar ,

luching a function with a var in it ,

example:
Code:
//i need to lunch 
this.Fquestion_single_up();

but need to replace the "up" by the corect state

i got a var that know what state it is "_root.button_states"
but i cant make it work

im trying
Code:
_root.whatFunction = this.Fquestion
_root.whatFunction['_single_' + _root.button_states +'()']
i have thry passing all to "_root.whatFunction "
but dosent seem to work more
Code:
_root.whatFunction = "this.Fquestion_single_" + _root.button_states +"()"
so looks like i need help again ,

thanks in advance guys
plz and tnx
Reply With Quote  
Lppgfx Lppgfx is offline 2008-04-11 #8 Old  
FIX
thanks anyway
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: