A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] Read current URL of current page into Flash

  1. #1
    Generous Newbie
    Join Date
    Apr 2002
    Location
    London, UK
    Posts
    147

    [RESOLVED] Read current URL of current page into Flash

    Third try:

    Flash 7 -

    Is there any way at all to read the current URL of the current browser page of a Swf ?

    I have 450 links from various places to a Single Page with a Single Swf on it. The Swf will take a ?arg from the URL path and then show the correct animation.

    Links to the page appear like these -

    mysite/mypage.htm?1234
    mysite/mypage.htm?1004
    mysite/mypage.htm?0034

    My Swf needs to know what the 4-digit number is when the page is opened in browsers.

    Note: Using Javascript to build the Embed/Object at runtime is not an acceptable solution in this case.

    Thanks
    Last edited by Donelson; 05-05-2006 at 03:30 AM.
    Regards, William Donelson
    Explore the Taj Mahal, India - online VR tour - http://www.taj-mahal.net

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    maybe use the .htaccess file to rewrite it into something flash can read, like ?number=xxxx

  3. #3
    Generous Newbie
    Join Date
    Apr 2002
    Location
    London, UK
    Posts
    147
    Wings Gaurav on Experts-Exchange
    http://www.experts-exchange.com/Web/..._21838980.html

    has suggested this, which I will try and report back here:

    getURL( "javascript:window.document.testSWF.SetVariabl e( 'strURL', document.location.href);" );
    Last edited by Donelson; 05-06-2006 at 06:37 AM.
    Regards, William Donelson
    Explore the Taj Mahal, India - online VR tour - http://www.taj-mahal.net

  4. #4
    Generous Newbie
    Join Date
    Apr 2002
    Location
    London, UK
    Posts
    147
    YES !


    Code:
    getURL( "javascript:window.document.testSWF.SetVariable(
        'strURL', document.location.href);" );


    Wings --

    Absolutely Brilliant ! Elegant, succinct, reliable! Five-Stars for this perfect solution!

    After spending 11 hours searching, begging, trying weird and sometimes awful solutions, this is truly EXCELLENT.

    All hail to the Expert Extraordinaire !


    http://www.experts-exchange.com/Web/..._21838978.html
    Last edited by Donelson; 05-05-2006 at 11:44 AM.
    Regards, William Donelson
    Explore the Taj Mahal, India - online VR tour - http://www.taj-mahal.net

  5. #5
    Generous Newbie
    Join Date
    Apr 2002
    Location
    London, UK
    Posts
    147
    ----------- TYPICAL USAGE ---------

    Code:
    stop();
    
    getURL("javascript:window.document.myMovieSwf.SetVariable(
             'pageURL', document.location.href);");
    
    intID = setInterval(this, "check_url", 250);
    
    function check_url() {
    	if (pageURL == undefined) return;
    	clearInterval(intID);      // Be sure to stop this when we've got an answer
    	theArgs = pageURL.split("?")[1];      // get second part of URL
    	if (theArgs.length > 0) {
    		// do whatever you want with the args
    	}
    }
    Regards, William Donelson
    Explore the Taj Mahal, India - online VR tour - http://www.taj-mahal.net

  6. #6
    Generous Newbie
    Join Date
    Apr 2002
    Location
    London, UK
    Posts
    147
    Here is a test page for communication between Flash and Javascript in different browsers and systems -

    http://www.permadi.com/tutorial/flashGetObject/



    I use Macintosh extensively and have found this information to add to the TEST table

    Macintosh OSX 10.4.x --

    Safari 2.0.3 - Movie plays once then stops for methods (1, 2, 3, and 5).
    No play for (4 & 6).

    FireFox 1.5.0.3 - Movie plays once then stops for methods (1, 2, 4 and 6).
    No play for 3, which gives dialog "movie object not found. No play for 5.

    Internet Explorer 5.2.3 (no longer supported by MicroSoft on Mac)
    No play for any test.

    Regards,
    William Donelson
    Regards, William Donelson
    Explore the Taj Mahal, India - online VR tour - http://www.taj-mahal.net

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