Delay Adding Child (Movie Clip) to Stage
I am attempting to add a movie clip to the stage when a button is triggered. When the user clicks the button the movie clip is added to the stage; it works fine, but the following problems occur:
1) The appearance of the movie clip is delayed.
2) The sound in the movie clip starts to play but the movie clip appears when the sound is finished.
Additional information:
1) The movie clip has the sound in the timeline.
Here is the code:
Actionscript Code:
//Buttons: Adds movie clip to stage.
readtomeShortA1.addEventListener(MouseEvent.CLICK, playShortAReadMe1);
var playShortA1:ShortAReadMe1
function playShortAReadMe1(e:MouseEvent):void{
playShortA1 = new ShortAReadMe1
addChild(playShortA1);
playShortA1.x = 307;
playShortA1.y = 603;
}
My questions are:
1) I'm not sure if the movie clip is playing or not. The movieclip is supposed to play on top of a text box. It is the same text, but the movieclip text highlights the words as it is being played.
So the movieclip may be playing but under the other layers. I suspect this is the problem. If so, then I would assume I would use the addChildat method so that the movieclip plays on top. Please confirm. Note I did this with the following code and I was still not able to see the movie clip. I was attempting to have the movieclip play on top of everthing:
Actionscript Code:
function playShortAReadMe1(e:MouseEvent):void{
playShortA1 = new ShortAReadMe1
addChildAt(playShortA1,7);
playShortA1.x = 307;
playShortA1.y = 603;
trace (numChildren);
}
2) However, I also want to know is keeping the sound in the timeline of the movieclip the most efficient way to use sound in the movieclip? Or is there better, more efficient way to do it? I ask this because I want to make sure that there are no problems with the sound being loaded when called.