www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 10-22-2009, 12:00 PM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    problem w/ simple script coming from Flash

    Hi all,
    I am using a javascript to open a new centered "pop-up"-window from Flash. It's simple and I haven't needed to use it for a long time. Now it doesn't work in Explorer (8). I have tried two different scripts actually, both originally coming from forums.
    It works fine in Safari, Firefox and Opera for MAC. It also works in Google Chrome on PC (haven't had a chance to try in Firefox/PC yet). In Explorer I get an: "Error in page" message in the status-field and when making an error-search in the webdeveloper tool, it displays "non-guilty argument" for this line:
    Code:
    win = window.open(page,winName,config);
    I also made a php-page with the same script and a text-based link. Then the pop-up window opens like it should..

    Here is the code on the button in Flash:
    Code:
    openPopupBUTTON.onRelease = function() {
        getURL ("javascript:newWin('popupwindow.php','popupname','620','361','0','0')"); 
    }
    and in the php-page holding the swf:
    Code:
    <script language="JavaScript" type="text/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>
    The swf is version CS3 published as Flashplayer 9.

    Is there anyone that can help?
    Reply With Quote
      #2  
    Old 10-23-2009, 05:39 AM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Help!

    No one out there that knows what doesn't work?
    The info I get from the status bar error message is this:
    Message: Invalid argument.
    Line: 32
    Char: 1
    Code: 0
    URl: http//:the-url-to-the-phpdocument

    Line 32 is this one:
    Code:
    config = 'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+''
    OR does any one have a better idea of what to do instead?
    Reply With Quote
      #3  
    Old 10-23-2009, 04:48 PM
    mitya mitya is offline
    Registered User
     
    Join Date: Oct 2003
    Location: Nottingham
    Posts: 666
    A couple of points:

    1) Get into the habit of declaring vars in the scope you need them. All your vars are global. Put 'var' before each.

    2) Terminate commands with semi-colons.

    3) Why do you implicitely add an empty string at the end of your command line? (...resizable+'')

    4) I seem to recall an issue in IE with setting up command strings for pop-up windows rather than implicitely passing the individual parameters in the function invocation. Try that.
    Reply With Quote
      #4  
    Old 10-24-2009, 06:50 AM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Thank you for answering!
    I am basically a complete idiot when it comes to javascript. Can read it when it ressembles actionscript . And I have a hard time understanding your last point, possibly also because my understanding of English isn't perfect.

    I did add the semi-colons and have added var to the vars..
    As far as I understand, the empty strings are there to receive the variables from the getURL action coming from Flash.
    Code:
    openPopupBUTTON.onRelease = function() {
        getURL ("javascript:newWin('popupwindow.php','popupname','620','361','0','0')"); 
    }
    How should I change them? Since it's a simple execution and I have all the variables at hand, could I simply put them into the javascript in the php-page instead? But what do I do with the getURL script? Don't I need to have them there?
    Reply With Quote
      #5  
    Old 10-24-2009, 06:57 AM
    mitya mitya is offline
    Registered User
     
    Join Date: Oct 2003
    Location: Nottingham
    Posts: 666
    Did you try passing the pop-up window arguments directly inside the function, instead of preparing it as a var string? i.e.

    Code:
    var win = window.open(page,winName,'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize);
    not

    Code:
    var config = 'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize;
    
    var win = window.open(page,winName,config);
    There are number of other options. Firstly, try opening the new window implicitely from within AS. So:

    Code:
    getURL("javascript:window.open(page,"mywin",'height=100,width=100,top=0,left=0,scrollbars=0,resizable=0');
    Else try simple invoking an arguments-less function from within AS, then build the window entirely in your JS, i.e.

    Code:
    getURL("javascript:myfunc();"...
    Reply With Quote
      #6  
    Old 10-24-2009, 07:02 AM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Thanks! Will try, just have to find someone with a PC.. considering it's Saturday and I seem to have chosen my personal network out of the existance of MAC in their homes.. not PCs
    Reply With Quote
      #7  
    Old 10-24-2009, 04:19 PM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Hi again..
    no nothing works as far as I have tried..
    It does work to evoke the javascript from the actionscript like this:
    Code:
    getURL("javascript:window.open(page,"mywin",'height=100,width=100,top=0,left=0,scrollbars=0,resizable=0');
    But then I don't get the centering of the window of course. I haven't event tried it on a PC since the centering is important.
    It works to skip the var config and call the arguments directly in win but that doesn't work in Explorer (Explorer in Windows XP on Mac, mind you..)
    Nothing else seems to work.

    The strange thing is, the last argument, resizable, seems to be badly written since it lacks both the closing single quote and a +-sign. But if I put them there the window doesn't open in Mac either..
    Code:
    var win = window.open(page,winName,'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize);
    shouldn't it be?
    Code:
    var win = window.open(page,winName,'height='+h+',width='+w+',top='+centerHeight+',left='+centerWidth+',scrollbars='+scrollb+',resizable='+resize+');
    Reply With Quote
      #8  
    Old 10-27-2009, 07:42 AM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13

    I think I am finally on the road with this one. Thanks for the help! I did this:
    Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function newWin() {
    var win=null;
    var centerWidth = (screen.width) ? (screen.width-620)/2 : 0;
    var centerHeight = (screen.height) ? (screen.height-362)/2 : 0;
    var win = window.open('mynewwindow.php','newwindow','height='+362+',width='+620+',top='+centerHeight+',left='+centerWidth+',scrollbars=0,resizable=0');
    }
    //-->
    </script>
    and only called the function from Flash:

    Code:
    button.onRelease = function() {
        getURL ("javascript:newWin()"); 
    }
    I have tested on two PCs/Explorer so far with a correct result.
    But, if anyone knows there is something wrong in the code, please alert me since I am so unknowing in Javascript.
    Reply With Quote
      #9  
    Old 11-03-2009, 09:52 AM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Unhappy

    I am now realizing that the script I wrote above doesn't work on all versions of Explorer. And strangely enough the failures are not consistent, i.e. it doesn't work on some computers with Windows XP with Explorer 8... On others it works..
    Is there anyone out there that knows wht's wrong? Or is there ANY way I can open a chromeless centered window directly from its own script so that I don't have to use a javascript in the swf-file??
    PLEASE HELP if possible..
    Reply With Quote
      #10  
    Old 11-03-2009, 10:05 AM
    criterion9 criterion9 is offline
    Registered User
     
    Join Date: Jan 2009
    Posts: 981
    Is there a particular reason you need a new browser window? Why not use a lightbox type effect with a div that you populate, center, and make visible as needed?
    Reply With Quote
      #11  
    Old 11-03-2009, 10:17 AM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Partly because it wouldn't fit the rest of the site.. It's a small showreel playing in the new window and it should look like Quicktime rather than anything else.

    What I should do really, is to make a flv instead and play it centered within the swf itself. Only, my client has bought a template I made quite a while ago and it's made with Actionscript 2.0. To use an flv I need to script in actionscript 3 which would mean a lot of changes to make for the site..

    The client doesn't want to compress the mv4-file enough either to put it into the existing swf.. He wants to keep it at 11mb which means I have to stream it.. it takes too much time to download entirely before playing.
    Reply With Quote
      #12  
    Old 11-03-2009, 01:20 PM
    criterion9 criterion9 is offline
    Registered User
     
    Join Date: Jan 2009
    Posts: 981
    You can use flv content in AS2. We do that all the time at work. You could just as easily make a div containing a quicktime like player that "appears" when needed. That way you wouldn't have to touch your existing template and could reuse the component later (in fact there are a number of components free or otherwise that play flv content in either AS2 or AS3).

    http://www.swinburne.edu.au/design/t...-Flash/ID-130/
    Reply With Quote
      #13  
    Old 11-03-2009, 02:59 PM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Thanks a bunch for the answer.
    I'll look into it in a little while.. However I haven't been able to publish anything with flv and AS2 combined..
    Reply With Quote
      #14  
    Old 11-03-2009, 03:03 PM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Hang on, making a div doesn't make a difference to me I think. I have an entire Flash site to work from, no html-content whatsoever (except the chromeless window and the window that holds the Flash-site). Which means the javascript is triggered from a button inside Flash. My problem is that I don't know how to trigger the chromeless centered window without using javascript inside Flash.. because then IE stops it. If I trigger it from a html-script in a php or html window it works fine. But maybe the answer is in the link you sent. Will look
    Reply With Quote
      #15  
    Old 11-03-2009, 04:00 PM
    javacessan javacessan is offline
    Registered User
     
    Join Date: Oct 2009
    Posts: 13
    Can't seem to get the video from the link working.. will try again tomorrow.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:09 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.