PDA

View Full Version : getURL calling Javascript: how to pass additional variables?


isabelstripes
02-01-2003, 09:14 PM
I am using Flash MX.

I have a getURL function in my flash movie(movie1.swf) which calls on Javascript to open a popup window with another flash movie(movie2.swf) in it...the pop window works great but now I need to pass a variable as well.
The global variable(samples) is declared in movie1.swf (which is on level 2 if that matters) and the button is pressed a value is assigned to it.
Ideally, _I want the variable be passed to the the next movie(movie2.swf) and then go the appropriate frame and start playing based on that variable. (frames labels in movie2.swf are the same as the assigned values). _I do not know how to do this through Javascript. _I am very new to Flash and am extremely limited with Javscript so this has been very painful for me. __I would appreciate any help anyone can give me.

Below I have put my action script and javascript
Thank you

on (release) {
samples = "sample 1";
getURL("javascript:openNewWindow('movie2.swf','portfolio', 'height=400,width=400,toolbar=no,scrollbars=no')");
}
<script language="JavaScript">
function openNewWindow(URLtoOpen, windowName, windowFeatures){
newWindow=window.open(URLtoOpen, windowName, windowFeatures);}
</script>

tost
02-01-2003, 09:42 PM
u will need a dynamic (php/asp/..) page instead of a html page to embed your swf. from movie1, you can then target movie2.php (eg) and add the vars you want to pass as a string to the url:


on (release) {
samples = "sample 1";
getURL("javascript:openNewWindow('movie2.swf?samples="+samples+",'portfolio','height=400,width=400,toolbar=no,scro llbars=no')");
}


the php-page should parse the same html-code as the 'normal' html file you would embed your swf in, exept for the variable samples. everywhere where "movie2.swf" appears in the source, (2 times, in the embed and object tags), it should become "movie2.swf?samples=samples"

then in movie2.swf, paste this code in the first frame:

myURL = this._url;
myPos = myURL.lastIndexOf("=");
samples = myURL.substring(myPos+1, myURL.length);


should do the trick :)
check the attachment in the post below, these example files will work on any server with php.

rgdz
tost

(i edited this post 'cause i was wrong, sorry if that wasted anyone's time)
(keep in mind that "javascript" between actionscript tags in a post here always appears as "java script", cut out the space!)

tost
02-01-2003, 09:42 PM
oh, and welcome a Board :)

isabelstripes
02-01-2003, 10:44 PM
I tried the code you posted and it did not seem to work..but maybe I did it wrong. it seems my pop windows are not working either in IE.
Here is the URL if that helps ...it is PORFOLIO--->print-->brochures&mailers-->thumbnail buttons on right.

elizabethnicklaus.com (http://elizabethnicklaus.com)

Am I supposed to add gotoAndPlay(samples); after the that code that goes in frame 1 of movie2.swf ? ("samples" was the variables name.)

Also, do I need to worry about the OBJECT ID and EMBED tags within the HTML File?

Should I maybe just embed my movie2.swf into the HTML file? Will that change appearance...can I still control the scrollbars, etc.?


Thanks for your help

tost
02-02-2003, 12:12 AM
shouldn't there be a file called http://elizabethnicklaus.com/movie2.swf? couldn't find it on your server..

if the value of samples is always a frame label, you could indeed add a gotoAndPlay(samples) right after the code i gave you. (put a preloader in movie2 or you'll get in trouble).

you should leave both the object and embed tags in the html file, one's for IE and the other for netscape.

a html file should give you more control on appearance, by placing your embed and object tags inside a table cell with a fixed width and height, (eg), you can be sure that your swf won't be scaled and distorted..

grtz
tost

isabelstripes
02-02-2003, 05:18 PM
Thanks for all your help, I'll try these changes.

tost
02-07-2003, 12:28 PM
herez the files