Comanda pentru setarea atributului smothing a imaginilor din libraria flash (jsfl)

Aceasta comanda trebuie scrisa in notpad si salvata cu estensia .jsfl , apoi din flash aplelati Commands -> Run Command...

var itemArray = fl.getDocumentDOM().library.items;

for (i=0; i<itemArray.length ;i++)
{
	if( fl.getDocumentDOM().library.items[i].itemType=="bitmap")
	{
		fl.getDocumentDOM().library.items[i].allowSmoothing = true;
		fl.getDocumentDOM().library.items[i].compressionType = "lossless";
	}
}

Ceas analog

var now:Date;
var ct:Timer = new Timer(1000); 
ct.addEventListener(TimerEvent.TIMER, onTick);
ct.start();
function onTick(event:TimerEvent):void{
	now = new Date();
	var s:uint = now.getSeconds();
	var m:uint = now.getMinutes();
	var h:uint = now.getHours();
	movieSec.rotation = 180 + (s * 6);
	movieMin.rotation = 180 + (m * 6);
	movieHour.rotation = 180 + (h * 30) + (m * 0.5);
}

Transforma o variabila de tip String in Boolean

package utils
{
	public class StringUtil
	{
		/**
		 * toBoolean
		 * Transforma o variabila de tip String in Boolean si este util
		 * atunci cand incarcati variabile din fisiere de tip XML
		 *
		 * @param value: String
		 *
		 */
		public static function toBoolean(value:String):Boolean
		{
			// Am considerat ca e necesar sa se defieasca explicit false, daca nu se considere true
			return !(value.toLowerCase() == "false" || value.toLowerCase() == "0");	
		}
	}
}

Functie validare cod identificare fiscala (CUI)

/**
 * isValidCUI
 * Valideaza CUI-ul
 * 
 * @param value: se introduce CUI-ul fara RO
 *
 */
function isValidCIF(value:String):Boolean
{
	var control:String = "753217532";
	var rez:Number = 0;
	for (var i:uint = 1; i<value.length; i++){	
		rez += Number(value.charAt((value.length-1)-i))*Number(control.charAt(control.length-i));
	}
	(rez*10)%11 == 10 ? rez = 0 : rez = (rez*10)%11;
	if(rez == Number(value.charAt(value.length-1)))
	{
		return true;
	}
	else 
	{
		return false;
	}
}
trace(isValidCIF("CUI"));

Functie de validare CNP

/**
 * isValidCNP
 * Valideaza CNP-ul
 * 
 * @param value: CNP
 *
 */
function isValidCNP(value:String):Boolean {
	var control:String = "279146358279";
	var rez:Number = 0;
	for (var i:uint; i<12; i++) {
		rez += Number(value.charAt(i))*Number(control.charAt(i));
	}
	rez%11 == 10 ? rez=1 : rez = rez%11;
	if(rez == Number(value.charAt(12)))
	{
		return true;
	}
	else
	{
		return false;
	}
}
trace(isValidCNP("SAALLZZJJNNNC"));

Incarcarea unei imagini folosind URLLoader

package 
{
	import flash.net.URLRequest;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	
	public class LoadingImageExample  extends Sprite
	{
		public function LoadingImageExample() {
			var url:URLRequest = new URLRequest();
            url.url = encodeURI("imagine.jpg");
            var loader:Loader = new Loader();
            loader.load(url);
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
		}
		
		public function onImageLoaded(event:Event):void
		{
			addChild(event.currentTarget.content);
		}
	}
}

Model de CustomEvent

package
{
	import flash.events.Event;

	public class CustomEvent extends Event
	{
		public var data: Object;
		
		public function CustomEvent(data:Object, type:String, bubbles:Boolean=false, cancelable:Boolean=false)
		{
			super(type, bubbles, cancelable);
			this.data = data;
		}
		
		override public function clone():Event
		{
			return new CustomEvent(data, type, bubbles, cancelable);
		}
	}
}

Incarcarea unui fisier XML folosind URLLoader

package
{
	import flash.net.URLRequest;
	import flash.net.URLLoader;
	import flash.events.Event;
	import flash.display.Sprite;
	
	public class XMLLoaderExample extends Sprite
	{
		public function XMLLoaderExample() {
			var url:URLRequest = new URLRequest();
			url.url = "config.xml";
			var loader:URLLoader = new URLLoader();
			loader.load(url);
			loader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
		}
		
		private function onXMLLoadComplete(event:*):void
		{
			trace(event.target.data.toString());
		}
	}
}