Groups | Blog | Home
all groups > flash (macromedia) > june 2004 >

flash (macromedia) : external text in Flash and aditional "white spaces"


Jack.
6/11/2004 10:08:16 PM
try

loadtextContent.onLoad = function(success){
if(success){
killWhiteSpace(loadtextContent);
}

function killWhiteSpace(theData) {
var myNewString:String = '';
var j:Number;
for(j = 0; j < theData.length; j++) {
if(theData.charCodeAt(j) > 31) {
myNewString += theData.charAt(j);
}
}
myText.text = myNewString;
}

hth
Stanislav Komlenac
6/11/2004 10:45:40 PM
Hello :-)

I have action that load external text into my flash and I have
function that take care of aditional white spaces, but i don't know
how to implement this funcion into action. Can anyone help me?

Stanislav

PS:
Action:
myText.html = true; // allows html tags and XML styles to be displayed
myText.wordWrap = true;
myText.multiline = true; // makes it scrollable
loadtextStyle = new TextField.StyleSheet(); // create a new instance
of a Class StyleSheet
loadtextStyle.load("css.css"); // loads your CSS document with defined
tags
myText.styleSheet = loadtextStyle; // applies your new XML styles to
myText
myText.setStyle("backgroundColor","0x8F908E"); // sets the background
color (Text color is set in the CSS.)
myText.setStyle("borderStyle","none");
loadtextContent = new XML(); // create a new instance of an XML Class
//loadtextContent.ignoreWhite = true;
loadtextContent.load("index.xml"); // identifies the file to be loaded
loadtextContent.onLoad = function(success)
{
if(success)
{
myText.text = loadtextContent; // loads the file into the TextArea
}
}


Function:
// This function kills any characters in the passed in string
// that are considered to be white space. White space is
defined
// as anything *below* ASCII/Unicode character code 32.
// We want code 32 because that's a space, and we want words
separated, right?

function killWhiteSpace(theData) {
var myNewString:String = '';
var j:Number;
for(j = 0; j < theData.length; j++) {
if(theData.charCodeAt(j) > 31) {
myNewString += theData.charAt(j);
}
}
return myNewString;
}
Stanislav Komlenac
6/12/2004 10:06:40 AM
[quoted text, click to view]

OK. I will :-) Let you know how it works :-))

Tnx.

Stanislav Komlenac
6/12/2004 10:21:16 AM
[quoted text, click to view]

I try this, but it doesn't work :-(
This is error report:

**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 11: Statement
block must be terminated by '}'
loadtextContent.onLoad = function(success){

**Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 25: Syntax error.
}

Total ActionScript Errors: 2 Reported Errors: 2

Stanislav

Jack.
6/12/2004 11:51:11 AM
i only copied the relevant parts, you will need the whole code -

myText.html = true; // allows html tags and XML styles to be displayed
myText.wordWrap = true;
myText.multiline = true; // makes it scrollable
loadtextStyle = new TextField.StyleSheet(); // create a new instance
of a Class StyleSheet
loadtextStyle.load("css.css"); // loads your CSS document with defined
tags
myText.styleSheet = loadtextStyle; // applies your new XML styles to
myText
myText.setStyle("backgroundColor","0x8F908E"); // sets the background
color (Text color is set in the CSS.)
myText.setStyle("borderStyle","none");
loadtextContent = new XML(); // create a new instance of an XML Class
//loadtextContent.ignoreWhite = true;
loadtextContent.load("index.xml"); // identifies the file to be loaded
loadtextContent.onLoad = function(success)
{
if(success)
{
killWhiteSpace(loadtextContent);

}
}


Function:
// This function kills any characters in the passed in string
// that are considered to be white space. White space is
defined
// as anything *below* ASCII/Unicode character code 32.
// We want code 32 because that's a space, and we want words
separated, right?

function killWhiteSpace(theData) {
var myNewString:String = '';
var j:Number;
for(j = 0; j < theData.length; j++) {
if(theData.charCodeAt(j) > 31) {
myNewString += theData.charAt(j);
}
}
myText.text = myNewString;
}

hth
Stanislav Komlenac
6/12/2004 8:16:41 PM
[quoted text, click to view]

:-) Yes, I undestand that, but now i don't get any error report, but I also don't get any text in .swf :-((

This is the action part...

myText.html = true;
myText.wordWrap = true;
myText.multiline = true;
loadtextStyle = new TextField.StyleSheet();
loadtextStyle.load("css.css");
myText.styleSheet = loadtextStyle;
myText.setStyle("backgroundColor","0x8F908E");
myText.setStyle("borderStyle","none");
loadtextContent = new XML();
loadtextContent.load("index.xml");
loadtextContent.onLoad = function(success)
{
if(success)
{
killWhiteSpace(loadtextContent);
}
}
function killWhiteSpace(theData) {
var myNewString:String = '';
var j:Number;
for(j = 0; j < theData.length; j++) {
if(theData.charCodeAt(j) > 31) {
myNewString += theData.charAt(j);
}
}
myText.text = myNewString;
}

Do you have any idea what can be wrong?

Stanislav

Jack.
6/12/2004 11:36:20 PM
add traces to help find the problem,

function killWhiteSpace(theData) {
trace(theData); //what is the result
var myNewString:String = '';
var j:Number;
for(j = 0; j < theData.length; j++) {
if(theData.charCodeAt(j) > 31) {
myNewString += theData.charAt(j);
trace(myNewString); //what is the result
_root.myText.text += myNewString;
}
}
}



Stanislav Komlenac
6/13/2004 10:01:00 AM
[quoted text, click to view]

OK. I did. Here is the complete action part:
myText.html = true;
myText.wordWrap = true;
myText.multiline = true;
loadtextStyle = new TextField.StyleSheet();
loadtextStyle.load("css.css");
myText.styleSheet = loadtextStyle;
myText.setStyle("backgroundColor","0x8F908E");
myText.setStyle("borderStyle","none");
loadtextContent = new XML();
loadtextContent.load("index.txt");
loadtextContent.onLoad = function(success)
{
if(success)
{
killWhiteSpace(loadtextContent);
}
}
function killWhiteSpace(theData) {
trace(theData); //what is the result
var myNewString:String = '';
var j:Number;
for(j = 0; j < theData.length; j++) {
if(theData.charCodeAt(j) > 31) {
myNewString += theData.charAt(j);
trace(myNewString); //what is the result
_root.myText.text += myNewString;
}
}
}

After I hit CTRL+Enter, i got this massage in Output window:
<body>

<textformat leftmargin="8" rightmargin="8">

<Text_pt12>Dobro došli na nove web stranice</Text_pt12>

<Text_pt10>Jako mi je drago da ovo radi
J</Text_pt10>

<br />

<a href="www.nesto.hr"><img align="left" src="prof.jpg"
width="100" height="100" hspace="10" vspace="10" /></a>

<Text_pt10>dJako mi je drago da ovo radi Jako mi je drago da
ovo radi Jako mi je drago da ovo radi Jako mi je drago da ovo radi
Jako mi je drago da ovo radi Jako mi je drago da ovo radi Jako mi je
drago da ovo radi Jako mi je drago da ovo radi Jako mi je drago da ovo
radi Jako mi je drago da ovo radi Jako mi je drago da ovo radi Jako mi
je drago da ovo radi Jako mi je drago da ovo radi Jako mi je drago da
ovo radi Jako mi je drago da ovo radi Jako mi je drago da ovo radi
Jako mi je drago da ovo radi Jako mi je drago da ovo radi Jako mi je
drago da ovo radi Jako mi je drago da ovo radi Jako mi je drago da ovo
radi Jako mi je drago da ovo radi Jako mi je drago da ovo radi Jako mi
je drago da ovo radi Jako mi je drago da ovo radi Jako mi je drago da
ovo radi Jako mi je drago da ovo radi Jako mi je drago da ovo radi
Jako mi je drago da ovo radi Jako mi je drago da ovo radi Jako mi je
drago da ovo radi Jako mi je drago da ovo radi </Text_pt10>

<br /><br /><br /><br /><br /><br />

<Text_pt10>Jako mi je drago da ovo radi J</Text_pt10>

</textformat>

</body>

This is the text that is in index.txt. I try to rename this file to
index.xml, but nothing change.

Maybe it's time to sent you the .fla document?

Stanislav

Jack.
6/13/2004 11:50:35 AM
[quoted text, click to view]

i do not use MX2004, so i will not be able to open it.

try testing with a well-formed xml document
http://www.w3schools.com/xml/xml_whatis.asp

try setting your textfield to html-enabled -
trace(myNewString); //what is the result
_root.myText.html = true;
_root.myText.htmlText += myNewString;

apart from this, i am out of ideas, perhaps
somebody on this board with MX2004 and
XML experience can assist you further,


Stanislav Komlenac
6/14/2004 1:26:20 PM
[quoted text, click to view]

Thank you very much! I will try to solve this problem in other way,
maybe it work :-)))

AddThis Social Bookmark Button