[RESOLVED] Using Load vars
What I want to do:
I have a flash quiz (projector file) that students can take home and practice.
I want students to practice at home but take the quiz at school. In the past I used flash 8 and placed a watermark on the printed answer page based on a file found on the school server. If flash loaded the file a watermark (mc) appeared lightly behind the answers saying 'printed at school'. If the file couldn't load the watermark would say 'printed at home'.
I'm trying to learn AS3 using CS4 and am trying to use the same concept.
Here is the old flash 8 code that worked great.
Code:
var my_lv:LoadVars = new LoadVars();
my_lv.onLoad = function(success:Boolean) {
if (success) {
tryagain = 0;
school._alpha = 15;
home._alpha = 0;
} else {
tryagain = ++tryagain;
if (tryagain<=4) {
my_lv.load("file:///G:/Tests/Spanish/Spanish/ok.txt");
}
if (tryagain>4) {
school._alpha = 0;
home._alpha = 15;
}
}
};
my_lv.load("file:///G:/Tests/Spanish/Spanish/ok.txt");
Here is what I have come up with for CS4. I'd appreciate any advice. I'm a hobbyist programmer.
Code:
school.alpha=0;
home.alpha=0;
var watermark="home";
var myLoad:Loader=new Loader();
var url:URLRequest=new URLRequest("file:///G:/Tests/Spanish/Spanish/ok.txt");
myLoad.load(url);
myLoad.addEventListener(Event.COMPLETE,myFile);
function myFile(evt:Event):void {
watermark="school";
}
if (watermark=="home") {
school.alpha=0;
home.alpha=.15;
} else if (watermark=="school") {
school.alpha=.15;
home.alpha=0;
} else {
school.alpha=0;
home.alpha=.15;
}
Is it a bad thing if I leave the URLRequest unable to complete because students don't have access to the school server from home?