PDA

View Full Version : [AS3] SeekBar Custom Component: scrubber handle not disappearing


olke
05-27-2009, 05:36 PM
I am having some issues trying to get the scrubber handle to disappear on non movie scenes. I have a flash file, that has a navigation menu on the left side of the stage. When you click on a navigation element, it changes what gets shown on the right side of the stage. One of the navigation elements is a movie trailer, that shows player controls(my own custom controls). The other nav elements reference non movie screens, like a synopsis of the movie(note: no player controls).

The problem i am having is that when i change fromt he movie screen to a non movie screen, i can make all the custom components disappear, except the timeline scrubber handle.


Heres what i did,
I dragged a seekbar, playpausebutton, muteButton custom component to my stage.

I then put this actionscript into my file


import fl.video.VideoEvent;

vid.pause();
vid.skin = null;
vid.source = ermParams["vidUrl"];
vid.playPauseButton = mc_playPause_btn;
vid.muteButton = mc_mute_btn;
vid.seekBar = mc_seek_bar;


When i switch to a non movie screen, i do the following

mc_mute_btn.visible = false;
mc_playPause_btn.visible = false;
mc_seek_bar.visible = false;
vid.visible = false


All the controls disappear, except for the scrubber handle.

When i move to the movie screen, i have the following code

vid.visible = true;
mc_mute_btn.visible = true;
mc_playPause_btn.visible = true;
mc_seek_bar.visible = true;


Ive read on various forums, including this one, and nothing seems to work without bugs.

The closest i have gotten to getting things working is that when i move off movies screen, i remove the seekbar child.


removeChild(mc_seek_bar);


When i move to a movie screen, i reassing the seekbar to the video.

vid.seekBar = mc_seek_bar;


This seems super hacky. And there is a bug, lets say the scrubber has progressed half way across the timeline. When i use the navigation to move back to the movie screen, and the controls display, the srubber starts off at the beginning of the timeline, and "hops" to where we previously left off.

Anyone have any ideas?

thanks

deDogs
06-18-2009, 03:26 PM
Something that may help?

I created a movie clip and put all the video components into the movie clip, therefore, if i wanted to set the visibility to false, I would set the move clip's visible to false and all the components become invisible.

I hope this helps

deDogs

Someguy20
06-29-2010, 07:52 PM
NOTE: These instructions also apply to the volume bar and the volume bar handle.

The FLVplayback object's seekbar handle is part of the seekbar component on layer 2.

No matter if you give it an instance name at authortime, it gets taken by flash and moved somewhere else at runtime. In other words your instance name won't work as a target.

I've found that flash gives it some generic instance name like 'instance 29' or something by using Event.target.name in an event handler while trying to find a name to target it by. Those don't work either.

Here's what will work:

Place your seekbar (or entire skin) into a containing movieclip and give that an instance name (for this example I'll use 'mySkin'). When flash generates the handle it will place it at the top of the index of nested movieclips. So we can use a roundabout way to target it.

mySkin.getChildAt(mySkin.numChildren - 1);

getChildAt() will target a nested movieclip based on its index position. the numChildren property returns the total items inside a movieclip. Since getChildAt begins with zero, we subtract 1 and that is the highest level item. Substract 2 to get the the handle. You can set each one to a variable:

volumeHandle = mySkin.getChildAt(mySkin.numChildren - 1);
seekbarHandle = mySkin.getChildAt(mySkin.numChildren - 2);

To test if you have the right movieclip (the handle), set it to visible false.

volumeHandle.visible = false;
seekbarHandle.visible = false;