Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-11-2003, 03:09 AM   #1
petermoy
Registered User
 
Join Date: Apr 2003
Location: Oakland, CA
Posts: 6
Default confusion about instance names and variables in createTextField

I'm trying to develop a component that creates some dynamic text that displays the current value of a user-selected variable. The data will be sent via an XML socket.

One of the user component parameters is a string called rdout_var. Suppose the user enters the string "val1".

Within my component constructor, I try to create a text field:

_root.createTextField(this.rdout_var, 1, 10, 20, 40, 80);

My problem is that I can't seem to get access to the text field using the variable - I need to explicitly use the string name.

e.g. _root.val1.type = "dynamic";

Any suggestions on a flexible way to get around this problem? The component would be used multiple times on the stage so we can display the values of a number of different variables.

I'm pretty much a newbie when it comes to Flash and Actionscript so I'd appreciate any assistance.

Thanks.
petermoy is offline   Reply With Quote
Old 04-11-2003, 03:20 AM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy...

Try this code...
ActionScript Code:
this.rdout_var = "val1"; _root.createTextField(this.rdout_var, 1, 10, 20, 400, 80); this[this.rdout_var].border = true; this[this.rdout_var].text = "Testing"; this[this.rdout_var].type = "Input";
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 04-12-2003, 04:06 AM   #3
petermoy
Registered User
 
Join Date: Apr 2003
Location: Oakland, CA
Posts: 6
Default

Thanks, Jason. Your help is appreciated.

I tried out your suggestions today.

I was able to get the following working:

_root.createTextField(this.rdout_var, 1, 10, 20, 400, 80);
_root[this.rdout_var].border = true;


When I tried this, I had some problems:

this.createTextField(this.rdout_var, 1, 10, 20, 400, 80);
this[this.rdout_var].border = true;

It looked like I was setting the parameters OK in the debugger, but for some reason I wasn't seeing any of the text displayed. I'm a little puzzled by this.

The differences are that in the first case, the text field is on _level0.val1 while in the second case the text field is on _level0.rdout1.val1

Another problem that I ran into was that I needed to use different depths for each text field that I created in order to have more than one text field displayed at a time.

Anyway, I'm fighting my way through the Flash learning curve. Thanks again for your help.

Peter
petermoy is offline   Reply With Quote
Old 04-12-2003, 04:23 AM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Hm... I am sure I am not getting what you saying...
ActionScript Code:
this.rdout_var = "val1"; this.createTextField(this.rdout_var, 1, 10, 20, 400, 80); this[this.rdout_var].border = true; this[this.rdout_var].text = "Testing"; this[this.rdout_var].type = "Input";
Is this code working for you???

If this code is not the case you want to talk about, can you explain it one more time in layman's term??? Some sample might help me understand what you are trying to do...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 04-13-2003, 06:06 AM   #5
petermoy
Registered User
 
Join Date: Apr 2003
Location: Oakland, CA
Posts: 6
Default

I'm sorry that I was unclear.

The code that you have in your last reply does allow me to set the parameters of the text field without having to explicitly use the string name. I can use the debugger to see that the variables for the text fields created by my component are indeed getting set properly.

My problem, however, is that the text fields created in this manner are not being displayed on the stage. Is there something else that I need to do to get a nested movie clip to display?

I've attached an fla file containing the component I'm trying to get working.

Thanks for all your help.

Peter
Attached Files
File Type: zip bxi_rdout1.zip (39.2 KB, 211 views)
petermoy is offline   Reply With Quote
Old 04-13-2003, 06:37 AM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Um... I haven't figured it out yet, but the code does create the text field at the bottom of the screen that says 'testing3'... The problem is that I do not see the first and second one... Hm...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 04-13-2003, 06:43 AM   #7
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Strange thing is that it seems like there are actually three text fields on the stage... Two invisible ones and one visible one... I am able to get the tab working fine and at every third tab, I get to see the tab on the last text field...

I really do not know...
ActionScript Code:
this.createTextField (this.rdout_var, _global.varnum, this._x, this._y, this._width, this._height);     this[this.rdout_var].tabIndex = _global.varnum;     this[this.rdout_var].type = "input";     this[this.rdout_var].variable = this.rdout_var;     this[this.rdout_var].border = true;     this[this.rdout_var]._visible = true;     this[this.rdout_var].backgroundColor = this.rdout_bgcolor;     tformat = new TextFormat(this.rdout_fontstyle, this.rdout_fontsize, this.rdout_fontcolor,         null, nullnull, null, null, "right", null, null, null, null);     this[this.rdout_var].setnewTextFormat(tformat);     this[this.rdout_var].text = "testing " + _global.varnum + " : " + this._name;     trace("\tthis._name = " + this._name + "\t_global.varnum = " + _global.varnum + "\tthis._x = " + this._x + "\tthis._y = " + this._y);
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 04-15-2003, 02:42 AM   #8
petermoy
Registered User
 
Join Date: Apr 2003
Location: Oakland, CA
Posts: 6
Default

Thanks Jason for taking a look at my problem. It has been a big help to me getting familiar with Flash and ActionScript by going through these forums. I appreciate your effort.
petermoy is offline   Reply With Quote
Old 04-15-2003, 07:13 AM   #9
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Um... Not much of help I was able to provide...

Did you solve the problem???
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 04-16-2003, 05:23 AM   #10
petermoy
Registered User
 
Join Date: Apr 2003
Location: Oakland, CA
Posts: 6
Default

No, I never solved the problem. It was annoying since I spent a lot of time on it and I still don't know why it didn't work.

I did find a workaround that seems to work.
If I use

_root.createTextField(this.rdout_var, _global.varnum, this._x, this._y, this._width, this._height);
_root[this.rdout_var].border = true;

the text fields appear on the stage and I can update the variable values that get displayed.
petermoy 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 Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:41 PM.

///
Follow actionscriptorg on Twitter

 


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