Skip to content

Commit 3194083

Browse files
committed
Merge pull request mailru#271 from im-saxo/hotfixes
flash fixes for #177, #199, #265
2 parents 7f3487d + 279c53b commit 3194083

File tree

7 files changed

+47
-43
lines changed

7 files changed

+47
-43
lines changed

dist/FileAPI.flash.camera.swf

-247 Bytes
Binary file not shown.

dist/FileAPI.flash.swf

-4.36 KB
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+
}

flash/core/src/net/inspirit/MultipartURLLoader.as

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@
481481

482482
private function removeListener(): void
483483
{
484+
if (!_loader) return;
484485
_loader.removeEventListener( Event.COMPLETE, onComplete );
485486
_loader.removeEventListener( ProgressEvent.PROGRESS, onProgress );
486487
_loader.removeEventListener( IOErrorEvent.IO_ERROR, onIOError );
@@ -562,16 +563,17 @@
562563

563564
}
564565
}
566+
import flash.utils.ByteArray;
565567

566568
internal class FilePart
567569
{
568570

569-
public var fileContent:flash.utils.ByteArray;
571+
public var fileContent:ByteArray;
570572
public var fileName:String;
571573
public var dataField:String;
572574
public var contentType:String;
573575

574-
public function FilePart(fileContent:flash.utils.ByteArray, fileName:String, dataField:String = 'Filedata', contentType:String = 'application/octet-stream')
576+
public function FilePart(fileContent:ByteArray, fileName:String, dataField:String = 'Filedata', contentType:String = 'application/octet-stream')
575577
{
576578
this.fileContent = fileContent;
577579
this.fileName = fileName;

flash/core/src/ru/mail/commands/ResizeFileCommand.as

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ package ru.mail.commands
130130
}
131131
else
132132
{
133-
//currentImageMap = fullImageMap.clone();
134-
currentImageMap = fullImageMap;
133+
currentImageMap = fullImageMap.clone();
134+
// currentImageMap = fullImageMap; // #199 #265 вернул обратно clone(), т.к. ниже есть currentImageMap.dispose()
135135
}
136136

137137
// ==============

flash/core/src/ru/mail/controller/AppController.as

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,19 +514,16 @@ package ru.mail.controller
514514
*/
515515
public function getFileInfo(fileID:String, callback:String):void
516516
{
517-
trace ("getFileInfo");
518517
LoggerJS.log('getFileInfo, fileID: '+fileID+', callback: '+callback );
519518
var file:BaseFileVO = _model.filesBuilder.getFileByID(fileID);
520519
if (!file) {
521-
trace ("file with id "+ fileID +" doen't exist");
522520
LoggerJS.log("getFileInfo, file with id "+ fileID +" doen't exist" );
523521
return;
524522
}
525523

526524
var imageFactory:IImageFactory = file.imageFactory;
527525
(imageFactory as EventDispatcher).addEventListener(ImageTransformCompleteEvent.TYPE,function (event:ImageTransformCompleteEvent):void {
528526
event.currentTarget.removeEventListener(event.type, arguments.callee);
529-
trace("getfileinfo complete", event.isSuccess);
530527
LoggerJS.log("getFileInfo complete, success = "+ event.isSuccess );
531528
if (event.isSuccess && (file as IFileVO).imageData)
532529
{

flash/core/src/ru/mail/data/ImageFactory.as

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,10 @@ package ru.mail.data
202202
trace ("bitmap created, isSuccess", event.isSuccess);
203203
LoggerJS.log('ImageFactory bitmap created, success '+ event.isSuccess);
204204
if (event.isSuccess) {
205-
file.imageData = event.decodedBitmap.bitmapData;
206-
/*
207205
file.imageData = new BitmapData( event.decodedBitmap.width, event.decodedBitmap.height );
208206
file.imageData.copyPixels( event.decodedBitmap.bitmapData
209207
, new Rectangle( 0, 0, event.decodedBitmap.width, event.decodedBitmap.height ), new Point( 0, 0 ));
210208
event.decodedBitmap.bitmapData.dispose();
211-
*/
212209

213210
createImageFromSource(imageTransform);
214211
}

0 commit comments

Comments
 (0)