A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Linking two swf's together

  1. #1
    Junior Member
    Join Date
    Apr 2007
    Posts
    26

    resolved Linking two swf's together

    Hey, im wanting to link two swf files together but cant seem to get the code to work out correctly. I've created a button and a function that i want the code to go in to, so that once the button has been clicked it loads the second swf file. I've tried numerous things, such as getURL, loadMovie etc etc but it just doesn't seem to want to work.


    if anyone can give any help, that'd be great
    Last edited by derbys; 12-03-2009 at 01:03 PM.

  2. #2
    Member
    Join Date
    Sep 2008
    Posts
    80
    not sure if this is what u want.

    i've attached a simple flv sample

    it willl load an external movieclip, when you click the button it load the second movieclip

    just change the path of the moviclips in the flv.

    let me know if you have questions
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Apr 2007
    Posts
    26
    Hmmm cant seem to open the file, says its an invalid file type? im using CS3 btw.

  4. #4
    Member
    Join Date
    Sep 2008
    Posts
    80
    oh man .i'm using cs4

    well...it's kinda simple,

    to load a external movieclip ,

    first make a loader
    var swfLoader:Loader = new Loader;//create a loader object IMPORTANT
    var anim:URLRequest = new URLRequest("yourmovieclip.swf");//find the swf

    swfLoader.load(anim); //insert the location of the anim in the Loader
    swfLoader.y=control the y position of the swf
    swfLoader.x = control the x position of the swf

    stage.addChild(swfLoader);//add the Loader to the stage in your flash


    now to load a second movieclip when you click the button
    the even listener for the button

    my_button_name.addEventListener(MouseEvent.CLICK, loadSecond);

    function loadSecond(evt:MouseEvent):void
    {
    just do the same thing, but make new variables since the other one is being use

    var swfLoader2:Loader = new Loader;//create a loader object IMPORTANT
    var anim2:URLRequest = new URLRequest("yourmovieclip.swf");//find the swf

    swfLoader2.load(anim); //insert the location of the anim in the Loader
    swfLoader2.y=control the y position of the swf
    swfLoader2.x = control the x position of the swf

    stage.addChild(swfLoader2);//add the Loader to the stage in your flash

    }


    important
    make sure you write the write path for the swf
    control x and y position in a way that you can see it, sometime if it runs and it doesn't show the swf it's becuz of the x and y position you can use a ruler in the view option to help you


    that's it

  5. #5
    Junior Member
    Join Date
    Apr 2007
    Posts
    26
    ah thanks a bunch!

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