Flex 3: AddEventListener for loaded frames

I have a "Play" button that shows up in a flex app that plays flv's. The play button is centered on top of the movie with a slight transparency to mimic the way youtube does it. When the button is clicked, the movie begins to play. I would like for it to appear after the first frame of the movie displays on the screen. Is there an event I can use for this? (i.e. onframeload) Thanks.
LVL 1
rbichonAsked:
Who is Participating?
 
Jones911Commented:
Not sure about the event but make a timer and after 1-2 second or what ever time you need call your method to hide the button.
0
 
rbichonAuthor Commented:
I saw another post that suggested the same thing. Instead, I found a way to show the button after the flex app loaded a specific number of frames. Thanks anyway.
0
 
Jones911Commented:
Can you show what you did in code?
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
rbichonAuthor Commented:
I will attach a little bit of the code. Basically, the button starts off with an alpha of 0. When 50 frames have loaded, it sets the playImage button to 50% alpha. There is a lot more to the code because I also wanted the button to go invisible again after they click play, but that is another story.
public var totalframes:int = 0;
 
private function initVars():void {
    myPlayer.addEventListener(Event.ENTER_FRAME, showButton);
}
 
private function showButton(event:Event):void{
    totalframes += 1;
    if (totalframes == 50){
        myPlayer.removeEventListener(Event.ENTER_FRAME, showButton);
        playImage.alpha = 0.5;
    }
}

Open in new window

0
 
Jones911Commented:
Ahh OK.  I was thinking there might have been some way to do this:

PSUDO code of course

 myPlayer.addEventListener(Event.ENTER_FRAME(30), showButton);

But your method is perfect.
0
 
rbichonAuthor Commented:
Oh, I didn't realize that you could set an event listener on one particular frame. Your way is obviously cleaner. Thanks.
0
 
Jones911Commented:
No my way was psudo its not real buts its how I was thinking it may exist.  Your way is correct.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.