Go Back   SitePoint Forums > Forum Index > Design Your Site > Flash and Actionscript
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jul 25, 2003, 05:19   #1
kitjunkie
SitePoint Enthusiast
 
Join Date: Feb 2003
Location: Taunton
Posts: 28
Lightbulb Loading External Text Files into Flash MX

Hi Guy's and Gall's

I have a couple problems, i imagine probably easily fixed, but over my head

Number 1...

My flash movie loads an external text file on loading, then display's it in another scene in a scrolling box.
The problem is all the line breaks, it seems to add 2 for every 1, is that to do with the text file? or have i missed something in flash? can i remove them with action script?

Number 2...

The Flash movie doesn't reload the text file every time you oven the page, it seems to open a 'cached' version, can i do anything about this?

www.bexinoz.com

Thanks in anticipation of any help you guys can give me!

Andy
kitjunkie is offline   Reply With Quote
Old Jul 25, 2003, 07:00   #2
greg.harvey
Drupaler
bronze trophy
 
greg.harvey's Avatar
 
Join Date: Jul 2002
Location: London, UK
Posts: 3,299
Regarding the caching, the usual trick is to make sure that the URL changes slightly each time to fool the browser. Do this with a querystring. It doesn't have to do anything. You could generate it randomly with JavaScript, so that your Flash page URL is maybe something like:

Code:
http://www.yoursite.com/flash.html?14526
greg.harvey is offline   Reply With Quote
Old Jul 25, 2003, 11:19   #3
freddydoesphp
Dumb PHP codin' cat
 
Join Date: Aug 2000
Location: San Diego, CA
Posts: 5,460
As for the two line breaks between paragraphs. Its because windows newlines are \r\n and so flash interprets that as two line breaks.

I have written quite a bit on this subject over at actionscript.org

Code:
function loadText(txtFile, target) {
 myVars = new LoadVars();
 myVars.load(txtFile);
 myVars.onData = function(raw) {
  var tmpText = "";
  if (raw.indexOf("\r\n") > -1) {
	tmpText = raw.split("\r\n").join("\n");
  }
  else tmpText = raw;
  target.text = tmpText;
 }
}
loadText("myText.txt", _root.myText);
So this is my method and works quite nice. Keep in mind you need to have a text file that is just raw text, for instance
Code:
Yo I am some text with windows line breaks, yes I am Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
v
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
Yo I am some text with windows line breaks, yes I am 
v
So there you go, this is my method for taking care of that problem.
Attached Files
File Type: zip linebreaks.zip (24.6 KB, 596 views)
freddydoesphp is offline   Reply With Quote
Old Apr 4, 2004, 19:12   #4
Curtis782
SitePoint Member
 
Join Date: Apr 2004
Location: Plymouth, NH
Posts: 5
I currently have a dynamic textbox with an actionscript input of:

t = "Text1\nText2\n\n";
text = t;

What I would like to do (keep in mind this box is linked with a scroll bar but it should not matter) is have Text1, Text2, etc. called from a text file called calendar.txt using the code above where I believe I could just list event titles in an organized way and have flash separate the lines for me.

How can I make this work?
Curtis782 is offline   Reply With Quote
Old Jul 18, 2004, 22:53   #5
speedball
SitePoint Member
 
Join Date: Jul 2004
Location: coimbra
Posts: 1
hi
try this way

t = Text1 + "\n" + Text2 + "\n\n";
text = t;
speedball is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 23:10.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved