Why doesn't this work?

7 posts

Flag Post

Hello! On the stage I’ve got a dynamic textbox with the name “chord1”, and a button named “startbtn”.
In the frameactions I’ve got this:


import flash.events.MouseEvent;
import flash.events.Event;

stop();

startbtn.addEventListener(MouseEvent.CLICK,startachord1);

function startachord1(e:MouseEvent){
	
	var chord1var:Number = Math.ceil(Math.random()*4);
	trace(chord1var);
	
	if(chord1var==1){
		chord1.text=String("LOL");
	}
}

I want to make so when I press the start button I’ll get “LOL” in the textbox IF chord1var is 1. The code and everything looks OK to me, but when I try it out, I won’t see nothing in the textbox, even though the trace gives me 1 :(
What is wrong?! Please help!

 
Flag Post

trace(chord1). See if it is null.

 
Flag Post

Ok, i put “trace(chord1);” in the code, and got this in the output:
[object TextField]

 
Flag Post

Um… I made a flash AS3 document.
Put your code in the main timeline
Made a button and gave it the instance name startbtn
Made a Dynamic textbox and gave it the instance name chord1

Then tested the movie.

When I pressed the button and it finally traced 1 the text said LOL

So…. What I am saying is your code works lol.

 
Flag Post

Check the really obvious stuff – you might be thinking too hard :)

Is the font colour the same as the background? Have you embedded the font? (rotated/skewed TextFields won’t work without that) Is the TextField big enough to hold the text?

 
Flag Post

So I copied everything, and pasted everything in a new document. Now it works o.0
Maybe I found a bug 0.0

 
Flag Post

It’s possible that this is a font embedding issue. If you embed some characters but not others, then the ones you didn’t embed may not show up. However, this doesn’t apply if the text field is set to use device fonts, which I think might be the default.

Note that if you type something in the text box before exporting the flash file, those characters are automatically embedded. So if you had “Hello” in the text box at the start and forgot to embed anything else, and you added “world” using code, it would display “Hello ol”.