Actionscript 3: Text not displaying properly - actionscript-3

I'm trying to display numbers in a text field in Flash CS6 but keep coming across this problem. When I run the program either a 0 is displayed or nothing at all.
Here is the code I am using
var seconds:Number = 10;
timer_txt.text = seconds.toString();
If the value of 'seconds' contains a '0' only the 0 will be displayed and if the value is anything else nothing is displayed. The text field is empty before the program starts.
Any help would be appreciated. Thanks.

Related

Flash CC HTML5 Canvas load from file/database

im new to stackoverflow, so i hope im doing everything right here ^^
So to my Question/Problem:
Im working with Flash CC and made a small HTML5 Canvas Animation. In this Animation there is a Textfield where I want to load text from a file/database. Is this possible? I assume that I have to use javascript/json for that bec Flash CC Canvas is working with that. But can I code it directly in Flash (in the Actions Panel) or do I have to open the js-output file and put my code there? And are there any examples of that case?
Second, and a more specific case of that above, I want to load a specific text into my textfield for example:
lets say I have a text in 3 languages (english, italian, french).
so I send a variable, where I state which language I want (var = eng;) and the correct text is loaded (from the file or database) to the textfield.
I hope everything is understandable (sry im not a native speaker)
Thanks in advance for any help/tips
You can code that interaction directly into the .fla file if you like.
Here is a simple example that you can play around with:
Open a new blank HTML5 Canvas Document in Flash
Create a text field and button and give them the instance names of text_box for the text box and btn for the button.
paste the following code onto frame 1 on the timeline:
//Variables
var count = 0;
//Make browser listen for a mouse click on the button
this.btn.addEventListener("click", fnCycleLang.bind(this));
function fnCycleLang()
{
if(count == 0){
this.text_box.text = "Hello World!"; //this actually changes the text in the text box
count ++;//this adds 1 to the count
}
else if(count == 1){
this.text_box.text = "Bonjour Le Monde!";
count ++;
}
else if(count == 2){
this.text_box.text = "Ciao Mondo!";
count = 0;
}
}
When you publish the .fla to HTML5 you should be able to click the button to cycle through the different languages. This way may be a but code intensive but it depends on how much text you are going to need to swap around. This would be fine for something like some menu items. Anything with a lot of text you would probably be better off not using flash to author it for you.

AS3 - Hindi font half letters getting converted

I have some text in Hindi language that should appear as क्या appears as क् या (without the space) which is not the way I want.
I am embedding fonts, but however flash is auto converting the "half letters". These sentences are getting read from an XML (which is UTF-8 encoded) and being directly applied into the textfield. In Flash Professional it shows up fine but when I check it in the app it appears as above. Anything that I am missing out on here?
Here is the textfield settings in my code:
tf.multiline = true;
tf.wordWrap = true;
tf.autoSize = TextFieldAutoSize.LEFT;
TLFTextField is the way to go. I had to convert all of my text fields in an application to TLFTextFields in order to show international characters. A TLFTextField is much larger in size then a regular TextField. You will notice when you compile the swf that it will grow quite large if you have many TLFTextField's.

No Dynamic Text will correctly show, why?

I am learning rudementary flash, and have a book in hand; but am beginning to wonder if there is something wrong with the program or my computer. The following should be simple but only gives me nothing in the dynamic text box or just pieces of letters.
Frame 1
var amount:Number = 1;
Frame 2
howmuch.text = String (amount);
and....nothing ever shows....like ever. I've used this in a simple loop according to the actionscript 3.0 lesson including an amount++ function to make a simple counter.
I'm trying to get each concept and build on it, but have been here at lesson one for days.
using Adobe Flash CC on an iMac I bought here in 2013 running Mountain Lion.
Help please.
Because your text field is a dynamic one you may need to embed the font. Also check if the text color is not the same as the color of the background.

Why does my AS3 DataGrid with sortable columns show wrong movieclip loaded in to cell after sorting?

I have a datagrid component in my AS3 project and have a custom cell renderer assigned to one column that loads a movie clip into a cell depending on the value of that cell data. For example if the cell data is the number 1 I load movieclip1, if 2 i load movieclip2. This works great. In the CustomCellRenderer Class I use the
public function set data(value:Object):void {
_data = value;
// value.Number is the value that I use to determine which movie clip to show in this cell
source = "movie"+value.Number;
}
When the DataGrid loads, the correct movie clip is loaded in to the cell. However when a user sorts the columns by clicking on the header of the column some of the movieclips dont load. I have checked that the data is sorting fine, and when I trace out "movie"+value.Number the correct string is displayed.
I think that maybe I need to unload the movie clips in each cell before setting source again? How do I do this?
Another thing I have noticed is that when the DataGrid needs to scroll because there are more rows than fit on the screen (duh!) then only one set of movieclips will be displayed at once, as if there is an 'active' or 'in focus' cell in which the only movie clips will display. Again, I am guessing that Flash is trying to only show the movie clips that are in the visible portion of the scrollable DataGrid and trying to refresh each time I scroll. However only 1 cell shows movie clips rather than all of the visible portion (which is about 8 rows).
thanks
Possibly it has something to do with datagrid cell virtualization as it tries to optimize scroll performance and recycles cell layouts. Try to set virtual layout to false, maybe it helps.

Actionscript 3 loading Chinese symbols into TextField using Actionscript

I am having trouble loading Chinese Symbols into a TextField from another TextField.
I have a dynamic drop down box that loads its text from a string within the actionscript code, however the actionscript code cannot contain chinese symbols.
I thought the easiest way around this problem would be to load the text from another TextField, however it seems to appear blank, failing to load the text.
example
base1_mc.header1.textbox_txt.text=q1.text;
base1_mc.header1.textbox_txt.text = dynamic drop down textbox.
q1.text = chinese symbols inside TextField on the stage.
I thought this would have been a simple problem, however it doesnt appear to be so.
If I try to load it using this
base1_mc.header1.textbox_txt.text=q1;
it loads some text declaring a new and empty function.
Can anyone help me out here?
Try to turn off embedFonts for TextField. I.E.:
textbox_txt.embedFonts = false.