FORUMS: list search recent posts

Pop Up Window with AS3

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Thomas MaCoy
Pop Up Window with AS3
on Jan 12, 2012 at 5:41:54 am

I haven't found any recent references to this, and so far every tutorial I've found online has not worked, so hopefully this isn't a question that's been repeated a dozen times already. (I'd put my Flash ability somewhere between 'beginner' and 'passable') CS3, AS3, what code do I need to open a pop up window over the main page? So far, this is all I've been able to get working correctly:

popup_btn.addEventListener(MouseEvent.CLICK, advance);
function advance(userEvent:MouseEvent):void
{
var link:URLRequest = new URLRequest("look.html")
navigateToURL(link, "_self");
}
I get that "_blank" opens in a new tab, and "_self" opens in the same window, but what does it take to get the look.html window (just a local file in the same flash folder at the moment) to open in its own window, the home page still running underneath it? (And ideally then I need to be able to control size/position/scroll bars, etc..., but one step at a time.) Every tutorial I've found has provided me with compiler errors or no response at all (Flash Local Security settings are set to allow my working folder) and I'm more or less stuck.
Some of my reading has also implied it's better to use Javascript to make this happen, and that it can be embedded entirely within the AS3 code, which is fine except I've had even less luck making that work. I only need to make this function work twice in the entire project, so I'm hoping to keep it simple. Any insight would be appreciated.
Thanks



Return to posts index

demetri tashie
Re: Pop Up Window with AS3
on Jan 13, 2012 at 3:23:29 am

thomas,

for a true pop up window, you will need to do it via javascript on the webpage. if you want flash to trigger javascript, you can do this via EdxternalInterface. This has been discussed here before. you can look at this post for some working code - both the AS3 code for inside flash, and the javascript code for inside your 'script' tags in your document head.

http://forums.creativecow.net/readpost/190/867673

you can easily adopt the code from that post to instead of having a button in the swf triggering a text field in the html to update, to rather just open your pop up window. your javascript's function would trigger code which looks more like this:

window.open("myPopUp.html", ........

i hope that helps. if you get stuck, let us know.


Return to posts index

Thomas MaCoy
Re: Pop Up Window with AS3
on Jan 13, 2012 at 9:50:19 pm

Thanks for the pointer, I will try again based off that example as soon as I can. I know one question that's already occurred to me though: When I publish out of Flash, it always generates a .js file that needs to be included in the same directory as the html pages. (As I understand it.) Should the Javascript that creates the pop up be appended to that dedicated file, or kept in the header of the relavent html page? (My HTML experience is reasonable, but my Javascript knowledge is pretty minimal.)
Thanks,
Tom



Return to posts index


demetri tashie
Re: Pop Up Window with AS3
on Jan 17, 2012 at 2:01:16 pm

don't put it in that js file - nor the 'swfobject.js' file if you use swfobject to embed your flash file (which is a much preferred method).

do keep it in the head of the html document - either directly, or as a separately linked js file


Return to posts index

Thomas MaCoy
Re: Pop Up Window with AS3
on Jan 17, 2012 at 10:08:07 pm

That makes more sense to me. I've finally got a working proof of concept, so I think I'm set.
Thanks very much for your help.



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]