homepage Welcome to WebmasterWorld Guest from 107.20.73.188
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
Flash Actionscript getURL with Javascript not working
sorta in Firefox not at all in IE
Cienwen




msg:3685395
 6:40 pm on Jun 27, 2008 (gmt 0)

Hello,

I am trying to get open a new browser window using getURL but I want to constrain the proportions (scale it). In Firefox it opens a new browser window at the correct width and height but it also opens an additional tab (different from the original launch tab) with my javascript in the URL address box and [object Window] written in the body of the page. This is bad.

In IE I get nothing at all. Here's the code:

on (release) {
getURL("javascript:window.open('http://www.example.com','Product Name Here','location=0,status=1,scrollbars=0,width=360,height=500', '_blank');");
}

I am using ActionScript 2.0

Any suggestions would be helpful and if no one has any ideas here, I will repost in the javascript section.

Thanks in advance.

 

rocknbil




msg:3685604
 10:45 pm on Jun 27, 2008 (gmt 0)

I don't think that's going to work. J.S. and Actionscript are similar, but I don't know that getURL is meant to nest Javascript. You pass URL, target, and method (post or get) to getURL.

I think you may need to dabble with fscommand. From the help manual:

fscommand function
fscommand(command:String, parameters:String) : Void

Lets the SWF file communicate with either Flash Player or the program that is hosting Flash Player, such as a web browser. ....
To use fscommand() to send a message to a scripting language such as JavaScript in a web browser, you can pass any two parameters in the command and parameters parameters. These parameters can be strings or expressions, and they are used in a JavaScript function that handles, or catches, the fscommand() function.

You use fscommand to pass the url and any other parameters to the browser and let it manage the Javascript for your sized window. Example provided in the manual:

In the web page
function myDocument_DoFSCommand(command, args) {
if (command == "messagebox") {
alert(args);
}
}

In Flash, add the call to fscommand to a button:

fscommand("messagebox", "Hello, " + name + ", welcome to our website!")

You should be able to alter this like so:


function myDocument_DoFSCommand(command, args) {
if (command == "mywin") {
// Always insures you have a true new window instead
// of loading into the same one if left open
var day=new Date();
var id=day.getTime();
// split args into an array
var argArray = args.split(',');
var url = argArray[0];
var params='width='+argArray[1]+',height='+argArray[2]+',scrollbars, resizable';
open(url,id,params);
}
}

And in flash, something like this should pass the parameters:

fscommand("mywin", 'http://url_of_new_win_content.html,600,500');

Completely untested, but should work, according to the manual. Check out the 2.0 entry for fscommand.

Cienwen




msg:3686835
 1:13 pm on Jun 30, 2008 (gmt 0)

Thanks for responding Rocknbil.

Using the fscommand is a little more complicated than I wanted to try. I don't have any experience in that department and it would require that I add javascript to the HTML file. I would like to save fscommand as a last resort.

I got the impression that the javascript would work because it was one of 4 options that was listed at Adobe (Flash) here:

[kb.adobe.com...]

So that's why I was thinking that I must be doing something wrong. If you could take a look at what Adobe is saying and compare it to what I have done I would really appreciate it!

I think I will throw this question into the javascript section too.

Thanks again.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved