Javascript question

Is it possible to put javascript directly into flash??? And if so, how?\rThanks

What is it that you really want to do? What I mean is, what would be the point of putting it in there?

this might clear it up…\rno, you can not put javascript in your swf’s.\rbut you can call javascript functions (and pass variables to them) from a swf. so, if you want to open a new window you can’t just put getURL(“javascript:new.window”,"_blank"), but you could write a javascript function that opens a new window and call that function like this: getURL (“javascript:functionNameHere(parametersHere)”,"_blank");\rif you are passing dynamic parameters from the swf:\rgetURL(“javascript:functionNameHere(”+parametersHere+")","_blank");\rhope that helps!\rjeremy

I am wondering about the exact same thing as John who posted this topic.\r\rYou say you can call javascript functions from your .swf.\rBut where do you write this Javascript function for starters?\r\r//m3rcc

you write it in your html, just like any other javascript function.\r:) \rjeremy

Sinfiniti probably know this :slight_smile: \r\rI have the function:\r—\rfunction openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0\r if(window.screen)if(isCenter)if(isCenter==“true”){\r var myLeft = (screen.width-myWidth)/2;\r var myTop = (screen.height-myHeight)/2;\r features+=(features!=’’)?’,’:’’;\r features+=’,left=’+myLeft+’,top=’+myTop;\r }\r window.open(theURL,winName,features+((features!=’’)?’,’:’’)+‘width=’+myWidth+’,height=’+myHeight)\r \r}\r—\r\rWhat do I write in the:\ron (release)\r{\rgetURL(" ??? ")\r}\r\rI’ve tried alot on this, though it won’t work :/\rHelp is appreciated\r\r//m3rcc

Put your code in an html doc, save it in the same directory as your .swf, and then…\r\r

 on (release) {\r\r     getURL(whateveryoucalledyourHTMLdoc)\r\r}\r\r

\rDid I misunderstand? Flash would then load the HTML and execute the code contained within the page.\r\rCheers!\r-Niann

you can call that function and pass parameters like this:\rgetURL(“javascript<img src=http://www.ezboard.com/intl/aenglish/images/emoticons/embarassed.gif ALT=”:o"> penBrWindow("+theURL+","+winName+","+features+","+myWidth+","+myHeight+","+isCenter+")","_self");\rplay around with the ‘_self’, ‘_blank’, etc. to see which one works for you.\rthat should do it!\r:) \rjeremy

hmm… is it just me… or :frowning: \r\rIn the index.html where I have embedded my .swf I have this javascript function in the HEAD tag:\r—\rfunction openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0\r if(window.screen)if(isCenter)if(isCenter==“true”){\r var myLeft = (screen.width-myWidth)/2;\r var myTop = (screen.height-myHeight)/2;\r features+=(features!=’’)?’,’:’’;\r features+=’,left=’+myLeft+’,top=’+myTop;\r }\r window.open(theURL,winName,features+((features!=’’)?’,’:’’)+‘width=’+myWidth+’,height=’+myHeight)\r—\r(the function is within it’s requierd script language=“JavaScript” , but I couldn’t write HTML for it on this forum) The script works, I have tried it on a HTML page before.\r\rAnd on a button in my Flash i have this action:\r—\ron (press) \r{\rgetURL (“javascript: openBrWindow(”+page.html+","+PageV.1.0+","+status=0,toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0+","+600+","+400+","+true+")","_blank");\r}\r—\rAnd it doesn’t work? :/\rI’m going nuts over this\r\r//m3rcc pulling his hair\r\r\r

if you paste that getURL line into flash you will notice that ‘page.html’ is a variable, and you might not have intended this. it’s looking for the variable ‘html’ in the clip (or object) named ‘page’. ‘PageV.1.0’ will not work either - the syntax will not work with flash because a variable/object can not have a number as it’s name.\rhere is what i think will work…\rgetURL (“javascript<img src=http://www.ezboard.com/intl/aenglish/images/emoticons/embarassed.gif ALT=”:o"> penBrWindow(“page.html”,“PageV.1.0”,“status=0,toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0”,600,400,“true”)","_blank");\r\ri’m not entirely sure, but try it and let me know. basically that line does not pass any variables, just values. all values except the ‘600’ and ‘400’ are sent as strings.\r:) \rjeremy

It didn’t work.\rIt just opened another HTML page and in the adress it said:\rjavascript<img src=http://www.ezboard.com/intl/aenglish/images/emoticons/embarassed.gif ALT=":o"> penBrWindow(“hej.html”,“sidfan”,“status=0,toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0”,600,400,“true”)\r\rAnd nothing could be seen on the page.\r\r//m3rcc

is that when you’re testing it from flash, or from the html that contains the swf?\r:) \rjeremy

ok, i did a test. try removing the ‘location=0’ in the window parameters.\r:) \rjeremy

Same thing happend again, a new HTML page opened with all the parameters in the address field, and nothing could be seen on the page itself.\r\rI must do something wrong, other elements I might have forgotten? Nothing special in the HTML file i want to open? … must be something :/\r\r//m3rcc

do you get the error in the browser, or are you testing the movie in flash when you get the error?\r:) \rjeremy

I don’t get an error, When I press the button(I have tested clikcing from the .swf, from flash, from the HTML page with the .swf) a new HTML page opens with Nothing! on it. And in the address field it says exactly what I wrote in the “getURL”\r\rso… in my flash:\ron (release) \r{\rgetURL (“javascript<img src=http://www.ezboard.com/intl/aenglish/images/emoticons/embarassed.gif ALT=”:o"> penBrWindow(“hej.html”,“sidfan”,“status=0,toolbar=0,directories=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0”,600,400,“true”)","_blank");\r}\r\rand in the adress field of the HTML page that opened when I clicked the button with the above code:\rjavascript<img src=http://www.ezboard.com/intl/aenglish/images/emoticons/embarassed.gif ALT=":o"> penBrWindow(“hej.html”,“sidfan”,“status=0,toolbar=0,directories=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0”,600,400,“true”)\r\rMaybe I have the wrong function? It ain’t supposed to work?\rI really don’t know…\r\r//m3rcc

Maybe this helps:\r\rwww.escalix.com/freepage/…kirupa.txt\r