A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: communicating between 2 swfs

  1. #1
    Senior Member
    Join Date
    May 2005
    Location
    Canada
    Posts
    212

    communicating between 2 swfs

    if i have been trying to get my lastest project to work all weekend with no luck. what im trying to do is when u click a button on one swf it goes to another swf and plays a desired label such as "about". I was wondering if you guys can help me narrow the problem down to see if its in the recieving html and swf or the sending html or swf

    my first question is; is this the right output (what appears in the brower's address bar) the button should b giving if its suppose to go to a new swf and play "about" this is what im recieving html looks like
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <script language="javascript">
    <!--remove the question mark from search info-->
    var i = document.location.search;
    cnt = 1;
    var exp = "";
    if(i==""){}else{
    while(exp.length<i.length-1){
    exp=exp + i.charAt(cnt);
    cnt = cnt + 1;
    }
    }
    </script>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>main</title>
    <style type="text/css">
    <!--
    body {
    height: 100%;
    width: 100%;
    margin: 0;
    }
    -->
    </style>
    </head>
    <body bgcolor="#ffffff">
    <!--url's used in the movie-->
    <!--text used in the movie-->
    <!--
    First Name Last Name Email Tel Number Comments -->
    <!-- saved from url=(0013)about:internet -->
    <a href="http://216.147.53.243/main.html?frameName=mark"></a>
    <a href="http://216.147.53.243/main.html?frameName=info"></a>
    <a href="http://216.147.53.243/main.html?frameName=contact"></a>
    <a href="http://216.147.53.243/main.html?frameName=links"></a>
    <a href="http://216.147.53.243/main.html?frameName=about"></a>
    <script language="JavaScript">document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'+'width=100% height=100% id=main align=middle><param name="allowScriptAccess" value="sameDomain" /><param name=movie value="main.swf" /><param name="quality" value="high" /><param name="flashvars" value="' + exp + '" /><param name="scale" value="default" /><param name="bgcolor" value="#ffffff" /><embed src="main.swf" quality=high scale=default bgcolor=#ffffff width=100% height=100% name=main align=middle allowScriptAccess=sameDomain '+'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
    </script>
    </body>
    </html>

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Passing variables trough the url is a valid solution.
    The easiest way to pass the variable from the url into Flash is using SWFObject.
    Here's more info.

    Something like:
    Code:
    <script type="text/javascript">
       var so = new SWFObject("main.swf", "mymovie", "100%", "100%", "7", "#FFFFFF");
       so.addVariable("frameName", getQueryParamValue("frameName"));
       so.write("flashcontent");
    </script>
    Now, in Flash, you have a varible frameName in the main timeline, which you can use like this:
    code:

    gotoAndStop(frameName);




    Your logic is correct, it's the same as this. But I don't know if your code is, and is far too complicate.

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    if I not misreading this (' and " next to each other are hard to read) you are omitting a few whitespace from the object tag. Try to avoid that '+' thing altogether

    Musicman

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