AS3 signals are free , very fast and relaible messaging tool, i have been using them from last 6 months , below are some features of Signals which are more superior than Events
Dowload it from https://github.com/robertpenner/as3-signals/wiki/
Signal's Salient Features
Remove all event listeners : signal.removeAll();
Retrieve the number of listeners : signal.numListeners
Listeners can be added for a one-time call and removed automatically on dispatch:
signal.addOnce(theListener); // result: signal has one listener
signal.dispatch(theEvent); // result: theListener is called, signal now has no listeners
A Signal can be initialized with value classes that will validate value objects on dispatch (optional):
// A Signal that will dispatch a String and an integer:
progress = new Signal(String, int);
//later:
progress.dispatch(); // will throw ArgumentError
progress.dispatch('The Answer'); // will throw ArgumentError
progress.dispatch('The Answer', 42.5); // will throw ArgumentError
progress.dispatch('The Answer', 42); // will succeed
Varun Rathore
Showing posts with label Flex. Show all posts
Showing posts with label Flex. Show all posts
Thursday, May 26, 2011
Wednesday, May 25, 2011
Adobe AIR - Opening Main Appllication from Child Window
Hi, I was trying to make the Main Application open and dock from a child window, here is the simple code to do this, it check if the Main application is not docked, if not if put that to front.
if(FlexGlobals.topLevelApplication.stage.nativeWindow.visible == false)
{
FlexGlobals.topLevelApplication.stage.nativeWindow.visible = true;
FlexGlobals.topLevelApplication.stage.nativeWindow.orderToFront();
}
FlexGlobals.topLevelApplication.stage.nativeWindow.orderToFront();
-Varun Rathore
if(FlexGlobals.topLevelApplication.stage.nativeWindow.visible == false)
{
FlexGlobals.topLevelApplication.stage.nativeWindow.visible = true;
FlexGlobals.topLevelApplication.stage.nativeWindow.orderToFront();
}
FlexGlobals.topLevelApplication.stage.nativeWindow.orderToFront();
-Varun Rathore
Labels:
AlwaysToFront,
Dock,
Flex,
Maximise,
Minimise,
sqllite Adobe AIR Flex Offline
Wednesday, August 26, 2009
Flex Challenge to know your acquisitions
Here is a good go-ahead step by Adobe india for flex developer to know their skills
Check out the great application with a great challenge at
http://flashahead.adobe.com/challenges/
I finised the challange in less than 20 minutes. :)
Cheers
Varun Rathore
http://www.vrathore.blogspot.com
Thursday, April 23, 2009
Adding Custom Components to Text Layout Framework(ADOBE LABS)

The Text Layout Framework is a set of ActionScript 3.0 libraries with support for complex scripts and advanced typographic and layout features not available in the TextField class,It allows us to add custom components and Display objects in the TextArea making the issue of adding headers, tables and providing loacl anchor links , also we can add multiple TextFlow elements in between the display objects and set the selection in between those elements. Still there are some Bugs which make the Text Layout framework informal to handle but overall we can achieve a good sort of text Typography which was earlier missing in Flash.
here is a code sniplet which i used to make multiple TextFlow elements inside onemain container.
// Creating a TextFlow for handling selected Text and editing
[Bindable]public var selectedFlow : TextFlow ;
// Adding UIComponent and TextFlow Dynamically, where is a public class //LinkedContainers extends Sprite
var dspObj : DisplayObject = new LinkedContainers();
dspObj.name = "dspObject";
var ufComponent = new UIComponent();
var custTextFlow : TextFlow = new TextFlow();
custTextFlow.flowComposer.addController(new DisplayObjectContainerController(ufComponent,textArea.width,textArea.height));
// setup event listeners for selection changed and ILG loaded
custTextFlow.addEventListener(SelectionEvent.SELECTION_CHANGE,selectionChangeListener,false,0,true);
custTextFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGED,graphicStatusChangeEvent,false,0,true);
//_textFlow.addEventListener(CompositionCompletionEvent.COMPOSITION_COMPLETE,checkCompositionChange);
custTextFlow.addEventListener(SelectionEvent.SELECTION_CHANGE,function checkChange():void{
selectedFlow = custTextFlow;
Cheers
Varun Rathore
Tuesday, February 10, 2009
Hash Map in Flex / AIR / AS3

A HashMap lets you look up values by exact key (always case-sensitive). It is very much like a Hashtable, except that it is faster and not thread-safe. There are some minor other differences:
* HashMaps work with Iterators where the older Hashtables work with Enumerations
* Hashtables work best with capacities that are prime numbers. HashMaps round capacities up to powers of two.
In Flex we dont have such a facility to look up values by exact key , so i tried to create a HashMap Class which have almost all the typical function needed to be used in the application, i have created a custom Stack Class too and will be sharing the code for that too soon.
Here goes the code :-
package
{
public class HashMap
{
public var keys:Array;
public var values:Array;
//
public function HashMap()
{
super();
this.keys = new Array();
this.values = new Array();
}
public function containsKey(key:Object):Boolean
{
return (this.findKey(key) > -1);
}
public function containsValue(value:Object):Boolean
{
return (this.findValue(value) > -1);
}
public function getKeys():Array
{
return (this.keys.slice());
}
public function getValues():Array
{
return (this.values.slice());
}
public function get(key:Object):Object
{
return (values[this.findKey(key)]);
}
public function put(key:Object, value:Object):void
{
var oldKey;
var theKey = this.findKey(key);
if (theKey < 0)
{
this.keys.push(key);
this.values.push(value);
}
}
public function putAll(map:HashMap):void
{
var theValues = map.getValues();
var theKeys = map.getKeys();
var max = keys.length;
for (var i = 0; i < max; i = i - 1)
{
this.put(theKeys[i], theValues[i]);
}
}
public function clear():void
{
this.keys = new Array();
this.values = new Array();
}
public function remove(ikey:Object):Object
{
var theiKey = this.findKey(ikey);
if (theiKey > -1)
{
var theValue = this.values[theiKey];
this.values.splice(theiKey, 1);
this.keys.splice(theiKey, 1);
return (theValue);
}
}
public function size():int
{
return (this.keys.length);
}
public function isEmpty():Boolean
{
return (this.size() < 1);
}
public function findKey(key:Object):Object
{
var index = this.keys.length;
while(this.keys[--index] !== key.toString() && index > -1)
{
}
return(index);
}
public function findValue(value:Object):Object
{
var index = this.values.length;
while(this.values[--index] !== value && index > -1)
{
}
return (index);
}
}
}
Cheers
Varun Rathore
Monday, February 9, 2009
How to escape characters while Saving Data in SQLITE database
I have used the following function while saving data to sqllite if the data had some characters which needed to be escaped passing the string to the function returns the escapes string .
private static function SQLSafe(strTemp:String):String
{
var i:Number = 0;
var iOld:Number = 0;
var firstQuote:Boolean = false;
var strNew:String = "";
strTemp = StringUtil.trim(strTemp);
while (i != -1){
i = strTemp.indexOf("'", i);
if (i != -1){
if ((strNew != "") || (firstQuote)){
strNew += "'" + strTemp.substring(iOld, i);
}
else if (i != 0) {
strNew = strTemp.substring(iOld, i);
}
else {
firstQuote = true;
}
iOld = i;
i++;
}
}
if (iOld <= strTemp.length){
if (strNew != ""){
strNew += "'" + strTemp.substring(iOld, strTemp.length);
}
else {
strNew = strTemp.substring(iOld, strTemp.length);
}
}
return (strNew);
}
Cheers
Varun Rathore
private static function SQLSafe(strTemp:String):String
{
var i:Number = 0;
var iOld:Number = 0;
var firstQuote:Boolean = false;
var strNew:String = "";
strTemp = StringUtil.trim(strTemp);
while (i != -1){
i = strTemp.indexOf("'", i);
if (i != -1){
if ((strNew != "") || (firstQuote)){
strNew += "'" + strTemp.substring(iOld, i);
}
else if (i != 0) {
strNew = strTemp.substring(iOld, i);
}
else {
firstQuote = true;
}
iOld = i;
i++;
}
}
if (iOld <= strTemp.length){
if (strNew != ""){
strNew += "'" + strTemp.substring(iOld, strTemp.length);
}
else {
strNew = strTemp.substring(iOld, strTemp.length);
}
}
return (strNew);
}
Cheers
Varun Rathore
Labels:
AIR,
Escaping Characters,
Flex,
sqllite Adobe,
String
Subscribe to:
Posts (Atom)
About Me
- vrathore
- noida, dehli, India