PDA

View Full Version : loadVariables and Player version??


stephenF
10-18-2001, 05:56 AM
In the flash 5 book, it says that "loadVariables" is a flash 4 feature, and gives as and example the following:

on(release) {
loadVariables("data.text",0);
}

The accompanying text says that this loads information from a text file into text fields etc. Now I find that the ability to load info into a text field is a flash 5 feature (or at least that's what the output box keeps telling me). So using flash 4, my text box keeps coming up empty. Also, the way to retrieve variables once they've been loaded with "loadVariables" is to use :

onclipEvent(data) - which the book says is flash 5 only? I don't get it - in what sense is "loadVariables" a flash 4 feature? Does anyone know? Thanks or any help.

Jesse
10-18-2001, 07:39 AM
LoadVariables works in F4 and 5. ClipEvents are F5 specific. Your code, if it's Flash 5 code, is wrong though. It should be:
on(release) {
loadVariablesNum("data.text",0);
}
LoadVariablesNum is for loading into a level. LoadVariables is for loading into a target MC.

stephenF
10-18-2001, 09:56 AM
Thanks for that. The code in my actual (test) file is:

loadVariables ("text1.txt", "_root.text1box");

I have a movieclip with a dynamic text box whose variable is "text1". The instance on the stage is called "text1box"

My text file is called "text1.txt", and the first variable in it is text1=message, so, in the flash 5 player, "message" appears in the text box. But in the flash 4 player, nothing happens. Is this supposed to work in flash 4?

stephenF
10-18-2001, 01:00 PM
Me again. I've just tried putting the text file straight on the timeline (rather than embedding it in a movie) and now the text dynamically loads in flash 4 as well (phew). So, flash 4 is unable to load text if the text box is embedded in a movie clip?

Ok, the thing is, I want to be able to click on the dynamically loaded text (or box underneath it) to activate a get url that is also derived from a variable in a text file. They say in the book that in order to do this, flash has to check first that the variables are loaded, and that the way to do this is with onClipEvent(data). But onClipEvent(data) is flash 5. So how can I pass the variable to getUrl so that flash 4 can see it?Help would be great at this point...

stephenF
10-19-2001, 01:15 AM
I've got it now. If loadVariables happens earlier in the movie, getUrl can see the loaded variable. I thought I tried this - maybe I had things in movieclips to confuse the issue. Has anyone else found that the flash actionscript book doesn't explain things very well?

tg
10-19-2001, 05:47 AM
depends on the book, some are better than others.

Jesse
10-19-2001, 07:09 AM
Flash 4's loadvariables will load text into an MC with a text field in it just fine. Make sure you have the font embedded in the field. And if you want to play it in the Flash 4 player make sure you're publishing for Flash 4.

stephenF
10-19-2001, 08:42 AM
Does the fact that I'm on a mac make any difference? Because I can't get it to work in flash 4 no matter what I do. My code is:

loadVariables ("text1.txt", "_root.text1box");

I have a movieclip with a dynamic text box whose variable is "text1". The instance on the stage is called "text1box"

My text file is called "text1.txt", and the first variable in it is text1=message, so, in the flash 5 player, "message" appears in the text box. But in the flash 4 player, nothing happens.

Also, when I embed the font, a message appears telling me that an appropriate outline font is not available. This happens regardless of the font I use. In the flash 5 player, the text appears despite this message. For my actual file I ended up resorting to _sans, and this seems to have worked fine...

Jesse
10-19-2001, 02:56 PM
Mac should make no difference, but I've never heard of that font error before.

stephenF
10-20-2001, 05:27 AM
I know I'm being repetitive, but I'm at a loss...

If I have a dynamic text field on the main timeline it works fine in flash 4 and 5. If I put the dynamic text field in an MC, then put an instance of that on the timeline, (and load the variables to a target rather than level_0), then it works in 5, but nothing happens in 4. Is there something I'm doing here that is flash 5 specific?

Jesse
10-20-2001, 08:03 AM
as far as I remember loadVariables worked in Flash 4 too (as in loading into an MC) in fact I'm sure it did. If all else fails try loading into the main timeline, waiting a second then duplicating the variable in the MC. Or make the text variable in the MC reference _root.varName.

stephenF
10-20-2001, 08:11 AM
Thanks for that, but I've just got it working. What it seems to be (correct me if I'm wrong) is that flash 4 requires slash syntax. I suppose I assumed that flash exports the flash file to 4 with dot syntax changed to slash. Actually I think it does for other stuff (ie not involving variables)??

One more question on this - you said earlier to make sure that the flash file is exported as 4 - but if 5 can read slash syntax, couldn't it just be exported as 5? That way, if you have some 5 feature that you want to bring in later in the file (say, a game), then at least people with the 4 player could see your file up to that point.