Is there an easy way to switch out a movieClip for another dynamically loaded movieClip?
I have and eventListener onCLICK that when selected it starts an FLVPlayback but I would also like to swap out with another movieClip Play Now / Now Playing button.
Just some background. I am looping and loading a play button jpg’s into one movie clip and assigning an incremental number as a name to the play button movie clip. On Click that play button plays a movie but now I would also like to switch the play button graphic to a playing now graphic.
//ADD EVENT LISTENER TO ALL MY THUMBS_BUTTON
thumbs_button.addEventListener (MouseEvent.CLICK, playVideoThumb);
for (var i:Number = 0; i < my_total; i++) {
var playButton_url = "play_now.png";
var playButton_loader = new Loader();
playButton_loader.name = i;
playButton_loader.load (new URLRequest(root_path + playButton_url));
playButton_loader.contentLoaderInfo.addEventListener (Event.COMPLETE, playButtonLoaded);
playButton_loader.y = (115 * i) + (135 * i) + 138;
//PUT NEW LOADED IMAGE INTO THUMBS_BUTTON
function playButtonLoaded (e:Event):void {
var my_playButton:Loader = Loader(e.target.loader);
thumbs_button.addChild (my_playButton);
}
//THIS IS WHERE I NEED TO REMOVE THE PLAY NOW AND PUT IN THE NOW PLAYING BUTTON
function playVideoThumb (e:MouseEvent):void {
var video_url = root_path + my_videos[e.target.name].@URL;
my_player.source = video_url;
var blank_butt:Number = thumbs_button.getChildByName(e.target.name).x;
thumbs_button.removeChild(thumbs_button.getChildByName(e.target.name));
}
Looking at your code I assume you probably want a radiobutton like functionality. There a few ways to do this. One way would by removing and adding children or in the case below just using the visible property:
If you don’t need any processing of the loaded buttons, you can immediately add the Loader objects to the thumbs_button. You don’t have to do this in the COMPLETE handler.