mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Added screenshot item to Stage's context menu
This commit is contained in:
parent
9be7d2e86e
commit
4aeeda9f43
1 changed files with 21 additions and 2 deletions
|
@ -25,14 +25,17 @@
|
|||
package scratch {
|
||||
import flash.display.*;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.filters.GlowFilter;
|
||||
import flash.geom.*;
|
||||
import flash.filters.GlowFilter;
|
||||
import flash.geom.*;
|
||||
import flash.media.*;
|
||||
import flash.events.*;
|
||||
import flash.system.Capabilities;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.net.FileReference;
|
||||
import blocks.Block;
|
||||
import filters.FilterPack;
|
||||
import translation.Translator;
|
||||
import uiwidgets.Menu;
|
||||
import ui.media.MediaInfo;
|
||||
import util.*;
|
||||
import watchers.*;
|
||||
|
@ -210,6 +213,22 @@ public class ScratchStage extends ScratchObj {
|
|||
for each (var c:DisplayObject in toDelete) uiLayer.removeChild(c);
|
||||
}
|
||||
|
||||
/* Menu */
|
||||
|
||||
public function menu(evt:MouseEvent):Menu {
|
||||
var m:Menu = new Menu();
|
||||
m.addItem('save picture of stage', saveScreenshot);
|
||||
return m;
|
||||
}
|
||||
|
||||
private function saveScreenshot():void {
|
||||
var bitmapData:BitmapData = new BitmapData(480, 360, true, 0x0);
|
||||
bitmapData.draw(this);
|
||||
var pngData:ByteArray = PNG24Encoder.encode(bitmapData, PNGFilter.PAETH);
|
||||
var file:FileReference = new FileReference();
|
||||
file.save(pngData, 'stage.png');
|
||||
}
|
||||
|
||||
/* Scrolling support */
|
||||
|
||||
public var xScroll:Number = 0;
|
||||
|
|
Loading…
Reference in a new issue