Skip to content

Commit 36c27bd

Browse files
committed
#177 IE9, IE11 flash.camera remembered settigns
1 parent 7f3487d commit 36c27bd

File tree

2 files changed

+41
-33
lines changed

2 files changed

+41
-33
lines changed

dist/FileAPI.flash.camera.swf

-247 Bytes
Binary file not shown.

flash/camera/src/FileAPI_flash_camera.as

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package
22
{
3-
import flash.display.Bitmap;
43
import flash.display.BitmapData;
54
import flash.display.Sprite;
65
import flash.display.StageAlign;
76
import flash.display.StageScaleMode;
8-
import flash.events.*;
7+
import flash.events.Event;
8+
import flash.events.StatusEvent;
99
import flash.media.Camera;
1010
import flash.media.Video;
11-
import flash.text.TextField;
11+
import flash.utils.setTimeout;
1212

1313
public class FileAPI_flash_camera extends Sprite
1414
{
@@ -39,38 +39,20 @@ package
3939
// we need to show settings dialog, so we attach camera to a video
4040
video = new Video();
4141
video.attachCamera(camera);
42+
if (!camera.muted) {
43+
onCameraStatus(new StatusEvent(StatusEvent.STATUS, false, false, 'Camera.Unmuted'));
44+
}
45+
else {
46+
setTimeout(function ():void {
47+
if (securityPanelIsClosed()) {
48+
onCameraStatus(new StatusEvent(StatusEvent.STATUS, false, false, 'Camera.Muted'));
49+
}
50+
}, 1000);
51+
}
52+
4253
} else {
4354
// callback with error
4455
}
45-
46-
47-
// test
48-
/*var tf:TextField = new TextField();
49-
tf.text = 'on';
50-
tf.x = 10;
51-
tf.width = 30;
52-
tf.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
53-
toggleCamera(true);
54-
});
55-
addChild(tf);
56-
57-
tf = new TextField();
58-
tf.text = 'off';
59-
tf.x = 50;
60-
tf.width = 30;
61-
tf.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
62-
toggleCamera(false);
63-
});
64-
addChild(tf);
65-
66-
tf = new TextField();
67-
tf.text = 'photo';
68-
tf.x = 100;
69-
tf.width = 30;
70-
tf.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
71-
shot();
72-
});
73-
addChild(tf);*/
7456
}
7557

7658
public function toggleCamera(on:Boolean):void {
@@ -121,5 +103,31 @@ package
121103
// redispatch
122104
dispatchEvent(event.clone());
123105
}
106+
107+
/**
108+
* This code checks one time if the security panel is closed.
109+
* When you open the security panel, you should run this test
110+
* repeatedly with a timer (every 500ms seems to work well).
111+
* If the security panel is closed, you can then clean up your timers
112+
*/
113+
private function securityPanelIsClosed():Boolean
114+
{
115+
// Why not just wait for an event from the SettingsPanel to know that it's closed? Because there isn't one.
116+
// See http://bugs.adobe.com/jira/browse/FP-41
117+
var closed:Boolean = true;
118+
var hack:BitmapData = new BitmapData(1,1);
119+
try
120+
{
121+
// Trying to capture the stage triggers a Security error when the settings dialog box is open.
122+
hack.draw(stage);
123+
}
124+
catch (error:Error)
125+
{
126+
closed = false;
127+
}
128+
hack.dispose();
129+
hack = null;
130+
return (closed);
131+
}
124132
}
125-
}
133+
}

0 commit comments

Comments
 (0)