Hello , I'm trying to make a simple form that uses a input text box to redirect to a specific url. However it doesnt work at all. I have a input box and a button with the code bellow.
Here is my code:
on (release, keyPress "<Enter>") {
if (input == "boo") {
getURL("x3.jpg", "_blank");
if (input == "bii") {
getURL("http://www.google.ro", "_blank");
}
} else {
prevFrame();
}
}
the text input box variable is input. When i click the button it skips to the prevframe no matter if the word typed is boo or bii. It doesn't redirect me either to x3.jpg or http://www.google.ro , it skips to the prevframe. If i remove prevframe nothing happens.
I need to use about 500 words that redirects to 500 url , in my case a picture stored on the server.
If i change prevFrame(); with getURL("x3.jpg", "_blank"); When i click the button it skips to x3.jpg no matter of the word typed in the box.
As i said i need to use about 500 words . if you know a better way to do this i would appreciate your effort. i could have used a php file but my server doesn't support php or mysql. I think that xml and txt files are supported , but i'm not sure.
Thanx in advance for your help!
I would have said use switch case, but if you have 500 of these pairs, treat them as such: pairs? as in variables value pairs. That list could be in any format you can load.
boo="x3.jpg";
bii="http://www.google.ro";
then, in flash, once the list is loaded and without any conditional statements:
actionscript Code:
var myUrl:String = eval(this.input); getURL(myUrl);
Place that code in your first frame. Then the validation you call from the button:
if the value "val2" in the myList array equals the input, assign the value of "ur" to myUrl. Then, the same call than before.
Here's a (tested) working code:
Thank you for your help . I used the code , but it doesn't work. the text input box has the var input, but when i click the button nothing happens. I use flash 8 , as2 , and flash cs 4.
Ok its working , but not as it should work. if i type boo it stil goes to prevframe. No matter of what i type it goes to prevframe. What is wrong with it?
Still not working. this thing its driving . for 2 days i'm trying to make it work. It skips back to the prevframe no matter what i type. The input box var is input. tryed with instace name input , it doesn't work. On the server the same story.
Thank you for the .fla file. the file works without a problem , but when i put the code in my fla it stops working. I think it is something in my fla file that blocks it. When i enter the code and click the button it goes back to the prevframe. yours works fine, mine doesn't. Is there any other way to do this, maybe with the help of an external file?
Of course you could have the myList array content as an external file that you would split back into an array similar to the one in my example. But that wouldn't change 'the way', just the ease of editing without opening the .fla.
I see. if i put the code at the begining of the movie , it works. If i put it where i need it, it doesn't work. Ill try to put it between other layers ,maybe that will work. thank you for your help , and ill keep you up to date.
I also created a new movie with just the code , and it works just fine.
Thank you ,
Cezar
The instance of the button and the textfield with var input have to be present on that specific keyframe on your timeline where the code is. The layer's order wouldn't change a thing.