Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : how to check if loaded?



Dimak
5/29/2004 7:26:24 PM
Hello at my movie at first frame i am loading


[CODE]
myData = new LoadVars()
myData.load("en.txt")
myData.onLoad = function(succes){
if(succes){
mainpage_txt.htmlText = "<b>"+this.mainpage+"</b>"
} else trace("Error loading data")
}
[/CODE]

and i am trying to load some swf files that contain the same text at the first
frame but i want to make a change is it posible that stis file would check the
root file what txt file is loaded and load the same there are only 3 possible
en.txt , de.txt , fr.txt


i don't know how to manage this one but i hope its possible

any advices are welcome
Thanks in advance
kglad
5/29/2004 8:17:45 PM
yes, you could set a variable in your _root movie that would indicate which
file was loaded. the value of this variable would be available to any movie
that was loaded into your _root level.

for example, in your _root level you can use:

languageChosen="en.txt"; // or "de.txt" or "fr.txt" as the case may be to
designate the txt file loaded.

then in your loaded swf, you can use:

myData = new LoadVars()
myData.load(_root.languageChosen)
myData.onLoad = function(succes){
if(succes){
mainpage_txt.htmlText = "<b>"+this.mainpage+"</b>"
} else trace("Error loading data")
}

Dimak
5/29/2004 9:20:56 PM
Thnaks a lot mate for your help!
i realy apreciate it!

i have one more question

if at my first movie i have the loading function
[code]
myData = new LoadVars()
myData.load("en.txt")
[/code]

and button


that changes the loading file
[code]
on (release) {
myData.load("lang1.txt");
_level1.myData.load("fr.txt");
_level1.mc.myData.load("fr.txt");
_level0.mc2.myData.load("fr.txt");
}

[/code]

how can i trace that file is loaded ?

so i cand bind it to a variable?

thanks in advance

kglad
5/30/2004 3:41:22 AM
i'm not sure what you're asking. specifically, what do you mean by, "how can i
trace that file is loaded so i can bind it to a variable?" are you using the
word "trace" as in the actionscript function, trace()? that wouldn't make
sense because you can't trace(afile) and you can't bind a file to a variable.

do you want to confirm that your data have been loaded? if so, you can use
the onData or onLoad event handlers like you're doing now with the onLoad
handler.
Dimak
5/30/2004 1:58:51 PM
i will try to explain my self

i have two movies 1 main.swf and second is load.swf the load.swf which is
loaded by the pres on the button into main.swf into the _level1 also i have 3
text file which contain the same variables but translated into different
language
at my main.swf i have code
[code]
de = "lang1.txt";
en = "lang2.txt";
fr= "lang3.txt";
loadit = en // by default it has value en so lang2.txt is loaded
trace(this.loadit)
trace(myData)
myData = new LoadVars()
myData.load(this.loadit)

myData.onLoad = function(succes){
if(succes){
text1_txt.htmlText = "<b>"+this.text1+"</b>"
} else trace("Error loading data")
}

[/code]

also at main.swf i have language buttons which swich between the languages
unfortunatly i did't came up whth tha code yet but it would look simmilar to
his one
[code]

on (release) {
_root.loadit = de // abd the variable loadit at the main.swf shoud now
contain value de and load the land1.txt file
}

[/code]

now the last bit
i have load.swf file which is loaded by the press of the file button it
contains the code that is checcking what is currently loaded at the
_root.loadit vatiable and dependig on the value loads the text files
[code]
test = function(testit) {
if (_root.loadit == de) { lang1.txt }
else if (_root.loadit == en) { lang2.txt }
else if (_root.loadit == fr) { lang3.txt }
}
myData = new LoadVars()
myData.load(this.testit);
myData.onLoad = function(success) {
if (success) {
trace("done loading");
scroller.text = this.text2;
} else {
trace("not loaded");
}
};

[/code]

unfortunatly the only code that is working is the one in the main.swf first
frame , i am currently debugging the rest , with no luck , but i guest the idea
is right ,

hope to heare your advise
thanks in advance

kglad
5/30/2004 3:30:05 PM
attached to your buttons in main.swf, to change to fr, you can use:

on(press){
loadit=fr;
myData.load(loadit);
}

if this button is really a movieclip button you'll need to reference the _root
timeline for the LoadVars() object and the variables.

for your _level1 file that's checking the current language, you can use:

function testF(){
if(_level0.loadit==_level0.de){
//do something. i'm not sure whether you really want should reuse myData or
not.
} else if(_level0.loadit==_level0.en){
//do something else
} else {
//_level0.loadit is fr and do something else
}
}

p.s. from a _level1 movie, _root refers to the _root timeline in _level1.
Dimak
5/30/2004 5:32:41 PM
kglad

Thank you for your help i really apreciate it every this worked out evetually
but i am still fighting with one little bit on loading function at load.swf
_level1 somehow it does't want's to work properly i tryed to debugg it by
tracing it mm trace gives everythis correctly but doe't work , i will keep
trying ... maybe if you would have time to take look at the code, i have
attached to this post for just in case..

Again thanks a lot!
AddThis Social Bookmark Button