Opening a new windows from flash

  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

ok,
well u may have seen my last website well it got alot of stick about it being to dark, so i am designing a lighter version.
but this time i am going to cram it full of games.
what i need to know is can i make a link in flash to a html page,(with a java/flash game in it) but for it to open to the exact size of the applet?
i know you can do it in html but i am unsure about flash.
this may sound weird i will try to explain more

what i need is to make the link from flash to open a fresh page (a popup) with the exact size of the applet, and no way the user can change the size of the box. so it is locked?
hope you can help.

and please dont just say "google :D" :wink:
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Well you actually do it the same as Javascript. Becuase you will need to use javascript on the page, and then you can call the javascript function from Flash using a getURL().

I usually add this .txt file as an attachment when people ask this question, but this forum doesn't allow attachments so I am just going to copy and paste the contents of it.

Quote:
Hello, and welcome to centered pop-up windows by Shane Waldeck!

Alright, what you need to do is add this script in between the <HEAD></HEAD> Tags of your page, pretty simple eh?


<SCRIPT LANUGAGE="javascript">
<!--
function newWin(page,winName,w,h,scrollb,resize) {
var win=null;
centerWidth = (screen.width) ? (screen.width-w)/2 : 0;
centerHeight = (screen.height) ? (screen.height-h)/2 : 0;
config =
'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+''
win = window.open(page,winName,config);
}
-->
</SCRIPT>


Now we need to know how to trigger this. In HTML you trigger it like this....

<A HREF="javascript:newWin('http://www.lostinbeta.com','lostinbeta','300','200','0','0')">Open New Window 1</A>

What that does is opens a pop up window to my site, assigns the name "lostinbeta" to it, is a width of 300 and a height of 200 and is not scrollable or resizeable.

Remember, 0 = false and 1 = true. The first 0 means not scrollable, and the second 0 means not resizeable. If you want any of these changed, just change the number to a 1.

Now to have the code work in Flash...

on (release) {
getURL("javascript:newWin('http://www.lostinbeta.com','lostinbeta','300','200','no','no')");
}


This does the same thing as the above link, but works in Flash.

I hope this helps!

Shane Waldeck
http://www.lostinbeta.com



This not only creates a pop-up, it creates an automtically centered pop up no matter what the resolution :D
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Oh yeah, and one more thing....

To get it EXACT size, the HTML page that will contain your content in the pop-up window must contain no default HTML margins and no scrollbar.

How to remove the scrollbar:

This handy CSS script disables the scrollbar in both IE and NS, so you can't beat that ;)

Code: [ Select ]
<STYLE TYPE="text/css">
<!--
body {overflow:hidden};
-->
</STYLE>
  1. <STYLE TYPE="text/css">
  2. <!--
  3. body {overflow:hidden};
  4. -->
  5. </STYLE>



How to remove the margins:

You will have to add the code to your HTML body tag... for example:

Code: [ Select ]
<BODY TOPMARGIN="0" LEFTMARGIN="0" BOTTOMMARGIN="0" RIGHTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">


TOPMARGIN, LEFTMARGIN, BOTTOMMARGIN, and RIGHTMARGIN are for IE and NS, and I believe MARGINWIDTH and MARGINHEIGHT are strictly NS, I forget exactly why.

I believe this CSS code works in IE and NS too, but I am not entirely sure and can't test it right now.

Code: [ Select ]
<STYLE TYPE="text/css">
<!--
body {margin: 0,0,0,0};
-->
</STYLE>
  1. <STYLE TYPE="text/css">
  2. <!--
  3. body {margin: 0,0,0,0};
  4. -->
  5. </STYLE>



If that does work in IE and NS you can combine the no scroll and no margins code in CSS

Code: [ Select ]
<STYLE TYPE="text/css">
<!--
body {margin: 0,0,0,0; overflow:hidden};
-->
</STYLE>
  1. <STYLE TYPE="text/css">
  2. <!--
  3. body {margin: 0,0,0,0; overflow:hidden};
  4. -->
  5. </STYLE>
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

Thanks alot, that is a whole let of help.....but...
i am making a website in flash, i have used the geturl() but i did not find the option to
Quote:
To get it EXACT size, the HTML page that will contain your content in the pop-up window must contain no default HTML margins and no scrollbar.

so?,...is there an option i missed?
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You add the code to remove the margins inside of the HTML file that you load into the pop-up window. This is not something you do in Flash or with the button that launches the window, it is something you do with the page that will get loaded into the window.
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

im sorry, but i found my answer http://www.kirupa.com/developer/mx/centered_popup.htm
hehe, does exactly what i want, sorry to bother you
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

I believe that tutorial has issues when using it for multiple buttons to pop up windows.

Not entirely sure on that fact, but some peopl have had problems with it, I don't know if it is something they did wrong or if it is something wrong with the script.

Anywho, good luck, have fun, code freely.
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

i will, i will 8)

although i am very bad with any type of coding, lol, i struggly with html but somehow managed to make a site with it :roll:

but flash is easy and i like it, the next design i am hoping will concerntrate on games :wink:

because before it did not have any theme lol
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6375
  • Loc: twitter.com/unflux

Post 3+ Months Ago

i'll speak from personal experience on that tutorial - it doesn't work properly.

kalbal - if you do anything in flash, the last person in the world you want
to ignore advice and code from, is lostinbeta. he's an up-and-coming
master, and you brushed him off for a crappy tutorial. I'd reconsider his
efforts and posts he made for you, because I guaran-damn-tee it's
going to be better than most anything else you find.

ok *whew* I feel better
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Hehe, you're so sweet Unflux :D
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

hehe, unflux ur so funny sometimes :wink:

-:lostinbeta u probably are the best coder on this forum (and i respect you for that), i just like the way unflux seems to stick up for every1 whenever i post something :wink: :-
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6375
  • Loc: twitter.com/unflux

Post 3+ Months Ago

It wouldn't matter who it was, if they continue to post the way they do,
they're going to hear about it. Sorry if that's a problem to you.

i don't stick up for anything but respect. I just don't feel like you have
any respect in regards to lostinbeta's efforts to answer your question.

I'm sorry you think I'm after you or anything like that, but maybe you
should be looking at how you post. It's pure coincidence if what you say
is true.

I have nothing against you at all. :D
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

I have nothing against u either (cleared that up)
and yes i do respect the effort lostinbeta put into this topic. he should know it as well, i did not expect so much input, i am sorry if it came across that i didn't.


*i am 16, so does that mean i am allowed to be a little nieve* :P just kidding ;)
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6375
  • Loc: twitter.com/unflux

Post 3+ Months Ago

no probs here, like I said. Hard to tell how people are saying things
sometimes in typed words.

we're all good. sorry lostinbeta's help isn't what you wanted tho.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

There is always (well usually) more than 1 method to do something. If you found a method you prefer more then go for it, but my method is always here as backup if the alternative method you found doesn't work out for you.

Perhaps I will rewrite the code in that centered pop up in Flash tutorial over at Kirupa and re-submit it to him... maybe.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Ok, well I have already submitted the modifications to Kirupa, now let's just wait to see if he decides to make th changes ;)

But while you wait, in the code in the tutorial replace the MovieClip.prototype.openWinCentre function with this
Code: [ Select ]
_global.openWinCentre = function(url, winName, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) {
    getURL("about :window.open('"+url+"','"+winName+"','"+"width="+w+",height="+h+", toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+", scrollbars="+scrollbars+",resizable="+ resizable+",top='+((screen.height/2)-("+h/2+"))+',left='+((screen.width/2)-("+w/2+"))+'"+"');void(0);");
};
  1. _global.openWinCentre = function(url, winName, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) {
  2.     getURL("about :window.open('"+url+"','"+winName+"','"+"width="+w+",height="+h+", toolbar="+toolbar+",location="+location+",directories="+directories+",status="+status+",menubar="+menubar+", scrollbars="+scrollbars+",resizable="+ resizable+",top='+((screen.height/2)-("+h/2+"))+',left='+((screen.width/2)-("+w/2+"))+'"+"');void(0);");
  3. };


The code for the buttons will still be the same, all I had to do was make a few minor adjustments to the function that opened the window so that it would work for multiple windows.

Funny how this tutorial has been something I wanted to fix for quite some time now, but I just never got around to it. Then this thread happened, and I go to fix it, and it takes me all of 30 seconds to fix and test... makes me wonder what I waited for.... hehe. :lol:
  • Nucleo
  • SausagePorkPie
  • Mastermind
  • User avatar
  • Posts: 2297
  • Loc: UK - England

Post 3+ Months Ago

that is the 1 i tried, but when i did it came up with an error, so atm i am stuck with this : http://www.stormhosting.cjb.com/users/kalbal/flash3/main.html
if u click on the games u will see, for some reason when i tried the tutorial flash its self came up with an error, maybe it was me, or what u changed may of been it?
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Update: The tutorial over at kirupa.com has been updated last night ;)

As for it not working and giving you errors, that's weird, it works fine for me. Are you sure you are putting the code in the right places?

Also, you have to test the pop-up button in a browser instead of preview movie in flash because window.open() is a javascript command that is interpreted by the browser and not flash.
  • trippin13
  • Born
  • Born
  • trippin13
  • Posts: 1

Post 3+ Months Ago

heya I used this popup code from kirupa before and it was kool cause it was all done through flash , but I keep having problems .. for example it works on some computers but on others ???? I tried localy works ... I get popups ... i put it on server try from my computer , nothing goes to non-existing page ...no popup .... I try on the server works fine I gave it to like 5 friens didn't work on any part from one Opera user .... is this due to flash versions or OS or ?? I don't get it I use XP (worked on win 2000 pro on the server) and use mx 2004, tried exporting as flash 6 & 7 (flash 6 shows error page, flash 7 u just click the popup button and nothing happens ...) any ideas ????????

cheers
  • |anzelic|so|_
  • Born
  • Born
  • |anzelic|so|_
  • Posts: 2

Post 3+ Months Ago

lostinbeta wrote:
Well you actually do it the same as Javascript. Becuase you will need to use javascript on the page, and then you can call the javascript function from Flash using a getURL().

I usually add this .txt file as an attachment when people ask this question, but this forum doesn't allow attachments so I am just going to copy and paste the contents of it.

Quote:
Hello, and welcome to centered pop-up windows by Shane Waldeck!

Alright, what you need to do is add this script in between the <HEAD></HEAD> Tags of your page, pretty simple eh?


<SCRIPT LANUGAGE="javascript">
<!--
function newWin(page,winName,w,h,scrollb,resize) {
var win=null;
centerWidth = (screen.width) ? (screen.width-w)/2 : 0;
centerHeight = (screen.height) ? (screen.height-h)/2 : 0;
config =
'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+''
win = window.open(page,winName,config);
}
-->
</SCRIPT>


Now we need to know how to trigger this. In HTML you trigger it like this....

<A HREF="javascript:newWin('http://www.lostinbeta.com','lostinbeta','300','200','0','0')">Open New Window 1</A>

What that does is opens a pop up window to my site, assigns the name "lostinbeta" to it, is a width of 300 and a height of 200 and is not scrollable or resizeable.

Remember, 0 = false and 1 = true. The first 0 means not scrollable, and the second 0 means not resizeable. If you want any of these changed, just change the number to a 1.

Now to have the code work in Flash...

on (release) {
getURL("javascript:newWin('http://www.lostinbeta.com','lostinbeta','300','200','no','no')");
}


This does the same thing as the above link, but works in Flash.

I hope this helps!

Shane Waldeck
http://www.lostinbeta.com



This not only creates a pop-up, it creates an automtically centered pop up no matter what the resolution :D


It doesn't work :( , Error on Page - > when i press the button
-Flash MX 2004 Pro
-Publish Settings->Version-Flash Player 7

First keyframe action:

function newWin(page,winName,w,h,scrollb,resize) {
var win=null;
centerWidth = (screen.width) ? (screen.width-w)/2 : 0;
centerHeight = (screen.height) ? (screen.height-h)/2 : 0;
config =
'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+''
win = window.open(page,winName,config);
}

Button action
on (release) {
getURL("javascript:newWin('http://www.lostinbeta.com','lostinbeta','300','200','no','no')");
}

previous versions of Macromedia Flash -> it works but not in this one.. help please?
  • Trippin
  • Born
  • Born
  • Trippin
  • Posts: 2

Post 3+ Months Ago

Yeah I ended up using that code a while back ... funny thing the issue with the other one I had was dude to the free domain I was using as a test online ... popups don't work for .tk if u switch of their popup system so kinda took me a while to work that one out so I just registered a normal domain and it worked ok ;)))) sheesh ...
  • |anzelic|so|_
  • Born
  • Born
  • |anzelic|so|_
  • Posts: 2

Post 3+ Months Ago

-it doesn't work localy
-it doesn't work in my registered domain

Post Information

  • Total Posts in this topic: 22 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.