SaveBArrayLocal (Adobe AIR only)

public class SaveBArrayLocal
The SaveBArrayLocal class allows to draw from an image and create a new image of any size and place it on the computer. Use the constructor to create a new SaveBArrayLocal().
Public Properties
Property Defined By
fileUrl : String
The URL of the file on the computer.
imgLoc : String
The location of the new image on the computer.
Public Methods
Method Defined By
Creates a new instance of the SaveBArrayLocal class.
initImage(mClip:DisplayObjectContainer, fName:String, _width:int, _height:int, folder:String="bytearrayimg", saveMode:Boolean=true, qual:int=80, _image:String="jpg")  :void
Initiates the draw and creation of the new image.
Event Defined By


This event is dispatched when the image was saved.

All inherited events for the EventDispatcher class. N/A
Property Detail
fileUrl property
fileUrl:String [read-write]

The URL for the image on the computer after it was saved.


public function get fileUrl():String
public function set fileUrl(value:String):void
imgLoc property
imgLoc:String [read-write]

The location, where the image should be saved, "desktop", "documents", "storage" or "user". Default is "desktop".


public function get imgLoc():String
public function set imgLoc(value:String):void
Constructor Detail
SaveBArrayLocal ()  Constructor
public function SaveBArrayLocal()
Intializes a new SaveBArrayLocal instance.
Method Detail

SaveBArrayLocal()  method
public function SaveBArrayLocal():void

Creates a new instance of the SaveBArrayLocal.

initImage(mClip:DisplayObjectContainer, fName:String, _width:int, _height:int, folder:String="bytearrayimg", saveMode:Boolean=true, qual:int=80, _image:String="jpg"):void   method

Creates a new image and saves it on the computer.


  • mClip:DisplayObjectContainer ____ The image source in the swf.
  • fName:String ____ The name of the newly created file.
  • _width:int ____ The width of the newly created image.
  • _height:int ____ The height of the newly created image.
  • folder:String="bytearrayimg" ____ Optional, the name of the image folder. The default is "bytearrayimg"
  • saveMode:Boolean=true ____ Optional, to save the image directly (true) or browse for a new location/name (false). The default is true.
  • qual:int=80 ____ Optional, The image quality. Default is 80 (of 100)
  • _image:String="jpg" ____ Optional, the type of image, jpg or png. Default is jpg.
Event Detail

imageSaved event

Event Object Type: biz.flashscript.adobeAir.SaveBArrayLocal
Event.type property = biz.flashscript.adobeAir.SaveBArrayLocal.IMAGE_SAVED

Dispatched when the image was saved.

Create a new fla file and name it SaveBArrayLocalExample.fla. Place the fla in the same folder as the biz folder. Put a UILoader component (imgHolder), two Button components (submitBut, showImg) and one TLFTextField instance (waitCounter) on the stage. Place 4 button components and name them A0, A1, A2, A3. Then create an Actionscript file, name it and place this script.
	import flash.display.Sprite;
	import fl.containers.UILoader;
	import fl.controls.Button;
	import fl.text.TLFTextField;
	import flashx.textLayout.formats.TextLayoutFormat;
	import flashx.textLayout.elements.TextFlow;
	import biz.flashscript.adobeAir.SaveBArrayLocal;

	public class SaveBArrayLocalExample extends Sprite
		public var imgHolder:UILoader;
		public var submitBut:Button;
		public var waitCounter:TLFTextField;
		public var showImg:Button;
		private var imgLoader:SaveBArrayLocal;
		public var A0:Button;
		public var A1:Button;
		public var A2:Button;
		public var A3:Button;

		public function SaveBArrayLocalExample ():void
			A0.label = "image 1";
			A0.addEventListener (MouseEvent.CLICK, selectImage);
			A1.label = "image 2";
			A1.addEventListener (MouseEvent.CLICK, selectImage);
			A2.label = "image 3";
			A2.addEventListener (MouseEvent.CLICK, selectImage);
			A3.label = "image 4";
			A3.addEventListener (MouseEvent.CLICK, selectImage);
			submitBut.label = "Save Image";
			showImg.label = "Show image";
			showImg.visible = false;
			showImg.addEventListener (MouseEvent.CLICK, showImage);
			submitBut.addEventListener (MouseEvent.CLICK, saveHandler);
			imgLoader = new SaveBArrayLocal ();
			imgLoader.addEventListener (SaveBArrayLocal.IMAGE_SAVED, imageUrlLoaderComplete);
		private function selectImage (ev:Event):void
			imgHolder.source = """.jpg";
		private function saveHandler (ev:Event):void
			waitCounter.text = "Saving starts in a second...";
			imgLoader.initImage (imgHolder,"test",500, 500, "Test");
		private function imageUrlLoaderComplete (event:Event):void
			waitCounter.text = "Image is saved.";
			showImg.visible = true;
		private function showImage (ev:Event):void
			imgHolder.source = imgLoader.fileUrl;