We help IT Professionals succeed at work.

Flex 3: AddEventListener for loaded frames

rbichon asked
Medium Priority
Last Modified: 2012-05-06
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.
Watch Question

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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


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.

Can you show what you did in code?


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

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.


Oh, I didn't realize that you could set an event listener on one particular frame. Your way is obviously cleaner. Thanks.

No my way was psudo its not real buts its how I was thinking it may exist.  Your way is correct.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.