4 Replies Latest reply on Nov 29, 2008 4:14 PM by bob1a2a

    can this be done?

    bob1a2a
      our plan is to see if there is a way to take this simple button idea and make it more global

      on (release) {
      if (clicked == 0) {
      getURL(" http://www.google.com", "_blank");
      clicked = 1;
      } else if (clicked == 1) {
      getURL(" http://www.yahoo.com", "_blank");
      clicked = 2;
      } else if (clicked == 2) {
      getURL(" http://www.seek.com", "_blank");
      clicked = 0;
      }
      }

      we are looking for help on how to remove the URL address. ie http://www.google.com and replace it with a reference number.
      Then have a file on another website, hosted somewhere else,that gives the reference number the URL address when the button is clicked.
      We have found that a cross domain policy file will probably be required but having trouble tracking down if it is possble to have a Actionscript look at a file, either txt or xml, and select a var from that file on another website?
      The other consideration how we have is redundancy, so that if the website with the data file is unavailable or to slow in returning the result how can the script then look at a secondry website.

      Is this possible or are we mad?

      Any tips on what the code should look like would be very helpful.
        • 1. Re: can this be done?
          clbeech Level 3
          this is certainly possible, however you may need to adjust your method concept just a bit. it may be best to simply 'load' the file containing the data on the 'front end' of the app, that is - right away. by doing so the data will be available to use at the time that the button is pressed. you could 'store' the values from the file within an array the you can then use in your determining conditional statement to nav to the appropriate site. you should be able to access the file on another domain and load it without a cross-domain policy file, and use:

          System.security.allowDomain('www.thesite.com');

          this will allow cross-scripting from outside the domain of the file. how you iterate through the data and 'store' it can be done in several different ways, and the 'file' itself could a variety of different types, it just depends on what you are comfortable using - a text file is the simplest, xml is more complex but an excellent format, you could also use php - as well as php with a Database (like mySQL) containing the data (much more complicated than you may want or need here)

          the code you use will be determined mostly by the type of data file you use, the LoadVars class will work for either a txt file or a php return, but you would need to use the xml class(es) to sort out the nodes and values if you go with xml.
          • 2. Re: can this be done?
            bob1a2a Level 1
            thanks clbeech, good to know we are looking at something that can be done.
            A bit more info on it is that there will probably these buttons on different websites all looking at the eternal reference file, The reference file could contain over 1000 different URLs. Our thought was not to load all URLs from the reference file as they will not all be relevant to an individual button.
            We have been looking through a lot of forums to see if someone else may have done something similar. That is to see what the code looked like to search a txt file and retrieve the required info from a file on a external site.
            As you might of gathered, we are relativily new to this, but like a challange to learn from.
            Any tips or info you could point us towards would most appreciated.
            • 3. Re: can this be done?
              clbeech Level 3
              no problem bob, you're welcome.

              hmmm... well i have couple of thoughts here. text data is very small and even with many 1000s of listings may only take a second or two to actually be downloaded to Flash, milliseconds to iterate and sort, or to 'find' a listing. so that aspect is still not out of the question - even if you have multiple parameters, nodes or attributes in a xml file - the actual 'time' it takes to gather the info is going to be small.

              however - "don't do it if you don't have to" - is never a bad idea. so considering more about what you goals are here, would lend to the idea of using a DB storage method for all relevent link information, and using a PHP program to retrieve the link, and/or even initiate the navigation call. I would now lean toward this: any button in any of your files/sites/pages would 'call' to a common PHP program on the hub server passing a variable to the app that relates to your referencing system. the PHP app would use that posted var to 'find' the correct link (even is this is a somewhat 'randomly' generated link) in the DB and then either initate the browser navigation, or return the data to Flash where you can nav using getURL (for instance if you want to show some graphic or do something previous to the user leaving). the advantage here would be that multiple files in multiple domains, can all access the common program, in turn accessing the DB.

              you would of course use some different methods and classes in your AS code, for instance, the LoadVars() class would be the method of choice to call to the PHP doc and send the required variable(s).

              the disadvantage here would be that you would need to learn a bit of PHP and mySQL (if you don't know them) to get the system to work - and it is possible that your host doesn't allow the use of, or provide access (through installation) of either of these (although this is extremely rare, and most hosts do)
              • 4. Re: can this be done?
                bob1a2a Level 1
                thanks for your comments, they have given us two clear paths to think about.
                we are thinking that it would be good see if we can make both methods work then decide what looks and feels best. We do have some learning in front of us, thats all good. We do have a little knowledge of PHP/mySQL.
                Again thanks for your advise, we are bound to back soon to seek some more :-).

                talk soon