dcsimg
A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Java pop up question

  1. #1
    Senior Member ryantsi's Avatar
    Join Date
    Sep 2005
    Location
    Exeter, Devon
    Posts
    288

    Java pop up question

    Hey all

    I am building a site at the moment which has an image gallery, the gallery itself is fine, it is a simple one loading in external pics in swf files, but due to layout i thought it would be nice to have the option of displaying a larger image should the viewer want. I used the standard getURL first to load a big pic in a seperate window, but thought this looked a bit naff, so i turned to a java pop up window.

    My questions is, i have about 36 pictures on the site. each picture has a button to load the pop up
    Code:
    on (release) {
    	getURL("JavaScript:popup();");
    }
    and then this is attached to the html page
    HTML Code:
    <SCRIPT LANGUAGE="JavaScript">
    function popup() {
    window.open('pic1.swf','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=800,height=600,left=50,top=50');
    }
    </script>
    my site is all in flash so there is only one html page. All i would like to know is if there is a simpler way of loading these pop ups than having 36 of these tags in the html page code? and if there is not, will alll this extra data affect loading time? ( as you can tell i am not good with java )

    any advice would be gratefully recieved

    Ryan
    Last edited by ryantsi; 09-16-2005 at 09:04 PM.

  2. #2
    Senior Member
    Join Date
    Oct 2004
    Location
    Rio de Janeiro, Brazil
    Posts
    344
    First of all, you have not a "Java" popup, but a "Javascript" popup.

    Well, why instead to call an html with 36 different Javascript fragments, you call a PHP script that dinamically generates the proper HTML?

  3. #3
    Senior Member ryantsi's Avatar
    Join Date
    Sep 2005
    Location
    Exeter, Devon
    Posts
    288
    I did not know that it was an unsaid rule on these boards not to use an abreveation for something, especially when it is quite clear what i am talking about. As far as php goes, i do not know too much about php

    Thanks Ryan

  4. #4
    up to my .as in code Chris_Seahorn's Avatar
    Join Date
    Dec 2004
    Posts
    4,389
    Yeah...thats pretty nutty. Are these images hard coded (inside the swf) or loaded dynamically (as an array maybe?).

    Anyway...I'll post a solution and you figure out how to push the image name and dimensions to the code on the fly (which is preferred with dynamically loaded or differing images). This requires no html code and is fired from flash itself.

    on (release) {
    getURL("javascript:window.open('http://sandbox.serveftp.org/somefrigginpicture.jpg,'newWin','width=310,height= 310');void(0);");
    }

    Just like the example shows...this will open "somefrigginpicture.jpg" in a 310 x 310 window.

  5. #5
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    There are several different techniques for initiating javascript pop up windows from a Flash movie. The method you posted works, but as your experiencing, it takes alot of code when using numerous objects. You could put all your object names in an array and use a for loop to apply the name to the pop up function. Here is a brief overview of a couple of the standard uses......

    Standard JS pop up code used with the getURL method directly on an object...
    code:

    on (release) {
    getURL ("javascript:NewWindow=window.open('http://ntdesigns.net','newWin','width=400,height=300,left =200,top=200,toolbar=No,location=No,scrollbars=Yes ,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);");
    }



    Another method is to write a function to handle the pop up and pass the info to the function as parameters.......
    code:

    function launchNewWin(url,wdth,hdth,windowNewName){
    if(windowNewName==undefined){
    var windowNewName="newWin";
    }
    getURL
    ("javascript:window.open(\""+url+"\",\""+windowNew Name+"\",\"width="+wdth+",heig
    ht="+hdth+",top=\"+((screen.availHeight/2)-("+hdth/2+"))+\",left=\"+((screen.ava
    ilWidth/2)-("+wdth/2+"))); void(0);");
    }


    Just declare it on frame1 of your flash movie and when ever you want to launch a
    new window, just write

    _level0.launchNewWin("myUrl.htm", 550,400,"myNewWindow");

    or

    _root.launchNewWin("myMovie.swf",800,600,"myNewWin dow");

    That's it, a new javascript window will pop up to your defined size. You can
    of course change those numbers to whatever you want. To add to the charm, the
    window will always be centered on the screen of the user regardless of
    resolution. The last argument, windowNewName is optional and will default to
    newWin, if not defined, hence you can call this function like this also:

    _level0.launchNewWin("myImage.jpg",300,500);

    You don't need any other declarations of javascript in html or any where else..
    Just drop this function and launch as many new windows from Flash..as you want.
    Works just like getURL, except, wants the url and size of the window to launch.

    Regards
    NTD

  6. #6
    Senior Member ryantsi's Avatar
    Join Date
    Sep 2005
    Location
    Exeter, Devon
    Posts
    288

    Thanks alot guys

    thanks alot for the post chris, unfortunatly it did not work, i got a page with a yellow triangle and ! on the bottom left of my browser ??

    NTD your solutions works great, although i am about to go out and havent resized the window or changed link but will do that later, along with trying out the other method you described, this would be very usefull if the gallery expands.

    Thank you both very much for your advice on this subject

    Ryan

  7. #7
    3D Artists/Freelance Design
    Join Date
    Sep 2005
    Location
    San Francisco
    Posts
    8

    No target

    I've been having trouble implementing Chris's actionscript. My site doesn't need to use the advanced scripting of NTD, unless I can't figure out some other way to get this done.

    The problem I'm having is that when I use the code:

    on (release) {
    getURL("javascript:window.open('http://sandbox.serveftp.org/somefrigginpicture.jpg,'newWin','width=310,height= 310');void(0);");
    }


    I get 2 windows that pop up. I don't know if this has anything to do with the fact that I'm testing it out from Flash itself instead of Publishing the FLA, but 2 windows aer what I get. Also, the window that opens up doesn't take on the attributes I specify in the javascript itself! The target I set isn't used at all! Instead, in the address bar I get this :

    javascript:window.open('http://sandbox.serveftp.org/somefrigginpicture.jpg,'newWin','width=310,height= 310');void(0);

    So what do I do? If anyone could help me out with a super simple way to get this to work, please let me know :-)

    -not holding my breath, since no-one seems to actually answer my questions here.

    Geoff
    Last edited by DefGeoff256; 09-21-2005 at 09:54 PM. Reason: more info

  8. #8
    Senior Member ryantsi's Avatar
    Join Date
    Sep 2005
    Location
    Exeter, Devon
    Posts
    288

    first off

    are you taking out the sandbox.ftp and changing it to the link that you want to open? but if you look at ntds post, you only have to use the on release function, the other part is optional. I am just using the beginning part and it is working fine, i think there might be a syntax issue in chris`s script.

    Ryan

  9. #9
    3D Artists/Freelance Design
    Join Date
    Sep 2005
    Location
    San Francisco
    Posts
    8
    Quote Originally Posted by ryantsi
    are you taking out the sandbox.ftp and changing it to the link that you want to open? but if you look at ntds post, you only have to use the on release function, the other part is optional. I am just using the beginning part and it is working fine, i think there might be a syntax issue in chris`s script.

    Ryan
    I've made all the appropriate changes, and I'm still getting weird issues that I don't understand. Now, in addition to opening a blank window with the JavaScript in the Navigator bar I get the pop-up that I originally wanted. I've used NTDs code, Chris' code, ActionScript.org's code, tried to embed code in the HTML as well as the FLA and SWF. The only approach I may have to take is just go back to using the regular gerURL code without any specifications on windows size or anything...

    This is the code I'm using, modified from NTD's post:
    on (release) { getURL("javascript:NewWindow=window.open('http://www.nahashon.com/content/case.html','newWin','width=600,height=490,left=200 ,top=200,toolbar=No,location=No,scrollbars=Yes,sta tus=No,resizable=Yes,fullscreen=No'); NewWindow.focus();");

    I've checked it for errors, spaces, syntax errors, the works! Maybe one of you will have a better idea....?

    Geoff
    }

  10. #10
    3D Artists/Freelance Design
    Join Date
    Sep 2005
    Location
    San Francisco
    Posts
    8
    Anybody?!

  11. #11
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Test it in an online situation. Testing from Flash's author mode requires a browser to be opened to process the Javascript code, then opens a window. Testing online from a browser window will open up a single window.

  12. #12
    Senior Member
    Join Date
    Oct 2004
    Location
    Rio de Janeiro, Brazil
    Posts
    344
    Quote Originally Posted by ryantsi
    I did not know that it was an unsaid rule on these boards not to use an abreveation for something, especially when it is quite clear what i am talking about. As far as php goes, i do not know too much about php

    Thanks Ryan
    Hey, dude dont be upset!

    Someone already make me this kind of observation once, and it's good to help keeping the tech level ok.

    In fact there is not a rule. I just was showing you that you shouldnt use as "abreviation" a word that is the name of another language.
    By the way, to abreviate JavaScript, use JS and not Java as NTD did.

    Why write wrong when we can write right? Right???

  13. #13
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    By the way, to abreviate JavaScript, use JS and not Java as NTD did.Why write wrong when we can write right? Right???
    What are you talking about? Where did I abbreviate Javascript with Java?

  14. #14
    Senior Member
    Join Date
    Oct 2004
    Location
    Rio de Janeiro, Brazil
    Posts
    344
    Quote Originally Posted by NTD
    What are you talking about? Where did I abbreviate Javascript with Java?
    Hi, NTD!
    No, you get it wrong! - LOL

    Maybe I wrote my phrase wrong. Maybe I should write:
    "By the way, to abreviate JavaScript, use JS as NTD did and not Java."

    I think I was the victim of my own mousetrap, and failed to express myself correctly. A thousand excuses!!!

  15. #15
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    lol, no worries.

    I looked over the post and didn't see anywhere I had used Java in place of Javascript. I understand what you were trying to say now.

    Keep on Flashin

    Regards
    NTD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center