Solved

How do I get special characters (e.g. ö,ä,ü) from an external .txt file loaded into a dynamic Textfield?

Posted on 2008-06-20
8
384 Views
Last Modified: 2013-11-11
I am loading with the LoadVars object text from an external .txt file into a dynamic text area. The font to be used has been imported into the library, exported for ActionScript and embedded in the text area by setting the embed property to true.  
The external text includes special characters as it is written in German.  These however do not seem to transfer into Flash.  How do I get the special characters of the external text to display correctly in the .swf file?
0
Comment
Question by:Parlian
  • 5
  • 2
8 Comments
 
LVL 9

Accepted Solution

by:
ddlam earned 500 total points
Comment Utility
just save the .txt in UTF-8 format
0
 

Author Comment

by:Parlian
Comment Utility
Unfortunately it did not do the trick as yet, did however change the appearance in the .txt file and I suppose it was one piece of the puzzle missing to bring me closer to the solution.

Another problem I do have with this, is that the text displays in bold, and I cannot get the text formatting to change within Flash.  The source might be the same mistake.

 

0
 

Author Comment

by:Parlian
Comment Utility
Here is a sample of the relevant part of the code

      var tfHeading:TextFormat = new TextFormat();
      with (tfHeading) {
            font = "Verdana";
            bold = true;
            color = 0x660000;
            size = 12;
      };
      var tfContent:TextFormat = new TextFormat();
      with (tfContent) {
            font = "Verdana";
            bold = false;
            color = 0x660000;
            size = 12;
      };

      mcComContent.txtHeading.embedFonts = mcComContent.txtContent.embedFonts =true;
      mcComContent.txtHeading.setNewTextFormat(tfHeading);
      mcComContent.txtContent.setNewTextFormat(tfContent);

      var ComData:LoadVars = new LoadVars();
      ComData.load("COMinfo.txt");
      ComData.onLoad = function() {
            mcComContent.txtHeading.text = ComData.title1;
            mcComContent.txtContent.text = ComData.content1;
      };
}
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
Comment Utility
here is my approach,

create a dynamic textField on first frame and keep it out of stage area so that it does not show up when swf runs..
no need to assign instance name..

now, selecte the same font for this txtField which you want to use in other textFields
next step is, select the textField and click embed to open "Character Embedding" dialog.
now enter all special characters in "include these character" textField and click ok

you are done,

now these characters should work fine with all dynamically created textfield also.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Parlian
Comment Utility
When the text is created within Flash(AS), e.g. self labeling buttons, the special characters display fine with all dynamically created textfields.  
Only, the text which I load from an external file, created with Notepad, still omits the special characters.  

By now I have saved the text file in UTF-8 format, as suggested by ddlam, and added the textField, as suggested by aneeshchopra, unfortunately no special characters to be seen in these fields so far.

Maybe it plays a role that  the whole thing is created with slides, but I would not know why.
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
Comment Utility
can you upload your sample source file with external source file for review?
0
 

Author Comment

by:Parlian
Comment Utility
Hello aneeshchopra

Please find attached the external text file, as well as a copy of the ActionScript, which is allocated to the slide containing the textField movie clip.  I hope this is what you meant. Sorry, I am not quite familiar with the terminologies, as yet, and am not sure what the sample source file is within Flash.

The external Data was only for testing, and length of content1 for testing the scroll component.

Additionally I still do not seem to get rid of the bold  text in the content textField, but am able to manipulate text size and color with the TextFormat object.

Thank you for looking at it

Parlian
COMinfo.txt
AS2-Code.txt
0
 

Author Comment

by:Parlian
Comment Utility
Hello ddlam and aneeshchopra

I got it working (surprise, surprise) and the solution was with the format of the external .txt file. Thank you ddlam.
I am afraid I cannot say exactly what I did as I was (being very inexperienced)  just playing around with the encoding and converting, to and fro AINSI and UTF-8, until I had the text encoded in UTF-8 format with the special characters not showing as E4s or something similar.

Thank you for your support
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now