A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Can two swf-files work together?

  1. #1
    Member
    Join Date
    May 2001
    Posts
    37
    I'm trying to make two swf-files work togheter.

    The idea is to have to swf-files in the same htm-document.
    The first swf-file (let's call it swf1) is supposed to be a "navigation swf" with a couple of buttons.

    And the second swf-file (swf2) is supposed to be the "action swf" were the things should happened.

    Can I make this work? To be able to press a button i swf1 and make it play a specified frame in swf2..

    I have tried the tell target function but doesn't really get it to work...(well, don't get it to work!)

    I have heard this is possible to make two swf's work togheter, but how?

    I am quite new at flash so this might be a stupid or easy question? /Thankful for all help, daniel.

  2. #2
    This type of thing will require just a little bit of Javascript ... but it will likely all be contained inside your flash movie.

    One of the important things to mention is that you have to make sure that when you place your object and embed tags in the HTML page, you have to clearly identify the ID in the object tag and the NAME in the embed tag. The SWLiveConnect just also be set to true. There is an example around here somewhere.... hmmmmm.

    ok, this is from the Macromedia support site:
    Code:
    <OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
    CODEBASE="http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0"
    ID=navmovie WIDTH=100% HEIGHT=100%> 
    <PARAM NAME="movie" VALUE="navigation.swf"> 
    <PARAM NAME="play" VALUE="false"> 
    <PARAM NAME="quality" VALUE="high"> 
    <EMBED NAME=navmovie SRC=navigation.swf WIDTH=100% HEIGHT=100% PLAY=false
    SWLIVECONNECT=true QUALITY=high>
    </OBJECT>
    OK, so start with making sure that you have those attributes (see bold text) included in your HTML page. You can refer to the movie object as :

    window.document.navmovie.__________;

    and (you'd do well to read the pages behind this link http://www.macromedia.com/support/fl...ithflash.html) you need to include a method call after navmovie. So straight from JS, you might say:

    window.document.navmovie.play();

    or

    window.document.navmovie.setvariable(varname,value );

    From inside your Flash movie, you can use a getURL method to fireoff javascript.... and the url would be something like this:

    javascript:alert('Does this work?');

    In place of the alert, you can put something like:

    window.document.navmovie.setvariable("_root.age", 25);

    Hope this helps get you started. Ask more questions as you get into it.

  3. #3
    Member
    Join Date
    May 2001
    Posts
    37
    Hi Mikebrittain!

    I will try this..

    I'll keep in touch during progress... but first lunch..

    THANKS!


  4. #4
    Member
    Join Date
    May 2001
    Posts
    37
    Howdy Mike!

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="307" height="319" ID=navmovie>
    <param name="movie" value="synctest.swf">
    <param name="quality" value="best">
    <param name="play" value="false">
    <embed name=navmovie src="synctest.swf" type="application/x-shockwave-flash" width="307" height="319" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" SWLIVECONNECT=true quality="best" play="false">
    </object>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="307" height="319" ID=testmovie>
    <param name="movie" value="test.swf">
    <param name="quality" value="best">
    <param name="play" value="false">
    <embed name=testmovie src="test.swf" type="application/x-shockwave-flash" width="307" height="319" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" quality="best" play="false">
    </object>

    This is how my OBJECT code looks like within my BODY.

    The first object is the movie I want to be the "navigation movie" and the second the "action movie" (where the stuff should take place).

    This far I'm with you.. (if the code looks alright) but regarding the javascript, am I supposed to insert the strings you added into Flash or into my HEAD tag? I didn't quite get that.
    (I'm no javascript programmer but I can understand and work with it... but write it.. no, no. ;) )

    I haven't looked up your url yet but I will do so.

    .daniel
    [Edited by rmr_daniel on 05-16-2001 at 09:09 AM]

  5. #5
    Member
    Join Date
    May 2001
    Posts
    37

    Smile

    YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEES!!!!!!!!!

    IT WORKS!

    Thanks Mike! I had to work on it for a while but now it's runnin' smooth!

  6. #6
    nice. Good to hear that!

  7. #7
    Junior Member
    Join Date
    Aug 2000
    Posts
    28

    but does it work in Mac/IE

    i've been doin something similar with the same approach. it works in IE and Netscape on PCs, and it works on Netscape on Mac's, but it doesn't seem to work on Mac IE.

    I've heard that liveconnect does not work on Mac/IE. Have you guys had any luck with this. Is there any way around it?

    Thanks,
    Doug

  8. #8
    Member
    Join Date
    May 2001
    Posts
    37

    Re: but does it work in Mac/IE

    I don't know about IE on Mac..

    To be true, I'm still working on the problem above. The liveconnect works but not in the way I want it to. Sucks!

    /daniel

  9. #9
    Member
    Join Date
    May 2001
    Posts
    37

    Lightbulb Still working on my problem... question in top of page.

    Hello all flashers!

    I'm still working on my problem with communicating between two swf's...

    in swf1 (who I want to controll swf2) I have used the

    getURL ("javascript:window.document.navmovie.play();") ;

    On a button... this makes the swf1 talk to swf2 but I can't make it go to a certain frame in a certain scene.

    To make it more easy for me I have now made the swf2 in a different way than before..so all i need now is to be able to tell swf2 to go to frame 1 in the scene it's in.

    Should i use Active X? If yes how should I use it?

    Desperate for a solution, daniel.

  10. #10
    Junior Member
    Join Date
    Aug 2000
    Posts
    28
    the only way i've been able to do this successfully is by setting a variable in one swf through javascript. as far as i can tell only certain functions work via javascript to flash - this has worked for me;


    <script language="javascript" type="text/javascript">
    function setFlashVar() {
    document.movieIDNamme.SetVariable("varname", "value");
    }
    </script>

    then in your first flash movie,
    getURL ("javascript:setFlashVar()");


    then in the target movie, set up a framescript or enter frame script to check the value of the variable (which will be set in the _root), and then act accordingly.

    good luck
    - doug

  11. #11
    Member
    Join Date
    May 2001
    Posts
    37
    Thanks Doug!

    I will try this.. I'll keep in touch during progress.. might take a wile, quite new to flash but I think I'll be figuring it out.

    /Daniel

  12. #12
    Junior Member
    Join Date
    Apr 2001
    Posts
    20
    Hate to rain on y'all's parade BUT...

    Communication between browser and flash (or any plugin for that matter) is NOT possible on the following platform/browser combos:

    Mac/IE (all versions of IE)
    Netscape 6.01 (both platforms, should be corrected in future versions of Nav 6)

    Keep this in mind when you're using this technology and make sure these exclusions are appropriate to your project.

  13. #13
    Originally posted by visualnoise
    as far as i can tell only certain functions work via javascript to flash
    Doug -- I don't know if you are aware of the listing of methods that can be used from Javascript to Flash (what you would need for communicating between two SWFs). There is a complete listing on Macromedia's support site:

    http://www.macromedia.com/support/fl...hflash_03.html

    mike

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