6 Replies Latest reply on Sep 19, 2006 5:46 PM by >>>S1n0Byt3}:>

    accessing variables and methods from a loaded external swf

    >>>S1n0Byt3}:>
      ok, I have been at this now for 2 days straight without success. I am using external swfs as a mean of customizing gui design. The default main swf is supposed to load the external swf, and manipulate the variables and methods. When I debug, it seems to show up on the stack that the variables are loading up from the external swf. but when I try to manipulate it on the maintimeline, such as _level0.active_comp.name_space_header = "hello", it comes up either as the original value set in the external swf or worse undefined. I have extensively searched, in tutorials, help guide, search engines, and nothing points in the right direction, only that it should work, not that it does work.


      simply put, in the external compiled swf, I set an empty text box, give it the instance name "name_space".
      on the default swf main timeline, I perform a simple createEmptyMovieClip/loadmovie operation,
      then on the second frame, i enter a custom text to be put into the externally loaded clip, in the form of _level0.active_comp.name_space_header = "hello"; and that's it, nothing. I can't even access the variables on
      any given point of the default timline. HHHEEEELLP.!!! Arrrrrgh
        • 1. Re: accessing variables and methods from a loaded external swf
          Steven_Lyons
          Probably the external .swf isn't loaded at the moment you are setting the var. You have to check for the file to be loaded before doing anything else (like moving down the timeline and triggering other actions). Are you using MovieClipLoader to load the .swf's? If so, then you already have an easy way to check when the load is done. If you are using loadMovie, then it's a bit more difficult. I'd suggest reading up on MovieClipLoader:
          http://www.actionscript.org/tutorials/intermediate/MovieClipLoader_in_Flash_MX_2004/index. shtml
          • 2. Re: accessing variables and methods from a loaded external swf
            skalamichal
            Hi,

            you wrote here about the MovieClipLoader class, because with the loadMovie it's a bit more difficult.
            I need use loadMovieNum method to load an external movie (I need use only as1.0). But when this movie is then run in fp8, there are a security restrcitions. So, I'm not able to check, if the movie is loaded or not.
            In fact, this is possible in Firefox, where I'm able to check the _frameloaded property. But when I try check this property in IE, the loaded movie will stop and I'm not able to run it again.

            Can you help me ?
            Michal
            • 3. Re: accessing variables and methods from a loaded external swf
              >>>S1n0Byt3}:> Level 1
              I figured as much. I remembered that Flash doesn't integrate automatically loaded external objects let alone swfs. I decided to be a little more patient about it. I will read the documentation now, and get back with results so the way others can benefit from it.
              • 4. accessing variables and methods from a loaded external swf
                >>>S1n0Byt3}:> Level 1


                Success. Well this does make me feel better. I did verbatum the example and applied it to the test, it worked like a charm.
                It did provide a level of understanding for me that flash doesn't inheirantly take in externals and apply it on demand without some type of preloader. That is just by default and a fact. Be it a permissions thing or not. It is just a fact. Anyone that has this issue, get used to it.
                • 5. Re: accessing variables and methods from a loaded external swf
                  >>>S1n0Byt3}:> Level 1
                  The Movieclip Object is only part of the answer, the real answer lies within the FPS of the main movie loading the external swf. The faster you set the time, the faster it completes the process of loading. So ideally, you want to set the main.swf at 120fps, which is the maximum, and any time contrained movies as an external process. Any external swf that carries only action script, inline should be set also to 120fps. You can create a custom Init() function to execute only when the criteria for bytes loaded has been achieved. This prevents a hickup in code and have a missed line process. Anyone who wants the sample code, please feel free to e-mail me at nrgfxmail@yahoo.com
                  • 6. Re: accessing variables and methods from a loaded external swf
                    >>>S1n0Byt3}:> Level 1
                    The Movieclip Object is only part of the answer, the real answer lies within the FPS of the main movie loading the external swf. The faster you set the time, the faster it completes the process of loading. So ideally, you want to set the main.swf at 120fps, which is the maximum, and any time contrained movies as an external process. Any external swf that carries only action script, inline should be set also to 120fps. You can create a custom Init() function to execute only when the criteria for bytes loaded has been achieved. This prevents a hickup in code and have a missed line process. Anyone who wants the sample code, please feel free to e-mail me at nrgfxmail@yahoo.com