When your component is not visible, is it because it has been removed from the stage, or because its visible property is false?
The component is not visible to the user when I change the state. I have different components included in different states.
Listen for removedFromStage and disable the timer, then listen to addedToStage and reenable it.
Thanks that worked. Is there a way to do this from inside the component? I'm thinking of something like:
Yes, that is what I was suggesting. If you post the code of your component, I can be more specific as to the exact syntax and where you put it.
This is my component:
<?xml version="1.0" encoding="utf-8"?>
public var timer:Timer;
protected function refresh_clickHandler(event:MouseEvent):void
public function refresh():void
cam1.source = null;
cam2.source = null;
cam2.source = "http://____.jpg";
cam1.source = "http://____.jpg";
public function onTime(event:Event):void
protected function init(event:FlexEvent):void
// TODO Auto-generated method stub
timer = new Timer(1000*60);
<s:Image id="cam1" source="http://____.jpg" width="320" height="261" clearOnLoad="true"/>
<s:Image id="cam2" source="http://____.jpg" width="352" height="240" clearOnLoad="true"/>
<s:Button label="Refresh" click="refresh_clickHandler(event)"/>
And in my main application I have this right now:
<local:Cam id="cam" includeIn="Camera" removedFromStage="cam_removedFromStageHandler(event)"/>
protected function cam_removedFromStageHandler(event:Event):void
//remove the camera image refresh when it's not visible
trace("removed camera refresh");