11 Replies Latest reply on May 19, 2006 4:33 AM by digitalkiwi

    Dynamic URL link How?

      I want to be able to change the URL web address of web links inside my flash document by the means of an external text file, is this possible? I cant find any reference to any simple actionscript on the web.
      I don’t want to use php or any other scripting, I was thinking of putting a variable in the url field then loading a text file with the urls I want it to link to??

        • 1. Re: Dynamic URL link How?
          yeah, you can use the LoadVars class to assign a value to a variable which holds the URL
          for instance you can have this variable :
          var URLplace:String="some place in internet"
          then you write myButton.onRelease =function(){
          gotoURL(URLplace, "_blank");
          and then you can assign a different value by loading a text file within your LoadVars object :
          &anotherPlace="another place in internet"
          and your URL is now a different one
          • 2. Re: Dynamic URL link How?
            digitalkiwi Level 1
            Hey thanks, I understand the theory but when I code it up it doesn’t seem to work? The variable is defiantly getting written because I checked it with a dynamic text box but when I release the button it doesn’t launch a web page? I have even tried coding the button itself just to launch the webpage I defined as the variable inside flash.

            I’m missing something here,

            • 3. Dynamic URL link How?
              ActionScripter1 Level 1
              try just

              //text file//


              getURL(URLplace, "_blank", "POST");

              getURL(URLplace2, "_blank", "POST");

              Notice there is a gotoURL in this post and not getURL

              • 4. Re: Dynamic URL link How?
                digitalkiwi Level 1
                It just comes up with cannot find file “…………..URLplace” make sure path or internet address is correct?

                I cant even get a simple “get url” to www.google.com on a button to work?

                Any ideas would be great?

                So it seems the URL is not reading the variable; when the variable is defined as a URL, its just trying to look for the variable name eg: “URLplace” instead of the web address the variable 2URLplace” represents??

                There must be code to tell flash the variable is representing a web address??

                • 5. Re: Dynamic URL link How?
                  ActionScripter1 Level 1
                  you could try it with the http:// in your text file.

                  • 6. Re: Dynamic URL link How?
                    digitalkiwi Level 1
                    I put the http:// in and now nothing appears, not even an error message?
                    • 7. Re: Dynamic URL link How?
                      ActionScripter1 Level 1
                      URL1 = " http://www.google.com";

                      on (release) {
                      getURL(URL1, "_blank", "POST");

                      just create a blank document and then create a button then put this code under the button.

                      Let me know if that works.
                      • 8. Re: Dynamic URL link How?
                        ActionScripter1 Level 1
                        First of all create your text file.


                        Then for your movie create a button and add this code to it.

                        on (release) {
                        getURL(prf+URL1, "_blank");

                        Load in your variables from the text file and press the button.
                        • 9. Re: Dynamic URL link How?
                          digitalkiwi Level 1
                          Ok now its just getting weird, its now displaying www.(root of my page)/NaN??

                          You would think it would be simple?
                          • 10. Re: Dynamic URL link How?
                            tomdei Level 1
                            OK, I think people may be missing the obvious here. The posts above are all correct ActionScript. Some of them have more code than is really needed but it all looks correct so I am going to guess that the problem is that no one has mentioned that on the default Flash security settings, you cannot access links on the internet from Flash movies run from your local machine.

                            In other words, if you create a button with a link to http://www.adobe.com and run that Flash movie on your computer, it will not work. A security warning will pop-up. You need to upload your Flash movie to a server for it to work properly unless you are only using relative links (links that are relative to the current file and part of the same file system with no domain needed).

                            As for the code, my preference is to write it like this:

                            In a text file name data.txt:

                            On the first frame of the Movie:

                            On the button:

                            UPLOAD IT TO YOUR SERVER TO TEST IT.

                            Be sure to note that the text data will be cached by most browsers but that is something that can be saved for another time.

                            • 11. Re: Dynamic URL link How?
                              digitalkiwi Level 1
                              Thanks mate! sorted