A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Loading External SWF

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    5

    Loading External SWF

    I'm using Flash CS4 and AS2. I have an external swf that works fine, but when I try to load it into another swf part of it doesn't work. The swf that's loading it is in the exact same directory so it's not missing any files. It's a little hard to explain, and would probably be easier if you could see it, however, even zipped the file is rather larger at 23 mb, so I can't attach it.

  2. #2
    Senior Member
    Join Date
    Jul 2001
    Location
    San Jose California
    Posts
    144
    roger, the swf is 23mb?

    without actually seeing the file one of the first things that come to mind is the file you are loading probably has actionscript that includes "_root" Is this the case?

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    5
    Hi bgregus. No, the swf isn't that big, but it uses an images folder which bulks up the size. I could attach just the .swf but it wouldn't really function. As for the actionscript, yes, it does include "_root". Is this a problem?

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Location
    San Jose California
    Posts
    144
    Roger,

    What I think is happening is your external swf (lets call that swf A) has code pointing to it's _root but once you load swf A into swf B all those _root references now point to the _root of swf B.

    You might go through the swf you are loading up and remove all references to _root and instead use relative paths.

    OR if you don't want to figure out all the relative paths

    Say in swf B you are loading swf A into a movieClip called "holder_mc". Find all uses of _root in swf A and insert the holder_mc into the path "_root.holder_mc.whatever"

    does that make sense?

  5. #5
    Junior Member
    Join Date
    Oct 2009
    Posts
    5
    That worked! Thank you so much; you're a lifesaver. So glad I'll know this from now on

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Location
    San Jose California
    Posts
    144
    excellent!

  7. #7
    Junior Member
    Join Date
    Oct 2009
    Posts
    13
    Hi guys is it possible to load an external swf with a parameter which the external swf needs to operate?

  8. #8
    Senior Member
    Join Date
    Jul 2001
    Location
    San Jose California
    Posts
    144
    jonis - you could use the same _root trickery to set a variable in the file that is doing the loading. Then the loaded swf could look for the variable at _root. AKA

    PHP Code:
    if(_root.userChoice == 1){
    // play movie 1 code
    } else {
    // play movie 2 code

    I'm not sure if that is what you are talking about though.

  9. #9
    Junior Member
    Join Date
    Oct 2009
    Posts
    13
    i want to use on the parent swf something like

    PHP Code:
    ContainerClip.loadMovie("external.swf"my_variable); 
    or
    PHP Code:
    ContainerClip.loadMovie("external.swf?my_variable=" my_variable); 
    and each time pass a different "my_variable"

    Will the second solution work?Do i have to "GET" somehow the my_variable in the code of the external.swf?

  10. #10
    Senior Member
    Join Date
    Jul 2001
    Location
    San Jose California
    Posts
    144
    jonis - Gotcha, I haven't tried doing it like that.

    Usually I just set the "my_variable" in the parent file and then have the external swf look for "my_variable" on init or whatever function. Might want to start a new thread to see if someone more experienced has any input on an alternate way to pass directly into the swf.

    - B

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