View Full Version : Text Field displaying 'undefined' instead of my text
ms.kim615
08-13-2009, 05:09 PM
I have a text field on my flash site that shows up in the flash edit mode but when I save and test the site, the text field shows up only displaying the word "undefined". When I open the page to edit my text is still there. Here is the code for the page:
this.createEmptyMovieClip("Holder", this.getNextHighestDepth());
Holder._x = 2387;
Holder._y = 157;
Holder.createTextField("contentdisplay_txt", Holder.getNextHighestDepth(), 0, 0, 240, 230);
//
Holder.contentdisplay_txt.multiline = true;
Holder.contentdisplay_txt.wordWrap = true;
Holder.contentdisplay_txt.embedFonts = true;
Holder.contentdisplay_txt.html = true;
//
contentFormat = new TextFormat();
contentFormat.font = "Font1(embedded)";
contentFormat.size = 10;
contentFormat.color = fordisplay_txt.getTextFormat().color;
contentFormat.kerning = fordisplay_txt.getTextFormat().kerning;
//
Holder.contentdisplay_txt.text = fordisplay_txt.text;
Holder.contentdisplay_txt.setTextFormat(contentFor mat);
//Remove user input text field
fordisplay_txt._x = 3000;
Please, someone, help! It's driving me crazy. Try and describe directions to me in the simplest form possible, I'm new to flash. Thanks ahead of time!!!
tadster
08-15-2009, 09:24 PM
What is fordisplay_txt? Another text field, yes?
Try putting just a string like "Hello World" instead of fordisplay_txt.text.
It is fordisplay_txt.text that is undefined.
That is perhaps because the user has not had a chance to input any text into it.
Right away when the swf starts, you've got it putting fordisplay_txt.text as the text of another text field before the user even has a chance to input anything, therefore its text is undefined.
Also if you want to remove fordisplay_txt you should do one of these:
fordisplay_txt.visible = false; or stage.removeChild(fordisplay_txt);
nazojan
08-17-2009, 03:06 AM
Hi everyone,
about the issue I thinks that trying to assaign befor geting the value of that object, if you run the debuger and stepin to the code by puting a break point you can find the issue.
I have another question for you guys if any one can halp:
I need to load textbox.text in to string Obj and find the x y coordinates of some characters by the start and end index of that string. I am already doing this by using textSnapShot class but this class is working only on static textbox it is not working on dynamic textbox. any one knows any way of doing this? please help!! here is the snapshot function it returns xy coords:
function GetStringXY(startindex, endindex):Array{
var xy:Array = new Array();
var mc:MovieClip = this;
var tss:TextSnapshot = mc.getTextSnapshot();
var xydata:Array = tss.getTextRunInfo(startindex, endindex);
xy.push(xydata[0].matrix_tx);
xy.push(xydata[0].matrix_ty);
//trace("matrix_tx: " + xy[0].toString());
//trace("matrix_ty: " + xy[1].toString());
return xy;
}
thanks in advance.
Potemkyn
08-17-2009, 02:58 PM
nazojan, have you considered the possibility of creating your text using individual letters? I've never done that before, but it might be something to consider.
You could run over to Kirupa.com and visit the page where they make a mouse trail from a line of text. This is a sort of tutorial:
http://www.kirupa.com/developer/mx/mousetrailer.htm
here's the code (no, I did NOT write this):
Text = "Kirupa has the best site on the net!!!";
letters = Text.split("");
letterformat = new TextFormat();
letterformat.font = "Verdana";
letterformat.align = "center";
letterformat.size = "10";
spacing = 8;
speed = 3;
for (var LTR = 0; LTR<letters.length; LTR++) {
mc = _root.createEmptyMovieClip(LTR+"l", LTR);
mc.createTextField(letters[LTR]+"t", LTR, LTR*spacing, 10, 20, 20);
with (mc[letters[LTR]+"t"]) {
text = letters[LTR];
setTextFormat(letterformat);
selectable = false;
}
if (LTR) {
mc.prevClip = _root[(LTR-1)+"l"];
mc.onEnterFrame = function() {
this._x += (this.prevClip._x-this._x+5)/speed;
this._y += (this.prevClip._y-this._y)/speed;
};
} else {
mc.onEnterFrame = function() {
this._x += (_root._xmouse-this._x+10)/speed;
this._y += (_root._ymouse-this._y)/speed;
};
}
}
Mike
ms.kim615
08-24-2009, 01:59 PM
Where should I put the stage.removeChild(fordisplay_txt); in at? Should I actually delete the ford_display_txt.;?
Potemkyn
08-24-2009, 02:17 PM
Hmmm...
So, your code works when you test it in Flash, but when you test the swf, it shows undefined. Where is the code that you've shown here, all in one frame? I'd guess you're having a path problem since it works in testing, but not on the web. Is this movieclip that you created nested in other movieclips? And where:
Holder.contentdisplay_txt.text = fordisplay_txt.text;
where is fordisplay_txt? This to me seems to be the problem. Though, I'd guess that fordisplay_txt is a fill-in?
Mike
ms.kim615
08-24-2009, 04:09 PM
I have no idea.. I created the site by editing a template... I didn't create any coding
ms.kim615
08-24-2009, 04:12 PM
Here is my new code. I got the text to show up but now it just flickers. What do I do?
NEW CODE:
this.createEmptyMovieClip("Holder", this.getNextHighestDepth());
Holder._x = 237;
Holder._y = 157;
Holder.createTextField("contentdisplay_txt", Holder.getNextHighestDepth(), 0, 0, 240, 230);
//
Holder.contentdisplay_txt.multiline = true;
Holder.contentdisplay_txt.wordWrap = true;
Holder.contentdisplay_txt.embedFonts = true;
Holder.contentdisplay_txt.html = true;
//
contentFormat = new TextFormat();
contentFormat.font = "Font1(embedded)";
contentFormat.size = 10;
contentFormat.color = fordisplay_txt.getTextFormat().color;
contentFormat.kerning = fordisplay_txt.getTextFormat().kerning;
//
Holder.contentdisplay_txt.text = fordisplay_txt.visible = Please send a detailed description, including: size, material, colors, and quantity. If you are inquiring about a digital print, attach images to your e-mail. For faster service, please include multiple forms of contact.
E-MAIL INQUIRIES TO:
Verosigns@aol.com;
Holder.contentdisplay_txt.setTextFormat(contentFor mat);
Potemkyn
08-24-2009, 06:28 PM
What version of Flash are you using and what version are you publishing to?
Try putting a stop(); at the end of your code and see what that does.
Also in this code add the two trace lines and the line that sets contentdisplay_txt.text = a test text:
this.createEmptyMovieClip("Holder", this.getNextHighestDepth());
Holder._x = 237;
Holder._y = 157;
Holder.createTextField("contentdisplay_txt", Holder.getNextHighestDepth(), 0, 0, 240, 230);
// add this line:
trace('Holder: '+Holder);
//add test text
Holder.contentdisplay_txt.text = "This is a test of the contentdisplay text field!!!";
// add trace to see if that can be accessed:
trace('contentdisplay = '+Holder.contentdisplay_txt.text);
Here, the text is very long and could cause trouble. You also have a syntax error, you need to add quatations around your text:
Holder.contentdisplay_txt.text = fordisplay_txt.text = "Please send a detailed description, including: size, material, colors, and quantity. If you are inquiring about a digital print, attach images to your e-mail. For faster service, please include multiple forms of contact.
E-MAIL INQUIRIES TO:
Verosigns@aol.com";
// add this line to see what is is fordisplay at the end:
trace('fordisplay: '+fordisplay_txt.text)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.