I am creating a simple flash animation that displays text in a textField(textBox?).
var fl_TextLoader:URLLoader = new URLLoader();
var fl_TextURLRequest:URLRequest = new URLRequest("./liveStatus.txt");
fl_TextLoader.addEventListener(Event.COMPLETE, fl_CompleteHandler);
function fl_CompleteHandler(event:Event):void
{
var textData:String = new String(fl_TextLoader.data);
trace(textData);
text_feed_1.text_feed_1_text.text = textData;
}
However, when the text file has multiple lines, the text that gets displayed only contains the first line of that file, while the "trace" method displays everything in the console output. So I wonder how to display the additional lines from that text file in the textField.
Also, it would be great if these lines can be parsed into a string array. That would be even better because I can then manipulate the lines of that file.
Thank you very much!
Try to set the "multiline" (and maybe "wordWrap") value from your Textfield to true.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html
An to parse your string in a array you could use the split method from String like so:
var linesArray:Array = fl_TextLoader.data.split("\n");
\n = new line char. ("\r" or "\r\n" might alos do the trick depending on the encoding of your text file)
Related
I want to import a text file (not user import), for example:
Coding
There are several languages...
When the file is read, the first line should be in larger font and bolded, and the other lines can be kept in the text file format. Not sure how I can use JSP and link it to HTML
You've left out a lot of important details (Q: How is the JSP getting invoked? Q: Are you passing a filename in the URL? Etc. etc.)
But here's a simple example that might get you started in the right direction:
<%
BufferedReader reader = new BufferedReader(new FileReader("myile.txt"));
boolean firstLine = true;
String line;
while((line = reader.readLine())!= null){
if (firstLine) {
line = "<b>" + line + "</b>";
firstLine = false;
}
out.println(line);
}
reader.close();
%>
I am working in a fla file where i added a swf file.
How I set a text on that swf file's dynamic text. Is there any to to direct set text. I don't want to pass as parameter in url.
I tried like this
var rq:URLRequest = new URLRequest("subwindow/Time_date.swf");
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
ldr.load(rq);
function done(e:Event):void
{
var externalSWF:MovieClip = MovieClip(e.currentTarget.content);
// I have dynamic text field named dDate. I tried like this but got error
externalSWF.dDate.text = "tdfdfd";
addChild(externalSWF);
}
I got error
Error #1069: Property dDate not found on
Time_date_fla.MainTimeline_Preloader_ and there is no default value.
Please advice me
Are you using TLF text in your loaded swf?
in Time_date.fla goto file> publishSettings> actionScriptSettings> runtimeSharedLibrarySettings and change defaultLinkage to mergedIntoCode
you can read more about this problem here
hope this helps
I have a textfile, that is loaded into a swf through a flashvars:
The data is stored in Mysql,
The data is stored using coldfusion and cfquery
the data is read out into a textfile by coldfusion
the data is loaded into the swf by passing the filename to flashvars, then being read into the actionscript.
the problem is, all the text is initialized until the first
"e;
and I'm not sure how to escape this, and at what point I should.
I am storing the original text using coldfusion, and have it set the data to html edit format
#HTMLEditFormat(form.content)# />
The boy grinned as he led back to the trail.
"A big un, Granser," he chuckled
Below is the full actionscript
// This will be the starting position of the textbox
var starting_ypos:Number;
// Load the Flashvars into the script
text1.text = myVariable;
text2.int = mySecondVariable;
// Make a load vars object
my_data = new LoadVars();
// This will be how fast the text box will scroll
var scroll_speed:Number = text2.int;
// Make my on load function
my_data.onLoad = function() {
// Fix the double space issue
var my_text = unescape(this.content).split("\r\n");
my_text = my_text.join("\n");
my_text = my_text.split("\r");
my_text = my_text.join("\n");
// Set the text in the text box
scroll_text.Text = my_text;
// Set the autosize
scroll_text.autoSize = true;
// Set the starting_ypos
starting_ypos = scroll_text._y;
};
// Load the external text file
my_data.load(text1.text);
// Start the scrolling
this.onEnterFrame = function() {
// Check for hit test with the mask and the mouse
if(!mask_mc.hitTest(_root._xmouse, _root._ymouse)) {
// Check to see if we are in the mask
if(mask_mc.hitTest(scroll_text)) {
// Move the textbox
scroll_text._y -= scroll_speed;
} else {
// Reset the text box
stop();
}
}
}
// Simple stop command
stop();
When entering variables into a flash file the ampersand is used to delimit the variables, much like URL parameters.
so flash reads this:
The boy grinned as he led back to the trail. "A big un,
Granser," he chuckled
as this:
var1 = The boy grinned as he led back to the trail.
var2 = quot;A big un, Granser,
var3 = quot; he chuckled
try using URLEncodedFormat(FORM.content) so encode the vars for flash.
I have a RichTextBox which I'm trying to use to display a translateable block of text containing hyperlinks. The problem I'm having is I can't find a way to set the text property without manually coding the s and controls into the content, which isn't translateable. Is there any way of doing this? I tried saving a simple RTF file containing one sentence using Word so I could extract the bits I need, but I end up with 160 lines of difficult to decipher RTF text.
Ideally HTML would be easier but this doesn't seem to be supported
I solved this by using the http://htmlagilitypack.codeplex.com/ to parse out the anchors.
public static IEnumerable<Inline> ParseHtml(string text)
{
var inlines = new List<Inline>();
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(text);
if(doc.ParseErrors==null ||!doc.ParseErrors.Any()) {
foreach (var childNode in doc.DocumentNode.ChildNodes) {
switch(childNode.Name.ToLowerInvariant()) {
case "a":
var lnk = new Hyperlink(new Run(childNode.InnerText));
lnk.NavigateUri = new Uri(childNode.Attributes["href"].Value);
inlines.Add(lnk);
break;
default:
inlines.Add(new Run(childNode.InnerText));
break;
}
}
}
return inlines;
}
I am currently using an Ajax tool; HTMLEditorExtender to turn a textbox into a WYSIWYG editor, in a C# ASP.NET project. On the initial page load I place a large amount of formated text and tables into the editor which appears fine; even the tables.
The data is loaded into an asp:panel and the items/display from the panel is what is actually loaded into the extender and displayed.
However, if I want to have a button that saves all of the data that is in the editor to a Session and after the button press still display everything in the WYSIWG editor on the page postback everything that loads in the the textbox is fine except for the tables. They come up with the tags. Is there anyway around this?
The code I am using to initially load the page is this:
ContentPlaceHolder cphMain = (ContentPlaceHolder)this.Master.FindControl("MainContent");
Panel pnlContent = (Panel)cphMain.FindControl("innerFrame");
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnlContent.RenderControl(hw);
txtPN.Text = sb.ToString();
pnlContent.Visible = false;
On the button click I am having this saved:
string strHTMLText = txtPN.Text;
Session["ProgressNoteHTML"] = strHTMLText;
And I am loading it on the postback like this:
txtPN.Text = (string)Session["ProgressNoteHTML"];
ContentPlaceHolder cphMain = (ContentPlaceHolder)this.Master.FindControl("MainContent");
Panel pnlContent = (Panel)cphMain.FindControl("innerFrame");
pnlContent.Visible = false;
Any ideas as to why any postbacks would make the tags appear and in the original page load they do not?
The solution offered by Erik won't work for table tags containing property values. For instance: <table align="right"> will not be decoded. I have also found that <img> tags are encoded by the HTMLEditorExtender as well.
The easier solution is to use the Server.HTMLDecode() method.
TextBox_Editor.Text = Server.HtmlDecode(TextBox_Editor.Text) 'fixes encoding bug in ajax:HTMLEditor
I have the same problem, It seems to have something to do with the default sanitizing that the extension performs on the HTML content. I haven't found a way to switch it off, but the workaround is pretty simple.
Write an Anti-Sanitizing function that replaces the cleansed tags with proper tags. Below is mine written in VB.Net. A C# version would look very similar:
Protected Function FixTableTags(ByVal input As String) As String
'find all the matching cleansed tags and replace them with correct tags.
Dim output As String = input
'replace Cleansed table tags.
output = output.Replace("<table>", "<table>")
output = output.Replace("</table>", "</table>")
output = output.Replace("<tbody>", "<tbody>")
output = output.Replace("</tbody>", "</tbody>")
output = output.Replace("<tr>", "<tr>")
output = output.Replace("<td>", "<td>")
output = output.Replace("</td>", "</td>")
output = output.Replace("</tr>", "</tr>")
Return output
End Function