A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: LoadVars popup window function

  1. #1
    Hi, i'm having big problems with LoadVars. Specifically, getting a custom onLoad function of my loadVars object to successfully pop up a new browser window and load a page into it.

    What i'm trying to do is to open a popup window (new browser window) triggered by a button in flash. After the trigger button is clicked (within the swf), but before the popup opens, I need to load some variables.

    I've created a LoadVars object (called 'c'), which loads the variables from a php script. I've created an onLoad function for my object, which calls the javascript (embedded in the head of the html page holding the swf) which in turn, opens the popup window.

    The problem is, when i call the javascript from the object onLoad function, i get this error message in the browser..

    '"The attempt to load 'Accessing URL: http://burst-tv.net/picviewer/nonphp.html' failed"
    ('nonphp.html' is the page that should open in the popup window)

    But when i place the popup function call directly on the button within the movie, the popup page loads fine (and it works fine if i enter the url directly into the browser too)

    Does anyone know what's going on here? ive been trying to figure this out for a long time, any help would be greatly appreciated!

    _root, frame one AS..

    _________

    _root.c = new LoadVars();
    _root.c.onLoad=function() {
    var tempstring="java script:popup();";
    getURL(tempstring);
    }
    function popup(picurl){
    _root.c.passedpic=picurl;
    _root.c.sendAndLoad("http://www.burst-tv.net/picsizereporter.php",_root.c,"POST");
    }

    ______

    AS attached to button on frame one..
    ______

    on (release) {
    _root.popup();
    }

    ______

    And here's the javascript function in the head section of the page holding the swf..
    _______

    function popup(){
    window.open('picviewer/nonphp.html');
    }






  2. #2
    Junior Member
    Join Date
    Sep 2002
    Location
    Richardson, TX
    Posts
    27

    Thoughts

    I've recently reacquainted myself with Flash, so I'm no expert, but I think I see your problem..

    sendAndLoad posts a variable value to your .php page, and then returns the response back to your _root.c page. I am pretty sure you can't get the response to pop up into a new page.

    If you're looking for a new page to open up, try:

    Code:
    passedpic=picurl;
    loadVarNum("http://www.burst-tv.net/picsizereporter.php", "_blank", "POST")
    Any active variables that have been declared/defined will be sent via the POST.. Usually that's not a problem. If it is, you can use the delete function to get rid of variables after functions/events where they're used...

    This may or may not be the answer you're looking for, but it just might work - I hope it does!

  3. #3
    Junior Member
    Join Date
    Sep 2002
    Location
    Richardson, TX
    Posts
    27

    Correction

    I think I crossed my Actionscript a little.. you want getURL..

    Code:
    function popup(picurl) {
    passedpic=picurl;
    getURL("http://www.burst-tv.net/picsizereporter.php", "_blank", "POST");
    }
    loadVarNum isn't gonna do it for ya I don't think, but this one should..


  4. #4

    Re: Correction

    Thanks for your reply Rollins, but i'm already using getURL to access a javascript that does tha actual 'popping up'.

    My problem is that when i access this popup script from within my custom onLoad function ('onLoad' of the 'c' object), the page i specify fails to load within the popup window.

    My problem seems to be to do with calling the javascript from within the onLoad function since i can get the popup to work fine if i put the getURL command anywhere else in my script.


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