Thank you for your answer.
The purpouse of the application is giving some students a kind of ‘step by step’ lesson made with FlashMX.
So, for each part of the lessons I’ll have a few variables, as
Title, Text, Image1, Image2, Movie1, Movie2 and so on (they could virtually be as many as I need …).
My idea was to include all variables value in a text file.
For example, the images are linked to sites …
I’m looking for the chance to keep everything as a variable outside the Fla.
It could give me the ‘power’ to change everything so that my graphic interface is only a ‘graphic container’ for ALL my contents.
Create a new, empty movieclip (CTRL+F8), drag it from the library (F11) to the stage, and give it the instance name image for example.
Now, place that movieclip inside another movieclip, which I’ll give the instance name container in this example. Once placed inside, place it where you want the image to load. You can easily do that by choosing Edit in Place when opening container, that way all the content will still be visible, so you can see where to put it.
Now, apply this code to container:
[AS]
onClipEvent(load){
lv = new loadVars();
lv.onLoad = function(success){
if (success){
image.loadMovie(this.varImage1)
} else {
trace(“Failed to load textfile”);
}
}
lv.load(“textfile.txt”)
}
[/AS]
… where varImage1 is the variable from the textfile that contains the path to the image. If this path is incorrect, the jpg will not load. And, make sure your jpgs aren’t progressive. Flash can’t handle progressive jpgs.
Thanks a lot, it was very clear.
Now, other 2 questions :
Can I use that code to load any kind of file (JPEGS, SWFs, Video) ?
The schema of my movie is :
SCENE1 contains MC_menu, MC_textboxes and MC_Container.
what I have to gain is that from a btn contained in MC_Menu I have to load data (text) into the textboxes of Mc_textboxes and the file into the MC_Image of MC_Container.
Actually on Button1, contained in MC_Menu, I have this code :
where ‘testi’ is the instance name of the MC containing the textboxes.
So, if I want to load the image contained in my testo1.txt (called varImage1) in the image movieclip, contained in the container movieclip, the code should be something lik :
Actionscript :
onClipEvent(load){
lv = new loadVars();
lv.onLoad = function(success){
if (success){
_root.container.image.loadMovie(this.varImage1)
} else {
trace(“Failed to load textfile”);
}
}
lv.load(“textfile.txt”)
}
Left click on the button ?? This is why I’m confused:
what I have to gain is that from a btn contained in MC_Menu I have to load data (text) into the textboxes of Mc_textboxes and the file into the MC_Image of MC_Container.
So I suppose you want to load on left click on that button …
To have it load the image to _root.container.image. It’s the same actually, only with an on handler instead of the onClipEvent handler. I am supposing there are several textfields contained within the movieclip with the instance name textboxes. I named two of those textfields textF1 and textF2 in this example. I’m not sure if your instance names are like MC_Container or just container, but you can always change it in the AS I used varTitle and varText as vars from the textfile.
Thanks a lot for the last answer and sorry for my misunderstanding ‘right’ … !!
I only get this problem : when I preview (CTRL+ENTER) my movie,
it returns me the message :
Error opening : and the name and path of the file …
I have checked the path and it’s allright (same dir as the swf) .
Even if I change the object to load ( I tried another jpg, or an swf file), the error is the same.
That’s funny, if the image is there it should load … Are you absolutely sure the paths are correct ? We’re talking about the paths you specified in the textfile…