Cp5 Widget Development - Widget appearing on stage, event needed
First a caveat: I'm returning to Actionscript after after not touching it for a few years so I'm a bit rusty!
Problem: need an elegant method to tell when a Widget has appeared on the stage
A good example of why you might need this is the bundled Timer widget that comes with Captivate - it only starts when the widget appears on stage. Other things might be for example dealing with Captivate variables for more advanced branching schemes, but only at a point in the timeline when you know those variables are in the state they need to be.
So, the timer widget accomplishes this task, what's the problem? The problem is the method it uses is pretty inelegant in that an event listener is used on the ENTER_FRAME event to check on every frame the CPMovieHandle property isWidgetEnabled, and if it is, remove the event listener and start the timer.
From my testing, a widget gets initialised on frame 0 of the Captivate timeline irrespective of which slide the widget is on, so the above event listener is enabled and using resources right from frame 0. Multiply that up by several widgets and you can see what an inelegant solution that is especially if your widget(s) appear within the last few slides.
So, my question; is it possible to somehow extend one of the Captivate classes to raise an event when the widget 'becomes enabled', and render all that ENTER_FRAME stuff redundant? OR is there an undocumented event for what I want (ever hopeful!!)?
One idea I had was to use the CPSlideEnterEvent to only start the ENTER_FRAME listener on the slide that the widget was on - that fell flat as I could not find a way of determining programmatically which slide the widget was on ![]()
Any ideas anyone?