# Testing if an external swf is already loaded

**URL:** <https://forum.kirupa.com/t/testing-if-an-external-swf-is-already-loaded/17071>\
**Category:** Uncategorized\
**Created:** [April 1, 2003, 2:38am UTC](https://forum.kirupa.com/t/testing-if-an-external-swf-is-already-loaded/17071 "2003-04-01T02:38:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ironikart](https://avatars.discourse-cdn.com/v4/letter/i/7feea3/32.png) [@ironikart](https://forum.kirupa.com/u/ironikart)\
**Post date:** [April 1, 2003, 2:38am UTC](https://forum.kirupa.com/t/testing-if-an-external-swf-is-already-loaded/17071/1 "2003-04-01T02:38:32Z")

</div>

Hi all,

I’m having a bit of trouble using a function that loads external swf’s into the main movie. The function works fine, but I want to expand it to test if a movie is already loaded. Here is the actions for the button that loads the movie:

on (release) {  
\_root.movieloader(“Image.swf”);  
}

and here is the function in the main timeline of the movie:

function movieloader(name){  
loadMovie(name, \_root.maincontent);  
} //where maincontent is the destination MC

Any ideas on how I can incorporate some sort test to see whether a movie has been loaded already? I want to avoid clicking on the button multiple times and having it reload each time.

Thanks in advance!🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 1, 2003, 4:42am UTC](https://forum.kirupa.com/t/testing-if-an-external-swf-is-already-loaded/17071/2 "2003-04-01T04:42:54Z")

</div>

This isn’t tested, but I believe this should work…

…make a boolean variable, set it to true when u load the movie, (and if u do have a button that lets the user close the swf, then don’t forget to change the variable to false when u unload the movie)…

good luck

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 1, 2003, 5:07am UTC](https://forum.kirupa.com/t/testing-if-an-external-swf-is-already-loaded/17071/3 "2003-04-01T05:07:50Z")

</div>

I see what your getting at. It would work if I had the button to unload because I could then set the boolean to false, but I don’t have that button. Basically its a menu that opens different menu items in the main screen, it wouldn’t really work well if I made the user unload each swf.

I’m going to try passing a variable to another function to test whether it is loaded before it gets to the load movie function… perhaps I can get around it that way. Any other suggestions are welcome.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 1, 2003, 5:18am UTC](https://forum.kirupa.com/t/testing-if-an-external-swf-is-already-loaded/17071/4 "2003-04-01T05:18:05Z")

</div>

hi,

add a small preload with your function

may be like

function movieloader(name){  
loadMovie(name, \_root.maincontent);  
movieLoaded=false  
while(movieLoaded==false){

```
     if(_root.maincontent.getBytesLoaded&gt;=_root.maincontent.getBytesTotal){
         movieLoaded=true
        
    }
    // here you can have a preloader also;

```

}  
}

there is one more way that is creat a loader object, the same way XMl works.

Movie=new loadMovie()  
// this way variable i have taried but movie not yet

Regards  
ajo  
[ajok@indiatimes.com](mailto:ajok@indiatimes.com)
