Link to home
Start Free TrialLog in
Avatar of Antonatwork
Antonatwork

asked on

creating a (flash) html popop using existing code

In a site I am working on a javascript is used to create fixed sized popup's. I would like to use the same script to create fixed sized popup's from within a flash file.

The Code that is used in the HTML is the folowing.
--------
<script language="JavaScript" type="text/JavaScript">
<!--

var win=null;
function NewWindowScroll(mypage,myname,w,h,pos,infocus){
        if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
        if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
        else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
        settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
        win=window.open(mypage,"popup",settings);
        win.focus();
}

function NewWindow(mypage,myname,w,h,pos,infocus){
        if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
        if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
        else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
        settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";
        win=window.open(mypage,"popup",settings);
        win.focus();
}
//-->
</script>
---------

The HTML link that uses this script looks like this
---------
<a href="javascript:NewWindowScroll('link.html','','400','300','center','front');">link<br/></a>
---------

I want to use the same script in a flash button to launch a new window with a fixed size.  
Can anyone help me out with this one line of code.

Thanks a lot,

Anton
Avatar of Member_2_1840827
Member_2_1840827
Flag of Switzerland image

Have you tried getURL?

on(release) {
getURL("javascript:NewWindowScroll('link.html','','400','300','center','front')");
}
Avatar of Antonatwork
Antonatwork

ASKER

I did not reall know how to combine the get URL thing and the Javascript.
The anwser you have given me does not contain an URL. I have tried the following.

on(release) {
getURL("http://www.test.com/test.html","javascript:NewWindowScroll('link.html','','400',300','center','front')");
}

But i does not work.
I just get a new screen, but nothing special like a fixed size or a 400 x 300 resolution.

Is there something wrong with my code?



No this is also not helpfull. This get URL really has to work together with the javascript mentioned in the first post.
I have no access to the index file, so I cannot change the javascript

Is the flash movie embedded in the same page where the javascript function is defined?
yes
Avatar of Vicker Leung
Anton,

try the following~

getURL("javascript:NewWindowScroll('http://www.test.com/test.html','','400','300','center','front')");

Vicker
Anton:

Don't know if you've figured this out yet, but an easy solution might be as follows:

Include the fscommand code in the HTML page that includes the Flash file.

From Flash, use:
fscommand("myFunction","myLink");

In the Javascript then, within the function declared as:
function myFile_DoFSCommand(command, args)

If it's not already there, add:
      var myArgs = new String(args);
      var cmd = new String(command);

Then, a simple if statement:
if (cmd == "myFunction") {
   NewWindowScroll(myArgs,'','400',300','center','front');
}

args can also be an array, if you want to send more than one parameter.

Hope this helps, this question has been idle for a while.

David Crossman
-=-



ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial