SaveBArrayLocal (Adobe AIR only)

Package:
Class:
Inheritance:
biz.flashscript.adobeAir
public class SaveBArrayLocal
EventDispatcher
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.
SaveBArrayLocal
imgLoc : String
The location of the new image on the computer.
SaveBArrayLocal
Public Methods
Method Defined By
SaveBArrayLocal()
Creates a new instance of the SaveBArrayLocal class.
SaveBArrayLocal
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.
SaveBArrayLocal
Events
Event Defined By

imageSaved

This event is dispatched when the image was saved.

SaveBArrayLocal
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.

Implementation

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".

Implementation

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.

Parameters

  • 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.

Examples
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 SaveBArrayLocalExample.as and place this script.
package 
{
	import flash.display.Sprite;
	import flash.events.*;
	import fl.containers.UILoader;
	import fl.controls.Button;
	import flash.net.navigateToURL;
	import flash.net.URLRequest;
	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 = "http://flashscript.biz/flashas3/biz/images/"+ev.currentTarget.name+".jpg";
		}
		private function saveHandler (ev:Event):void
		{
			waitCounter.text = "Saving starts in a second...";
			imgLoader.initImage (imgHolder,"test",500, 500, "Test");
			imgHolder.unload();
		}
		private function imageUrlLoaderComplete (event:Event):void
		{
			waitCounter.text = "Image is saved.";
			showImg.visible = true;
		}
		private function showImage (ev:Event):void
		{
			imgHolder.source = imgLoader.fileUrl;
		}
	}
}