|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Recognizing Variables
When I load variables from a text file into my Flash movie, it works properly. But when I try to set up "If" conditions based upon the variables, it fails to read them correctly and I have to manually type the variables in.
Is there any way to fix this? All help is much appreciated. |
|
#2
|
|||
|
|||
|
do you have an example of your code? how you access the variables depends on how you loaded them in.
bret |
|
#3
|
||||
|
||||
|
re: Variables
Hello,
Thank you for your assistance. It was very strange... When I started to build a working example to show you... It actually worked. The one that I am having difficulty with is the calendar at www.thedarkcontent.com because it refuses to respond to the "If" conditions based upon the text file variables. I have included an fla to show you what I was having problems with. Sincerely, Jamie Michels |
|
#4
|
||||
|
||||
|
Oops... I made a mistake. The file that I posted does not work properly. It too, does not act upon the conditions that I specified. It should go to and stop on keyframe 2, but it refuses.
|
|
#5
|
|||
|
|||
|
i think that your problem has to do with pathing. in your text file, you have "&_root.variables=Loaded" when you probably shouldn't assign the path of the variable in the text file (in fact, it was most likely the main problem).
when you say loadVariablesNum("variables.txt",0);, you are telling flash to load all of the variables into the _level0 timeline. this means that whatever variables are present in your text file, will now exist in whatever object you loaded them in to (our object just happens to be _level0; you can load them into movieclips, timelines or _levels.) So i changed the text file to "&variables=Loaded" and then changed your script in the first frame to: PHP Code:
notice i also put an onEnterFrame function to it, and changed "eq" to "==" (eq is deprecated now...) So, because i'm on the _level0 timeline, i don't need to reference anything but "variables". Once it's loaded, i kill the onEnterFrame function and then it goes to the next frame fine. the reason that we need the onEnterFrame function is, even when we play the file locally, it still doesn't get loaded in fast enough for just one check of if(variables=="Loaded").. so we need to check it until it resolves. hope that helps. cheers, bret |
|
#6
|
||||
|
||||
|
Bret,
Thank you very much for helping me! Your actionscript totally fixed the issue and I appreciate it. Sincerely, Jamie Michels |
|
#7
|
|||
|
|||
|
glad i can help
![]() |
|
#8
|
|||
|
|||
|
bret,
I have a similar problem . I have 2 frames flash movie and a data.txt file that contains data. I want to load all data in the data.txt file in the first frame and then go to second frame. But I want to be sure that all data is loaded before going to the second frame. my data.txt file: &url1=http://www.trgamer.com &url2=http://www.shockhaber.com frame 1: PHP Code:
frame 2: PHP Code:
I expect trgamer.com open in a new window but it doesn't. Another problem is I can't use the variables in the data.txt file. For example : PHP Code:
myDynamicText is dynamic text field. and it should have the text "http://www.shockhaber.com" but it hasn't can you help me about this? thank you, Den |
|
#9
|
|||
|
|||
|
your problem seems to be much more straight forward
after looking at how you loaded your variables, you just need to make sure that you refer to your LoadVars object. So, all you need to change is :mytext.text = myVars.url2; getURL(myVars.url2, "_blank"); Because the variables that you loaded in, actually reside in the object that you loaded them in to. Your LoadVars object was called "myVars" so in order to access the variables from the text file, you need to say "myVars.url2"... hope that helps. cheers, bret |
|
#10
|
|||
|
|||
|
bret, thanks for the quick answer
I was struggling with this for days ![]() |
|
#11
|
|||
|
|||
|
glad i can help
(assuming it works.. which it was working when i tested it ![]() bret |
|
#12
|
|||
|
|||
|
you probably already answered this...
but i'm too stupid to make this work. please help *begs*
okay i'm using flash 5. i simplified my problem down to the bare essentials so that the flash file would be easy to read. okay here is what i've been doing. i create a text file named "text.txt". inside the text file i have put (on the top line) Version one: boo=carnival Version two: &boo=carnival Version three: boo=carnival& I have tried all three of these but none of them seem to work. okay in my flash movie. on the first frame i put the action: loadVariablesNum ("text.txt", 0); |
|
#13
|
|||
|
|||
|
continued
on the fourth frame i have the action:
if (boo == "carnival") { gotoAndPlay (10); } |
|
#14
|
|||
|
|||
|
still continued (why is it cutting off my message?)
on the fifth frame is the action: "stop ();"
on the tenth frame is the action: "stop ();" |
|
#15
|
|||
|
|||
|
arg .. another continue .. sorry :/
on every frame (1-10) i have put a text box that is just a normal text box that only has the name of the frame so i know what frame number the flash movie is stopping on.
then on every frame (1-10) i have put a dynamic text box with the variable: boo okay .. that is basically the file. the thing that is frustrating me so much is that in the dynamic text box it will fill in the word 'carnival'. so i know that it is opening up the right file and finding the variable for boo. it just wont go to frame 10. i've tried changing it to _root.boo or _level0.boo but these don't work either. if anyone understands this please help. after 3 agonizing days i'm about to give up ![]() |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Recognizing Variables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|