3 Replies Latest reply on Oct 8, 2007 9:51 AM by Newsgroup_User

    ActionScript Open in New Window

    SJW239
      Good morning y'all

      I am trying to load a picture in a new window when a button is clicked. My code is as follows:

      on (release) {

      _root.loadMovie("screenshots\\clientprofile.jpg", "_blank");

      }

      It will load the graphic, but not in a new window. Any suggestions?
        • 1. Re: ActionScript Open in New Window
          Level 7
          SJW239

          > It will load the graphic, but not in a new window.
          > Any suggestions?

          By "new window," do you mean a new browser window? If so, you'll want
          something like getURL(), whose optional second parameter lets you specify
          how the new window should open, just like with anchor tags (<A>) in HTML.


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: ActionScript Open in New Window
            SJW239 Level 1
            Right - it works that way... only I have about 100 thumbnails to go along with 100 screen shots, and I didn't want to make a web page for each picture. Is there any way to do it like I am now? And yes, I mean a new browser window.
            • 3. Re: ActionScript Open in New Window
              Level 7
              SJW239,

              > Right - it works that way... only I have about 100 thumbnails to
              > go along with 100 screen shots, and I didn't want to make a
              > web page for each picture. Is there any way to do it like I am
              > now?

              Aha. Well, loadMovie() loads SWFs, JPGs, and the like into a movie clip
              target. That might be the main timeline (which is a movie clip) or an empty
              movie clip target -- but it's not going to put anything into a new window.
              The "_blank" parameter of getURL() operates essentially the same way an
              anchor tag does (target="_blank"), which does open a new browser window
              every time. If you want to open a new browser window once and keep reusing
              that same window, you'll have to use JavaScript.

              JavaScript doesn't run inside Flash Player, but the browser certainly
              knows what to do with it -- so you'll have to use ActionScript to pass your
              intentions along to JavaScript, which will then open a new window.
              JavaScript allows you to give new browser instances (new windows) a special
              name, so that you can then continue referencing that name as you send new
              images (or HTML documents, or whatever) to it.

              The recommended way to communicate with JavaScript from Flash is via the
              ExternalInterface class, so check that out in the ActionScript 2.0 Language
              Reference and see if the example code gets you started. If you get stuck,
              write back and I'll continue to follow up with you. You'll use ActionScript
              ExternalInterface class to invoke the window.open() method in JavaScript.


              David Stiller
              Co-author, Foundation Flash CS3 for Designers
              http://tinyurl.com/2k29mj
              "Luck is the residue of good design."