dynamic button?


#1

would someone mind helping me create a button in flash that gets its url from a txt file?

i’ve made a txt file named “variables.txt”
and then have:
“link01=http://www.monotypic.com”

but i’m confused as to how to get this read into flash mx.
i have a movie clip and on the first frame i put:
“Load Variables (“variables.txt”, 0)”

then the next frame i try and use the link01 variable i made on a button as:

on (release) {getUrl( link01, “_blank”);
}

but no go… when i check my scene inside flash… if i click the button it opens up a new window with my scene directory…
when i export it and test it as a html file the link doesn’t go anywhere at all.

-any help would be enough for me to give you my undying gratitude…or my first born child… which ever you prefer…:slight_smile:


#2

it should be


loadVariablesNum("variables.txt",0)

remember that it might take a while to load the text file


#3

A text file with a list of variables, will not take that long to load so you should be good. This will also allow you to make changes without having to modify the source fla. Good idea.

Try this out; in Frame 1 of the main timeline:

onClipEvent(load) {
	this.loadVariables("variables.txt");
}

#4

thanks guys. still not working… but i’m gonna reinstall flash and see what happens…its given me prob’s like this b4 with dynamic content…


#5

Hmm,

Maybe you should post your .fla so that we can take a look. :shrug:


#6

Personally, I’d use the LoadVars() object. Assuming you’re on MX, try this:

myObject = new LoadVars();
myObject.onLoad=parseIt;
myObject.load(“variables.txt”);

Where parseIt is the function to parse the data from the new object. (Note that there are no parens after the parseIt function call. There’s some wierd thing about the timing of calling the function and the parens - didn’t understand it myself, but it seems to work.)

Also make sure that your text file is saved in a unicode format and set up with variables declared with an “&” character.


#7

here’s pretty much what i was trying…
the zip file

thanks for all the help guys, i’m really new to actionscripting and mx.


#8

It’s not pretty, but you should get the general gist of it: Dynamic Buttons Sample

If I had more time I would have created the buttons themselves with ActionScript, but this should do as a demonstration.


#9

o_0 WOW. thank you sir! your my hero!


#10

You’re welcome. You shouldn’t have much troube modifying that to your needs. :thumbsup:


#11

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.