john_yourspace
asked on
AS 3 Eval
Hi guys,
I am trying to populate some text fields using this
So i am looping the VO and getting the values fine however I need to dynamically get access to the text field , txtName1 -> txtName10.
John
I am trying to populate some text fields using this
public var txtName:String ="MovieClip(leaderboard).txtName";
public var pic:String ="MovieClip(leaderboard).pic";
public var txtTime:String ="MovieClip(leaderboard).txtTime";
public function popLeaderBoard() : void {
var currentVO:Number = 0;
for each (var scoreVO:Object in leaderBoardDecoded)
{
currentVO++;
var leaderPic = "http://graph.facebook.com/"+scoreVO.fbname+"/picture";
var leaderPicFile : DisplayObject = loadSmallFBPic(facebookpic);
txtName = "leaderboard.txtName"+currentVO +".text";
pic = "MovieClip(leaderboard).pic"+currentVO;
txtTime = "MovieClip(leaderboard).txtTime"+currentVO;
this[txtName]= scoreVO.fname;
//this[pic].removeChildAt(0);
//this[pic].addChild(leaderPicFile);
//this[txtTime].text= scoreVO.scoreTime;
}
};
So i am looping the VO and getting the values fine however I need to dynamically get access to the text field , txtName1 -> txtName10.
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well, apparently the object "leaderboard.txtName0" (and txtName1, etc) are in fact MovieClips and not TextFields, is there a TextField within that MovieClip maybe? if so, that's the one who should be called.
Or you can post your files and I'll take a look at them.
Good luck
-V
Or you can post your files and I'll take a look at them.
Good luck
-V
ASKER
Thanks V, you sent me in the right direction
This worked
TextField(leaderboard.getC hildByName ("txtName" + currentVO));
This worked
TextField(leaderboard.getC
var currentVO:Number = 0;
for each (var scoreVO:Object in leaderBoardDecoded)
{
currentVO++;
var tmpTxtField:TextField = TextField(leaderboard.getChildByName("txtName" + currentVO));
tmpTxtField.text = scoreVO.fname + " " + scoreVO.lname;
var tmpScoreTxtField:TextField = TextField(leaderboard.getChildByName("txtTime" + currentVO));
tmpScoreTxtField.text = scoreVO.scoreTime;
var leaderPic = "http://graph.facebook.com/"+scoreVO.fbname+"/picture";
var leaderPicFile : DisplayObject = loadSmallFBPic(leaderPic);
var tmpPicField:* = leaderboard.getChildByName("pic" + currentVO);
tmpPicField.removeChildAt(0);
tmpPicField.addChild(leaderPicFile);
}
Glad to help!
-V
-V
ASKER
Tried that got this
tmpTxtField = TextField(this.getChildByN
tmpTxtField.text = scoreVO.fname;
Cannot access a property or method of a null object reference.
Your code above gave a coercion error
Symbol 'Leaderboard', Layer 'AS', Frame 1, Line 22 1118: Implicit coercion of a value with static type flash.display:DisplayObjec