I am trying to make use of an external style sheet and text file loader as a function. However, it appears that somewhere along the line a variable is perhaps over riding another one. I don’t quite have the grasp of this code, and that’s why I probably can’t detect where my error is.
The following function works when I perform the first ‘storyLoader’ call. But the second ‘storyLoader’ call returns an “undefined” in both text fields.
Here is the code:
// Code begin
storyLoader(feature1, “featurestory1.txt”);
storyLoader(feature2, “featurestory2.txt”);
function storyLoader(thefeature, thefile) {
var format = new TextField.StyleSheet();
var path = “feature.css”;
format.load(path);
format.onLoad = function(loaded) {
if (loaded) {
thefeature.story.styleSheet = format;
thefeature.links.styleSheet = format;
myLoadVar = new LoadVars ();
myLoadVar.load(thefile)
myLoadVar.onLoad = function (success){
if (success == true) {
thefeature.story.variable = “story”
thefeature.story.htmlText=myLoadVar.story;
thefeature.links.variable = “links”
thefeature.links.htmlText=myLoadVar.links;
}
}
} else {
output.text = “Error loading CSS file!”;
}
}
}
// Code end