SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist spoondevil's Avatar
    Join Date
    Jun 2001
    Location
    Harlow, Essex, UK
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Opening a Resized Window from Flash

    Hi there.

    I am trying to open a window from a link in Flash, the window has to be resized and with no menu, address, scroll, bars etc etc.

    I know this can be done as I've seen other sites doing it. I presume it'd have to be done through the "expert" actions, but I can find no info on it anywhere.

    Any ideas?!?

    In case you are interested, the link will be to open a full size image from a thumbnail. Would it even be possible to create a page such as /images.php?image=*** and have the window auto resize to the image loaded into the dynamic page and also lose the additional elements to the window?


    Many Thanks
    GŁnter

  2. #2
    SitePoint Evangelist spoondevil's Avatar
    Join Date
    Jun 2001
    Location
    Harlow, Essex, UK
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After a bit of playing about, I have come up with the following solution.

    In my page that holds the .swf file, I have added the following to the head tag:

    Code:
    <script>
    // Set the horizontal and vertical position for the popup
    PositionX = 100;
    PositionY = 100;
    // Set these value approximately 20 pixels greater than the
    // size of the largest image to be used (needed for Netscape)
    defaultWidth  = 500;
    defaultHeight = 500;
    // Set autoclose true to have the window close automatically
    // Set autoclose false to allow multiple popup windows
    var AutoClose = true;
    // Do not edit below this line...
    // ================================
    if (parseInt(navigator.appVersion.charAt(0))>=4){
    var isNN=(navigator.appName=="Netscape")?1:0;
    var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
    var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
    var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
    function popImage(imageURL,imageTitle){
    if (isNN){imgWin=window.open('about:blank','',optNN);}
    if (isIE){imgWin=window.open('about:blank','',optIE);}
    with (imgWin.document){
    writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
    writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
    writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
    writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
    writeln('width=100-(document.body.clientWidth-document.images[0].width);');
    writeln('height=100-(document.body.clientHeight-document.images[0].height);');
    writeln('window.resizeTo(width,height);}');writeln('if (isNN){');	   
    writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
    writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
    if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
    else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
    writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
    close();  
    }}
    </script>
    Then for each thumbnail image, I have given it the following action:
    Code:
    on (release) {
     getURL("javascript:popImage('/images/***.jpg','Titile of Image')");
    }
    Hope this helps someone else out as well If anyone knows how I can adapt this code so the popup is auto-centered, it'd make me very happy!


    GŁnter

  3. #3
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Good One there spoondevil!!

    Quote Originally Posted by spoondevil
    If anyone knows how I can adapt this code so the popup is auto-centered, it'd make me very happy!
    Ok, lets make you happy With the height & width both 500(as specified in your code above) I'd say that change the PositionX to 150 & PositionY to 50. This would center the pop-up on screen.
    Now, are you happy?
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  4. #4
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Or to be size independent, put the following.

    Code:
    PositionX = (screen.width) ? (screen.width-defaultWidth)/2 : 0;
    PositionY = (screen.height) ? (screen.height-defaultHeight)/2 : 0;
    Here defaultHeight is the height of the pop-up & defaultWidth is the width of pop-up.
    Now you can specify whatever size you want of the pop-up. The pop-up will remain centered.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  5. #5
    SitePoint Member
    Join Date
    Feb 2004
    Location
    France
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Open Browser Window

    Attach this to your button in Flash in the actionscript window

    on (release) {
    if (jsCommOK == "OK") {
    fscommand ("newwindow", "content.html");
    } else {
    getURL ("content.html", "_blank");
    }
    }

    Go to the html page (in this example its "content.html" see above) you want the button to open and place this in the scripting area:

    if (command == "newwindow") {
    window.open(args,"","width=320,height=240,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
    }

    I have not had success myself, but it may be my platform (Mac). Try it and let me know if it works please.

  6. #6
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vsaumarez
    Attach this to your button in Flash in the actionscript window

    on (release) {
    if (jsCommOK == "OK") {
    fscommand ("newwindow", "content.html");
    } else {
    getURL ("content.html", "_blank");
    }
    }

    Go to the html page (in this example its "content.html" see above) you want the button to open and place this in the scripting area:

    if (command == "newwindow") {
    window.open(args,"","width=320,height=240,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
    }

    I have not had success myself, but it may be my platform (Mac). Try it and let me know if it works please.
    Won't work b'coz instead of specifying url, you've put the variable args, & where's that defined? & what's jsCommOK?

    I think that the script is faulty. Why not check it on & paste the correct script. Also, it'd be better if you put your code between [_code] & [/code_] tags. Just remove the underscores from the tags.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  7. #7
    SitePoint Member
    Join Date
    Feb 2004
    Location
    France
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Open Window

    You may be right. I copied and pasted the script from Gary Rosenzweig's Flash MX ActionScript book. I failed to mention that you should select FSCommand as the template in publish settings. I also read last night in the preceeding chapter that Actionscript and javascript make an unhappy menage a trois with Macs. This may explain some of the code which for browsers that don't see the code, but yet will open the window, albeit without the specified size. My experience bears this out.


Bookmarks

Posting Permissions

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