A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Can a swf find out the URL of the HTML page it is embedded in?

  1. #1
    Flasher
    Join Date
    Nov 2002
    Posts
    171

    Can a swf find out the URL of the HTML page it is embedded in?

    So yeah, what the title says really. I have a flash movie that is going to be on many pages, but must behave differently depending on which page it is embeded in. Is there some way that flash can know what page it is on? I understand how to do this with javascript but was wondering if there was a neater way?

    Cheers chaps

    Rich

  2. #2
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    I know you can get the domain via the localconnection, but I don't know of a way to get the subdirectories.

    var my_lc:LocalConnection = new LocalConnection();
    myDomain = my_lc.domain();

  3. #3
    Senior Member random25's Avatar
    Join Date
    Apr 2002
    Posts
    566
    I have a site set up that knows what the url in the address bar is,
    http://www.covingtonscyclecity.com/flash.asp?scene=Home
    http://www.covingtonscyclecity.com/f...subscene=Pipes
    http://www.covingtonscyclecity.com/f...DL&goto=Smooth

    It uses java script to pass the url info to flash, the flash has to be embeded into an asp page.

    Flash.asp:
    Code:
    <%@Language="JScript"%><%
    	Response.Buffer = true; Response.Expires = -1441;
    	var s = new String(Request.Querystring("scene"));	
    	var ss = new String(Request.Querystring("subscene"));	
    	var gt = new String(Request.Querystring("goto"));	
    	strScene = (s!='undefined'&&s!='')?s:'';
    	strSubScene = (ss!='undefined'&&ss!='')?ss:'';
    	strGoTo = (gt!='undefined'&&gt!='')?gt:'';
    	
    %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
    
    <HTML>
    <HEAD>
    
    <link rel="alternate" type="application/rss+xml" title="Covingtons Customs RSS" href="http://www.covingtonscyclecity.com/rss.xml?author=Covingtons Customs" />
    
    <META NAME="ROBOTS" CONTENT="NOINDEX,NOFOLLOW">
    <meta http-equiv="Pragma" content="no-cache"> 
    <meta http-equiv="Cache-Control" content="no-cache"> 
    <TITLE>Welcome to Covington's Cycle City! The Ultimate in Custom Cycles</TITLE>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD>
    <body bgcolor="#000000" LEFTMARGIN=0 TOPMARGIN=0 RIGHTMARGIN=0 MARGINWIDTH=0  MARGINHEIGHT=0>
    
    <script language="JavaScript">
    <!--
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'
    +' width="100%" height="620" id="flash_embed_id" align="middle" scale="noscale"> '
    +' <PARAM NAME=movie VALUE="movie2.swf?date='+ new Date().getTime()+ '&scene=<%= strScene %>&subscene=<%= strSubScene %>&goto=<%= strGoTo %>"> '
    +' <PARAM NAME=loop VALUE=false>'
    +' <PARAM NAME=menu VALUE=false> '
    +'<PARAM NAME=quality VALUE=high> '
    +' <PARAM NAME=bgcolor VALUE=#000000> '
    +' <PARAM NAME=scale VALUE=noscale> '
    +' <EMBED src="movie2.swf?date='+ new Date().getTime()+ '&scene=<%= strScene %>&subscene=<%= strSubScene %>&goto=<%= strGoTo %>" quality="high" menu="false" bgcolor="#000000" '
    +' width="100%" height="620" scale="noscale" name="holder" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"' 
    +' PLUGINSPAGE="https://www.macromedia.com/go/getflashplayer">'
    +' </EMBED></OBJECT>');
    //-->
    </script>
    
    </BODY>
    </HTML>

    Im sure it could be done with php also, but i havent tried it.
    Last edited by random25; 03-01-2006 at 12:48 PM.

    If you want to make an apple pie from scratch, you must first create the universe. Carl Sagan

  4. #4
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    Just found this myself.. There is a '_url' property of a movieClip..

    myDomain = this._url

    But it doesn't give the name of the HTML file..
    Last edited by DallasNYC; 03-01-2006 at 12:57 PM.

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