R – Accessing ActionScript3 Nested Movie Clips from Class

actionscript-3flash

I'm trying to write a very simple/minimal custom video player in Flash CS3

I have a .fla file with 2 MovieClips in my library, Player and PlayButton. The PlayButton movieclip is found on the first frame inside the Player movieclip. Player is exported to actionscript and linked to a Player.as class which dynamically creates a video object.

My document class is MPlayer.as and it adds an instance of Player to the stage. This works well, and the video will play automatically. However, the PlayButton movieclip that is inside my library item Player does not show up…and I have no idea how to access it or get it to show. it is not in the same position as the video, so it shouldn't be under it…I tried addChild(playbutton_instance_name) from Player.as but I get errors. The Player movieclip is exported for actionscript, but the PlayButton movieclip is not since it's inside Player.

Am I setting this up correctly?

Best Answer

Sounds about right. If it's in your Player MovieClip, it will be exported inside of that. Are you sure it's in the Player clip? You can access it like you would a variable of your Player.as class, i.e. if the PlayButton has an instance name of "playBtn" you could (in the constructor function) try

public function Play()
{
    trace(this.playBtn);
}

And if the clip is in the class properly, it should trace something like [PlayButton]. If you want, post your code in your question or I can take a look at your files if you like.

Related Topic