Copy link to clipboard
Copied
Hi,
My application is a self-defined streaming player page. I would like to show the information of a series of video clips on the time buffer bar of my player as the following figure. The blue parts are the valid video clips. What I want to implement are that a thumbnail will show when MouseEvent.MOUSE_MOVE is triggered and the streaming will go to the right time when MouseEvent.MOUSE_DOWN is triggered. The information of the video clips(start time and end time) is received from remote server, so I need to generate the blue bar dynamically. My codes are as follows,
for(i = 0; i < pieces.length; i++)
{
if(pieces.end > beginning)
{
var wid:Number; // The variable to decide the
var rect1 = new Videoclip; // The class of video clip, which contains the blue image
var xx:Number; // position of the blue bar at x axis
if(pieces.start >= beginning)
{
wid = 840 * ((pieces.end - pieces.start) * 1.0) / ((ending - beginning) * 1.0);
xx = 840 * ((pieces.start - beginning) * 1.0) / ((ending - beginning) * 1.0);
}
else
{
wid = 840 * ((pieces.end - beginning) * 1.0) / ((ending - beginning) * 1.0);
xx = 0;
}
rect1.x = xx;
rect1.y = -1;
rect1.width = wid;
rect1.addEventListener(MouseEvent.MOUSE_DOWN, progressClicked); // add two event listener dynamically
rect1.addEventListener(MouseEvent.MOUSE_MOVE, thumbnail);
mcVideoControls.mcProgressFill.addChild(rect1); // mcVideoControls.mcProgressFill is a movieclip symbol
}
}
I want to ask if there is a limitation of added child for a symbol of movieclip; also, I wonder if generating an event listener dynamically is a good idea. Thanks.
Copy link to clipboard
Copied
While there are limits to everything, you are not likely to come close to reaching that limit with the design you are describing (It will be a very large number).
Adding listeners dynamically is a good idea. Removing them dynamically when they are noi longer needed is also a good idea.
Copy link to clipboard
Copied
Thanks!
Copy link to clipboard
Copied
You're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now