• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1382
  • Last Modified:

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.
0
rbichon
Asked:
rbichon
  • 4
  • 3
1 Solution
 
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now