Closed GoogleCodeExporter closed 9 years ago
Hi,
Thanks for the suggestion. I am having tough time to reliably get focusIn event
on stage in my test. It looks like the focusIn event fires immediately after
Flash security panel is closed, only if use has clicked on some button earlier
in the Flash application. To verify my understanding, I wrote a simple program
which you can test too.
binary at: http://myprojectguide.org/p/flash-videoio/Test.swf
source at: http://myprojectguide.org/p/flash-videoio/Test.mxml.txt
To test, go to the binary URL, and click on the "show" button on top-right
within 10 seconds. This shows the security panel. Click allow, and close, and
then you will see an Alert box immediately saying "focusIn was received".
Now refresh the page, and wait for 10 seconds for the security panel to show
*without* clicking on the "show" button. Click allow, and close, and you don't
see any "focusIn ..." event. Now when you click on the show button, you see the
focusIn event. So looks like the focusIn event is not quite reliable for
detecting when the security panel is closed.
Note also that Alert.show doesn't work if done in focusIn handler so had to use
a 0 ms timer.
If you are able to get focusIn reliably without a user click in the application
buttons, please send me the sample source code based on my Test.mxml and I will
incorporate those changes... Any other suggestions are welcome too. One option
is to show a "close" button behind the security panel, which user must click
after closing the security panel.
Original comment by kundan10
on 10 Aug 2011 at 6:26
I used a different technique to detect that the Flash security settings is no
longer active. I found three techniques (workarounds) and all these workarounds
have their own limitations. The version 2.5 has the fix based on periodically
checking the stage.numChildren value.
From developer point of view, first set "privacyEvent" property to true. This
will cause "onShowingSettings" callback to be invoked whenever the Flash player
security settings is about to be shown and after it is closed. The
event.showing property is true or false, respectively. This is a non-backward
compatible change in version 2.5, that onShowingSettings is invoked for show
and close of the security panel instead of just on show in version 2.4.
function onShowingSettings(event) {
log("onShowingSettings() " + event.showing);
}
To test this, use Flash Player 10.3 or later, and go to
myprojectguide.org/p/flash-videoio/test.html then enable "privacyEvent"
property. Now enable "live" property which will enable local camera view and
show the security settings dialog box. It will also show the onShowingSettings
callback with showing=true. After you close the settings dialog box it will
show the onShowingSettings callback with showing=false.
To use this fix, download the version 2.5 or later of VideoIO and use the
appropriate SWF from the zip archive in your application.
The rough sketch of the fix in actionscript is as follows:
private var settingsTimer:Timer;
private var stageChildren:int = 0;
public function showSettings():void
{
if (privacyEvent) {
// dispatch onShowingSettings with showing=true
var stage:Stage = mx.core.FlexGlobals.topLevelApplication.stage;
if (settingsTimer == null) {
stageChildren = stage.numChildren;
settingsTimer = new Timer(100, 0);
settingsTimer.addEventListener(TimerEvent.TIMER, settingsTimerHandler, false, 0, true);
settingsTimer.start();
}
}
Security.showSettings(SecurityPanel.PRIVACY);
}
private function settingsTimerHandler(event:TimerEvent):void
{
var stage:Stage = mx.core.FlexGlobals.topLevelApplication.stage;
if (settingsTimer != null && (stage.numChildren == stageChildren)) {
settingsTimer.removeEventListener(TimerEvent.TIMER, settingsTimerHandler);
settingsTimer.stop();
settingsTimer = null;
if (privacyEvent) {
// dispatch onShowingSettings with showing=false
}
}
}
Original comment by kundan10
on 10 Aug 2011 at 10:26
Re-opening this bug, because the stage.numChildren trick no longer works in the
latest version of Flash Player. Deprecating the "privacyEvent" property until
it can be fixed. The new behavior is that it dispatches the onShowingSettings
with showing=false, and immediately after that again dispatches the
onShowingSettings with showing=true.
Should explore other alternatives such as those listed in
http://stackoverflow.com/questions/6945055/flash-security-settings-panel-listeni
ng-for-close-event
Original comment by theinten...@gmail.com
on 14 Oct 2012 at 4:41
After the above comment, this is not merged with #27.
Original comment by theinten...@gmail.com
on 14 Oct 2012 at 5:31
Original issue reported on code.google.com by
a.v.ch...@gmail.com
on 8 Aug 2011 at 1:16