PDA

View Full Version : Loading dynamic variables?


neonleif
09-27-2003, 03:38 PM
I'm making a movie wich should load a few external variables.
So far I've tried to put
loadVariables("banner/flash.as", _level0); in a frame an it doesn't work. I've also tried variations like
loadVariables("banner/flash.txt", _level0);
loadVariables("banner/flash.as", _root);
loadVariablesNum("banner/flash.as", _level0); the contents of banner/flash.as:
var flash1 = "url";
var overskr1 = "some text";
var beskr1 = "some text";

var flash2 = "url";
var overskr2 = "some text";
var beskr2 = "some text";

var flash3 = "url";
var overskr3 = "some text";
var beskr3 = "some text"; the url's is for button links and the text is for dynamic textfields.
It all work if the file is #include'd.

So, what am I doing wrong? and how do I make it right?

Drakon
09-27-2003, 05:08 PM
Maybe what i'm telling u is not what u want but... One way wich works loading external variables is to have these variables "url encoded" i think they call them, I mean in the txt file u should put them like these:

flash1=url&overskr1=some text&beskr1=some text&flash2=url

and so on...

When u have a variable u put a & in front of it. The value of the variable is preceded by = The value should not be within quotes.

Happy flashing!

neonleif
09-28-2003, 02:22 PM
well, the external file have to be easy to edit, not for a light user like me, but for ultralight users:) the idea was that the ultralight user should be able to change the values in the .as file without too much trouble.
but then again I should make an app that converts the values to the MIME format, and how do I do that?
Thanks anyway.

Drakon
09-28-2003, 05:04 PM
Ok, so would it be considered that a ultralight user can writte in a text file and press enter?:)

I mean like that:
url1
some text1
some text1
url2
some text2
some text2

and so on....

and u would have to put in the flash file this piece of code. Got myself this one from this site also, 10x a bunch to the guy who wrote it:D


variabile= new LoadVars();
variabile.load("banner/flash.txt");
variabile.onData = function(raw)
{
vect = raw.split("\n");
}


now "vect" containes all those lines in the text file. U'll know how many lines u read from the file by using :
vect.length wich returns the number of elements the vector has. But u have to be carefull cause i see that every "element" in your file containes 3 "properties": the "url", "some text-a" and "some text-b".
So to find out actualy how many "elements" u have in your file u have to divide the vect.length by 3 and if u want to read what's the "url" say of the 4th "element" meaning url4 u would have to say:
nr=4; x=vect[3*(nr-1)];
assigning "some text-a4" to text u would have to say
nr=4; text=vect[3*(nr-1)+1];

And all this works nice in a repetitive "while" where u can increment the "nr";
PS: Jus watch out for infinite loops, hehe!:eek:

Hope i was of any help but the code is not tested!
Happy flashing!

neonleif
09-29-2003, 04:21 AM
Thank You D!
That's closer than the first answer ;)
However I found out that my problem lies in the URLencoding, you see, in denmark we use crazy letters like æ, ø and å and the URLencoding for those are even crazier. So imagine what the ultralight user might do to himself with those :eek:

Another Question
How do I generate an external file with URLencoded text in it.

f.x.: The user put some text in a form,
a link ("http://www.actionscript.org/")
and a description ("The place for Flashers"),
submits and wooptee, flash makes a textfile containing this URLencoded text:
flash1=http%3A%2F%2Fwww.actionscript.org%2F&overskr1=The+place+for+Flashers

or maybe it's science fiction?

Xenozip
09-29-2003, 07:35 AM
Hmm.. I don't know if this helps, but :

There's only two ways that I know of to display url-encoded text (or special ascii characters, or unicode characters from other languages/fonts).

1 way to do it is to to import the characters as a bitmap file (or transparent gif, actually), then trace the "bitmap" by pixle with no smoothing and covert the result to a symbol. In other words, make a gif file with two colors, make the background transparent, and write the text, then import the gif into flash and trace the image and convert to symbol.
However, I think this method is probably useless to you. So..

2nd way to do it is to embed the font. Right now, I only know of two methods for embedding fonts in Flash. The first is within the action script using embedFonts or "TextField".embedFonts. And you also have to import the font into the movie library, IIRC. The second way is to click on a dynamic text, edit the properties for the text, select "Character.." (Edit Character options button), and choose the embed font outlines for the characters that you need to embed, or all characters.

The only problem with the 2nd way (embedding the font), is that it makes your movie rather large. My 1k puzzle movie changed to a 18k movie after I embeded a japanese font. :|

But at least embedding it will display the characters properly.

Hope that helps. If not, I suggest doing a search in the actionscript library (http://www.actionscript.org/actionscripts_library/main/search.cgi?query=embedfont) for "embed".

neonleif
09-29-2003, 08:55 AM
Originally posted by Xenozip
There's only two ways that I know of to display url-encoded text (or special ascii characters, or unicode characters from other languages/fonts).

Stop Right There!
because that solved it...
actually I found out while you where posting, all I did was saving the textfile as a Unicoded file instead of ASCII.

Now I can write each variable on it's own line and put in the crazyChars and all that. Uhh, I love it!


... and thanks for helping out, y'all

Xenozip
09-29-2003, 02:01 PM
Originally posted by neonleif
Stop Right There!
because that solved it...
actually I found out while you where posting, all I did was saving the textfile as a Unicoded file instead of ASCII.

Now I can write each variable on it's own line and put in the crazyChars and all that. Uhh, I love it!


... and thanks for helping out, y'all Oh yeah, that makes sense. I was thinking the characters you were trying to use were font specific and/or just weren't displaying properly.

By the way, the art in that screenshot you posted is really sweet. Good luck on your project. :)

neonleif
09-29-2003, 06:58 PM
Originally posted by Xenozip
By the way, the art in that screenshot you posted is really sweet. Good luck on your project. :)
wasn't me :confused:
But you can have one of the project, not artsy at all bacause I didn't deside the layout :D

Anyway, I got the job done, thanks to y'all, and will deliver ONLY 24hrs after deadline:o
the site where it's gonna be (http://www.slagtojctr.dk/)

Xenozip
09-29-2003, 08:53 PM
Hehe, sorry about the deadline. *D'oh*
But at least it turned out great. At least, it looks like it did. :)

neonleif
02-25-2004, 05:16 PM
Now i'm getting complains about the pictures in it. Somehow they are not changing when the webmaster uploads a new picture, overwriting the old one.

What i'm getting at is that it must be something about internet cache... Agree?
The question is how to disable it so the the user is downloading the jpegs each time he/she visits.

By the way, I made a new thread of this (http://www.actionscript.org/forums/showthread.php3?s=&threadid=42368)

flashdudette
04-02-2004, 02:54 PM
My prob is a little different. I wonder if there is a way to take care of those "stupid" characters.
I enter the text in a asp form on the web. The result is sent to a database. Flash retreives the text from the database.
In the process the accents are lost.

For the "&" sign I used "%26" and it does show the ampersand but for the accents, it does not work. I tried "%E" for e accented to no avail.

Of course system.useCodepage = true; works but accordig to moock it's a no-no. So what do I do now?