6 Replies Latest reply on Sep 22, 2009 3:44 PM by Ned Murphy

    getURL in AS 3???  WHY so complicated??

    jefferisp7 Level 1

      This is what I hate about "upgrades" ! #(*#$& 

      I'm looking at the manual and there HAS to be a better way.  It appears the getURL is deprecated, but when I look up flash.net.URLLoader, I get 50 lines of code and a complex AIR function????    I just want to go to a new page when someone clicks a button...  

      Isn't there a simple way to do this on a button click?

       

      Jeff

        • 1. Re: getURL in AS 3???  WHY so complicated??
          Ned Murphy Adobe Community Professional & MVP

          In AS3, to make a button work with code, you need to add an event listener and event handler function for it.  You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.  In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:


          btn1.addEventListener(MouseEvent.CLICK, btn1Click);

           

          The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:


          function btn1Click(evt:MouseEvent):void {

             var url:String = "http://www.awebsite.com/awebpage.html";

             var req:URLRequest = new URLRequest(url);

             navigateToURL(req);

          }

          1 person found this helpful
          • 2. Re: getURL in AS 3???  WHY so complicated??
            Ned Murphy Adobe Community Professional & MVP

            One other thing.  If you want to remain working with AS2, you can do so with the latest versions of Flash.  You do not have to take on AS3, but it helps to learn it if you're in the business and want to remain competitive.

            • 3. Re: getURL in AS 3???  WHY so complicated??
              jefferisp7 Level 1

              Hi Ned,

              I had gotten as far as the function, but was trying to use navigatetoURL without creating a variable.

              This seems a bit redundant, if you want to create separate urls for separate buttons...  You have to create duplicate code for each?

               

              AS2 seems a lot more intuitive. It seems like most of the AS3 changes are for AIR compatibility.  I appreciate the preset motion actions now available in CS4, but having to unlearn and relearn is not my idea of a productivity increase when I'm juggling business, clients, etc. and Flash is NOT the only thing I have to do all day long.

               

              Jeff

              • 4. Re: getURL in AS 3???  WHY so complicated??
                RossRitchey Level 4

                The three lines that Ned gave you can be condensed into 1 for easier portability:

                 

                navigateToURL( new URLRequest("http://www.awebsite.com/awebpage.html") );

                 

                I agree about forcing the creation of a URLRequest object to pass into navigateToURL() - personally I feel it would be more intuitive to allow a string OR a URLRequest object, and convert the string to a URLRequest inside the function, but this is necessary at the current time.

                1 person found this helpful
                • 5. Re: getURL in AS 3???  WHY so complicated??
                  jefferisp7 Level 1

                  Just think about this guys...  This would be real development and improvement:

                  In Dreamweaver, we have so many extensions that write the banal code we need over and over again. The connections scripts are just wonderful timesavers, e.g. as well as many of the behaviors. 

                  Why, at this advanced stage of Flash development couldn't we, instead of adding more and more arcane coding to buttons by HAND, setting the link in the properties menu and having it write the code for us???   The new motion properties are just the ticket, but we lose some of the basic functionality with each upgrade. This used to be quite easy in Flash 3 and 4 when we could use the script dialog and point the target and voilà! 

                   

                  This has been my main complaint about each upgrade to new languages. You not only have to learn and entirely new language, you have to UNLEARN everything else you have learned. Any study of educational development would show that unlearning an established pattern is often harder than learning something new. I can't tell you how many times I've tried to make something work that used to work that doesn't any more and then just beings stumped for hours trying to figure out what the heck is wrong, when in fact I've done nothing wrong. Just what was once right no longer works!

                   

                  I often wonder if Adobe and previously Macromedia purposely made the code and the math so hard that it was intended to weed out everyone but dedicated programmers who could do all the wow stuff by hand.   I recently uncovered a problem with using an (AS2)  flash preloader from my components library in an AS3 file, and it prevented the stop(); action from working on the timeline. It took hours to figure out what the heck was wrong...

                   

                  I would have dedicated much more time to Flash in the past few years if I didn't keep losing ground with every new upgrade. I could not balance my love of Flash (and the time it took to relearn everything) with the budgets and time constraints of clients, esp. since Flash has been so uncooperative with SEO for clients who are not already a household name on the Net.  

                   

                  Some flash pros would say 'that is why you hire out,' but my response would be: "my clients are usually small to medium size businesses with budgets to match, and having a high end, Flash only dedicated site is out of the question."  So, I have used Flash mostly for ornaments, banners, and simpler things. I'd use it for catalog displays if they could afford a dual site, but that is not in their budgets, and frankly I can't recommend it to them unless they are music or film industry and have separate advertising media to drive the public to their sites...

                   

                  That's my rant for the day :-)

                   

                  Jeff

                  • 6. Re: getURL in AS 3???  WHY so complicated??
                    Ned Murphy Adobe Community Professional & MVP

                    I guess it's a to each his own situation.  I haven't had to unlearn anything, mainly because I still have to use AS2 quite often, but not learning AS3 would be detrimental to my skillset.  I agree that they probably made the language very difficult for people who have developed an intuitive feel for AS2, but I would also bet that all of those people didn't find AS2 intuitive when they first started learning it... AS in any flavor is alot like PHP... it has a whole bunch of specialty code to serve specific purposes, and it is only with time and experience of using them that they become intuitive.

                     

                    Flash does provide somewhat the equivalent of the bells and whistles that Dreamweaver has for what it can do, in the way of ScriptAssist.  But I gave up on using that within a month of when I started to use Flash long ago.  There is nothing magical about using the Dreamweaver tools to design a web site either. You can see every day in the Dreamweaver forum where people with greater expecations of the tools are told that they need to have a solid knowledge of html, CSS, javascript, and other web design skills in order to make Dreamweaver play well for them.  You cannot rely solely on the tool to create wonderful things that actually work... it is not smart enough (yet).

                     

                    So yes, it would be great if software could read your mind and with the click of a button do exactly what you want, but the probabilities of that happening are slim.  And the probabilities of some corporation sitting back and saying "we've made the perfect tool, no reason to create a newer one... we'll be happy with the income we get from selling this same version from here on out"  are just as slim.  There will always be people forcing a learning curve on their products... I think it's a business objective, not a technical one... sad, really.