A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: passing parameter/variable from url to swf ?!

  1. #1
    Senior Member
    Join Date
    Aug 2007
    Posts
    121

    Question passing parameter/variable from url to swf ?!

    hey,
    i am trying to define a parameter/variable in my html file and pass it through to the embedded swf file:

    Code:
      <param name="movie" value="index.swf?wmode=transparent&amp;index=XXX">
    ...
      <embed src="index.swf?wmode=transparent&index=XXX" width="200" height="910" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" name="nav"></embed>
    is there any method to read a part or the whole url?
    e.g. www.website.com/XXX (oder www.website.com/#XXX)
    ..and then forwarding the XXX to the swf??
    index=XXX

    is something like that possible anyhow?

  2. #2
    Senior Member vinayak.kadam's Avatar
    Join Date
    Oct 2006
    Location
    gotoAndPlay("Pune");
    Posts
    831
    ExternelInterface class is something you wud be intrested of which allows you to communicate bilateral between Flash and JavaScript! Look at this link.
    As ever,
    Vinayak Kadam

  3. #3
    Banned
    Join Date
    Mar 2009
    Posts
    153

    Use javascript (FlashVars)

    www.yourwebsite.com?indexvariable=hello

    Code:
    <head>
    <script src="AC_RunActiveContent.js" language="javascript"></script>
    </head>
    <body>
    <script language="javascript">
    var urladdress=window.location.href;
    var myindex=urladdress.split("?indexvariable=")[1];
    
    AC_FL_RunContent(
    			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
    			'width', '200',
    			'height', '910',
    			'src', 'index',
    			'quality', 'high',
    			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
    			'align', 'middle',
    			'play', 'true',
    			'loop', 'true',
    			'scale', 'noscale',
    			'wmode', 'transparent',
    			'devicefont', 'false',
    			'FlashVars', 'swfindex='+myindex,
    			'id', 'index',
    			'bgcolor', '#000000',
    			'name', 'index',
    			'menu', 'true',
    			'allowFullScreen', 'false',
    			'allowScriptAccess','sameDomain',
    			'movie', 'index',
    			'salign', ''
    			);
    </script>
    </body>

    Write this AS code on the main timeline(frame)

    Code:
    var variableFromHtml=swfindex;
    trace(variableFromHtml);
    
    // output: hello

Tags for this Thread

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