On Mar 22, 2009, at 1:30 AM, Alex Harrington wrote: > > Is it possible to pass parameters in to functions called by > setTimeout or setInterval. I'm trying to get me head around how I > can write a generic avg file with a single DIV and then parse our > XML format (which describes a layout) and then programatically > generate output in the Pleyer. > > I've got code working to do that, but it's proving difficult to > figure out which of the things on the screen has expired. > > For example, I add a div to Player (which is what we would term a > region), and then an image inside it (a media item). I then run > setTimeout for say 20 seconds, which would trigger that image to be > removed and say a video to be put in its place. However, at the same > time, I'll be adding another div to Player, and say some text inside > it, and then a setTimeout for 30 seconds, at which point the text is > removed and an image is loaded in its place. If I write a > regionExpired function to handle removing the outgoing items and > loading in the new ones, I think I need a parameter passed in to > tell me which region I should work on > > ie > > Player.setTimeout(20000, regionExpired(1)) > Player.setTimeout(30000, regionExpired(2))
Yes, this is possible with some python magic: Player.setTimeout(20000, lambda: regionExpired(1)) Google 'python lambda' - it's a powerful tool. Or do it in an object-oriented way: Make region a class, then Player.setTimeout(20000, region1.expired) is trivial :-). Cheers, Uli -- Any technology distinguishable from magic is insufficiently advanced. Ulrich von Zadow | +49-172-7872715 Jabber: [email protected] Skype: uzadow _______________________________________________ libavg-users mailing list [email protected] https://mail.datenhain.de/mailman/listinfo/libavg-users
