0

I've been searching for the past few hours how to do this but with no luck. First of all I'm new to AS and not sure what to search for.

So here's what I have and what I want to do:The stage has only 1 frame and on the stage I have 1 button (b1), 1 movie clip that is not visible (area) and 1 visible movie clip that is an animation of 20 frames(ani). For the moment when I press button "b1" it will start the movie "ani" (movie is stopped initially) that will stop when it reaches frame 20. Now what I want is when it reaches the last frame to make movie clip "area" visible. Since I am inside "ani" and on frame 20, I cannot use directly area.visible = true; as I would get the error "Access of unidentified property area." What would be the way to access "area"'s properties from within the other object ?

4

2 回答 2

0

I'm not sure I completely understand everything you said, but I think what you want to do is something like this on your stage where both ani and area have scope :

ani.addEventListener(Event.ENTER_FRAME, frameCheck);

function frameCheck(e:Event):void
{
   if (ani.currentFrame == ani.totalFrames)
  {   
      ani.removeEventListener(Event.ENTER_FRAME, frameCheck);
      area.visible = true;  
  }
}

That was just an example of how you could detect ani hitting the last frame and dealing with that appropriately.

You would need to add the event listener EACH TIME the button is pressed.

于 2013-03-30T03:31:43.007 回答
0

Inside your "ani" MovieClip (at last frame) add the following sentence,

MovieClip(this.parent).area.visible = true;

Here, parent is your main timeline.

(Note: This approach is not recommended).

Instead, use External classes approach. e.g. use Loader class to load animated swf with COMPLETE event and with contentLoaderInfo get swf object and detect for last frame and make area MovieClip visible.

于 2013-03-30T08:09:18.397 回答