PDA

View Full Version : What is wrong with this AC? Please help me...



mgyth
April 4th, 2004, 10:40 AM
onRelease = function (){
var format = new TextField.StyleSheet();
var path = "css1.css";
var quick = "<br><p class='one'>The quick Kirupa jumps over the lazy dog.</p><br><p class='two'>The quick Kirupa jumps over the lazy dog.</p><br><p class='three'>The quick Kirupa jumps over the lazy dog.</p><br><p class='four'>The quick Kirupa jumps over the lazy dog.</p>";
format.load(path);
format.onLoad = function(loaded) {
if (loaded) {
output.styleSheet = format;
output.text = quick;
} else {
output.text = "Error loading CSS file!";
}
};
};

mgyth
April 4th, 2004, 02:14 PM
:)
I fixed it myself (soo proud :thumb: )

T-O
April 4th, 2004, 02:44 PM
please post the solution...

mgyth
April 4th, 2004, 03:21 PM
The first error was on line one.
And there was an ; to much at the end...

on (release) {
var format = new TextField.StyleSheet();
var path = "css1.css";
var quick = "<br><p class='one'>Anette er veldig søt.</p><br><p class='two'>The quick Kirupa jumps over the lazy dog.</p><br><p class='three'>The quick Kirupa jumps over the lazy dog.</p><br><p class='four'>The quick Kirupa jumps over the lazy dog.</p>";
format.load(path);
format.onLoad = function(loaded) {
if (loaded) {
output.styleSheet = format;
output.text = quick;
} else {
output.text = "Error loading CSS file!";
}
};
}

I'm planning to apply this code on a button, do any one know if it is possible to load an external text file, instead of having to write the text in the code???
greatfull for any tips i might get :thumb:

mgyth
April 4th, 2004, 03:24 PM
I got the original code on the kirupa site, hope it's ok to use it.
Thanks for all the useful info i have gotten from this site. U are doing a great job.

kathari
April 5th, 2004, 02:14 AM
Yes very possible. Use loadVars.

myData = new LoadVars();
myData.onLoad = function() {
newsBox.myText_txt.htmltext = this.content;
}

when you want to load the text you put on a button (or whatever you want to use<.

myData.onLoad = ("myText.txt")

and in the txt file you start with the variable name:
content=

Just checking: suppose you are doing this in MX2004? I read that I can't use style sheets in MX?

mgyth
April 5th, 2004, 02:50 AM
I'm not too god at AS-ing.
I'm not really sure what to do now, where do i put the code you wrote?
Do i write it into the old code or... I'm sorry I'm really bad (but I'm learning..)
Yes i use mx2004.
thanks for all your help (-:

kathari
April 5th, 2004, 03:23 AM
I'm not advanced enough to be able to put the new code directly in to yours I have used a different way to format the text (can't use css either), I am sorry... I can tell you what I have done:
Put the code on the first frame of the movie. To format it I continued like this.
myData = new LoadVars();
myData.onLoad = function() {
output.text = this.content;
myFormat = new TextFormat();
myFormat.align = "center";
txtMc.ny_txt.setTextFormat(myFormat);
}
I would have to look at this longer to be able to "redo" the code but basically I have myData as the "container" for the text(myText.txt) and load it with onLoad. it is displaying the variable "content" from the txt file. Try putting the above code on the frame (or directly on your button)without the formatting stuff and then changing your code to: output.text = "myText.txt". I am not sure that is the right way but try fooling around with it. I'll try to see if I can rewrite it when I have more time. Hopefully someone else without more knowledge looks at this too. Good luck!

mgyth
April 5th, 2004, 04:02 AM
I'll try to get it to work, will let u know if i can.
thanks for all your tips...

mgyth
April 5th, 2004, 04:10 AM
E-hemm... :hr:
look at: http://www.kirupa.com/developer/mx2004/cssfile.htm
and all the ansvers to my, and maybe your questions (at least on this topic)
will be solved.
Kirupa.com, you got to love it...