1
votes

i searched for something similar here, but didn't found a clue about what's going on.

I have a Movie Clip object with a timeline, and it has 3 layers: a layer to stop the timeline at the last frame, a layer with regular drawing with mask attribute and a layer containing a target movieclip with the instance named 'target', that is masked by the layer above.

The drawing is very simple, not even a movieclip, just vector drawing. It's supposed to show the target movieclip only on regions where the mask layer has some drawing, right?

So, I created the method to load an image, listen to the complete loaded event and add the image to the target masked movieclip, but it disappears after the first frame! If i delete the layer with the mask drawing, works fine. Any clues?

Here's a smaller version of the code. Thanks in advance.

package  
{
    import flash.display.*
    import flash.events.Event;
    import flash.net.URLRequest;

    public class Main extends MovieClip
    {
        public function Main() 
        {
            var loader:Loader = new Loader()
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, listenComplete)
            loader.load(new URLRequest('img.jpg'));

        }

        private function listenComplete(e:Event)
        {
            target.addChild(e.currentTarget.content)

        }

    }

}
3

3 Answers

1
votes

Well, i got a solution - not quite what i wanted, but its a good one.

I created a new movieclip with the drawing, called it 'maskTimeLine' and pasted all frames, with a stop in the end, and left it as a regular layer. Then i instantiated it on the layer above my 'target' layer, stripped off the additional frames (that now belongs to the maskTimeLine object) and tried again, this time adding target.mask = maskTimeLine after the target.addChild method.

It works! :)

I believe that Flash has some trouble to work with addChild on a layer below a mask with timeline (that's it, these situations together. I've done a lot of 'addChild()' to animated movie clips, and added children to layer below masks too, but never done both things in the same object).

I hope this helps others too. Thanks all of you for your time!

1
votes

I had same problem but fixed it. 3 layers:

Layer 1 (Top layer of movie clip) was a mask. Layer 2 was the content being masked. Layer 3 was a non-masked layer.

Then, I dynamically added a symbol/movie clip to this at runtime. Won't show up. Automatically got masked by the Layer 1 mask.

To fix this, I created a blank layer above the other 3, then added something to that layer. If you don't add something to the layer, the empty layer is ignored and the problem remains. But as soon as you add another layer above everything and put something on it, Flash puts your dynamic content onto the topmost/unmasked layer.

Weired.

0
votes

It's something like then following.
Sorry no time to test code but one of these is correct.

target.addChild(loader.contentLoaderInfo);
or
target.addChild(loader.content);
or
target.addChild(loader);
or
// event targeting
target.addChild(e.currentTarget.contentLoaderInfo)
or
target.addChild(e.currentTarget);