# Importing SWF, layers and Actionscript mask question

**URL:** https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237
**Category:** flash
**Created:** [April 25, 2003, 4:58pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237 "2003-04-25T16:58:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Obelisk](https://avatars.discourse-cdn.com/v4/letter/o/f475e1/32.png) [@Obelisk](https://forum.kirupa.com/u/Obelisk)
#### Post date: [April 25, 2003, 4:58pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237/1 "2003-04-25T16:58:30Z")

</div>

Hi All,

I am trying to attach an animation I created in another swf. The movie attaches itself fine (see code sample 1). However an actionscrip mask I have used (please look at sample code 2) does not display at all. The animation works, but the mask (pre-built into the animation) is not working. Now I am pretty sure it has something to do with layers.

Any help would be appreciated.

// CODE SAMPLE 1

function createLoad()

{

```
        trace("attempting to load movie");

        this.attachMovie("loads", "loads_1", 1);

        loads_1._x = 60;

        loads_1._y = 340;

        trace("playing movie loading");

```

}

// CODE SAMPLE 2

onClipEvent (load) {

```
        _level_0.snowy.setmask(_root.hole);

```

}

Thanks,

Obelisk

---

<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 25, 2003, 5:00pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237/2 "2003-04-25T17:00:42Z")

</div>

Its not \_level\_0, its \_level0

And if that doesn’t work, just try \_root.

---

<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 25, 2003, 5:02pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237/3 "2003-04-25T17:02:04Z")

</div>

Oh, and why are you using attachMovie?

attachMovie is for pulling symbols out of the library. According to what you are saying, you are loading in an external .swf file.

That would use loadMovie(); or loadMovieNum();

---

<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 25, 2003, 5:05pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237/4 "2003-04-25T17:05:59Z")

</div>

Sorry i pasted the wrong function. Here is the correct function.

function createLoad()  
{  
trace(“attempting to load movie”);  
this.attachMovie(“loads”, “loads\_1”, 0);  
loads\_1.\_x = 60;  
loads\_1.\_y = 340;

```
trace("playing movie loading");

```

}

The movie animation plays fine on tis own. The mask works.

However when the movie is loaded into myh main swf, the mask does not work. I am pretty sure it has something to do with the way it is set.

---

<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 25, 2003, 5:06pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237/5 "2003-04-25T17:06:49Z")

</div>

sorry CORRECT function is CreateNewLoad()

function createNewLoad(){  
trace(“attempting to create a new container”);  
\_root.createEmptyMovieClip(“container”, 0);  
loadMovie(“snow.swf”, “container”);  
container.\_x = 60;  
container.\_y = 340;  
}

---

<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 25, 2003, 5:30pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237/6 "2003-04-25T17:30:19Z")

</div>

Here is the animation in question. Perhaps this will help.

---

<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 25, 2003, 5:48pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237/7 "2003-04-25T17:48:10Z")

</div>

Change…

[AS]onClipEvent (load) {  
\_level0.snowy.setmask(\_level0.hole);  
}[/AS]

To…

[AS]onClipEvent (load) {  
\_parent.snowy.setMask(this);  
}[/AS]

Reason: When loading a movie into another movie, the \_root of the loaded movie becomes the \_root of the main movie you are loading into, so \_level0 and \_root won’t work for targeting. Instead you need to use \_parent to go to the parent timeline. And as for the “this” part, since the actions are on that clip, you can use “this” as a target.

---

<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 25, 2003, 6:00pm UTC](https://forum.kirupa.com/t/importing-swf-layers-and-actionscript-mask-question/19237/8 "2003-04-25T18:00:14Z")

</div>

Dude you rock… that fix the issue.

Sometimes it’s hard to think straight when you got Java CFMX, Remoting, Actionscript, Javascript and ASP in your head.

Thanks again.
