Groups | Blog | Home
all groups > flash actionscript > october 2006 >

flash actionscript : Noob with text input


homer72
10/31/2006 7:27:14 PM
Ok I think I understand how the input text field works on flash but no
matter how i do it I can't read from the input text field. I have a
button and if you click on it I can make it skip to other parts of the
flash movie and other things so I know the button is working. I have a
input text field with an instance name and when I click the target
button in the action script code it shows up with the instance name I
gave it and it puts it in there with relative or absolute reference no
problem. I can even type out the instance name and . and a list comes
up so I know it recognizes the object. HOWEVER, when I try to set the
text in the area objectname.text = "hello"; or read from it
if(variablename.text == "hello") I get nothing. now I've used the
target button to insert the variable so it can be this.variablename or
_root.variablename none of this is making a difference. I have read
the tutorials in the program and I have looked at examples online and I
can't see what I'm doing wrong. I've even tried using different forms
of button trigger, I've clicked on the button and added the code there
and I've also added the code to a frame with the click_btn.onrelease =
function(){code} both ways the code behaves the same, I can use
gotoandplay() fucntions and it works no problem but any attempt to read
from the input text results in nothing. Any help would be appreciated.
DazFaz
10/31/2006 10:24:55 PM
Hi Homer72,
Ive put something together that might help. Just copy paiste all of the code
into a new fla and run it. Ive commented out the area where I think your
problem is. The rest of the code is just there to create the instances to
illustrate the point better.

// create the INPUT text box
var TXTBXdepth:Number = 1
var Xposition:Number = 10
var YPosition:Number = 10
var TXTBXwidth:Number = 100
var TXTBXheight:Number = 20
this.createTextField("my_txt_INPUT", TXTBXdepth, Xposition, YPosition,
TXTBXwidth, TXTBXheight);
my_txt_INPUT.border = true;
my_txt_INPUT.type = "input";
my_txt_INPUT.text = "INPUT"
//--------------------------
// create the OUTPUT text box
var TXTBXdepth:Number = 2
var Xposition:Number = 10
var YPosition:Number = 40
var TXTBXwidth:Number = 100
var TXTBXheight:Number = 20
this.createTextField("my_txt_OUTPUT", TXTBXdepth, Xposition, YPosition,
TXTBXwidth, TXTBXheight);
my_txt_OUTPUT.border = true;
my_txt_OUTPUT.type = "dynamic";
my_txt_OUTPUT.text = "OUTPUT";
//--------------------------

var myButton:MovieClip = createRectangle(40, 20, 0xFF0000);
myButton._x = 120;
myButton._y = 25;
myButton.onPress = function() {
// this is where the transfer is done from input to output
// The rest of the code in here is redundant to your request
// I created it as so you can copy paiste the code and see if working
// without having to create any graphics for this example
my_txt_OUTPUT.text = my_txt_INPUT.text
}

function createRectangle(width:Number, height:Number, color:Number):MovieClip {
var depth:Number = this.getNextHighestDepth();
var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
DazFaz
11/1/2006 12:00:00 AM
There is one way of seeing all the code at once and that is through "Movie
Explorer" (ALT+F3). Here you will be able to open and close each script in
turn. The only problem here is that you cant edit it here. You can however
select a script in here and press(F9) and it will bring that script into the
editing panel. To hold onto that script, pin it, This is a small pin icon next
to the bottom tab in the script panel. Then, go back to the movie explorer,
select another script, back to the edit panel and pin that one too. You will
notice a series of tabs across the bottom of the edit script panel appearing.
Now all yo have to do is press each tab to go directly to that particualr
script. Very long winded I know but once you get your head around it, it can
work well for you. Or am I telling you how to suck eggs here, lol
homer72
11/1/2006 2:57:05 AM
Hmm, that makes sense to me, I can understand your code perfectly, however I
don't understand how to get into a code view in the program. If I could view
the flash code like you have put here I would be in business, I just can't see
in the program where to enter a code view, I know you can open the little
sections for each frame, button, whatever, but to see all the code at once
would be helpful. Is that what you are suggesting or are you saying I should
just click on the layer, open the actionscript window and paste this in there?
AddThis Social Bookmark Button