ActionScript Open in New Window

ActionScript Open in New Window

Post by SJW23 » Tue, 09 Oct 2007 22:52:22


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?
 
 
 

ActionScript Open in New Window

Post by David Stil » Tue, 09 Oct 2007 23:33:16

SJW239


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.yqcomputer.com/
"Luck is the residue of good design."

 
 
 

ActionScript Open in New Window

Post by SJW23 » Tue, 09 Oct 2007 23:39:08

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.
 
 
 

ActionScript Open in New Window

Post by David Stil » Wed, 10 Oct 2007 01:51:53

SJW239,


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://www.yqcomputer.com/
"Luck is the residue of good design."