Monday, November 30, 2009
Free Education To Freshers and Project Training
As the RIA worker i am starting on providing free education to college students and freshers on Flex/AIR and java development to prepare them for Interview and to open there mind on a rich development practices .. This will be a experimental step to educate newbies , I will be covering the basic application development methodologies and will help them create applications for their projects.
Please feel free to contact me at
Varun Rathore
+919988178054
vrathore84@gmail.com
Sunday, November 29, 2009
A Great Window Utility - Windows 7 TuneUp
Windows 7 TuneUp is a great Window utility which makes you forget about PC maintenance and security, Loaded with many tools such as Registry Cleaner,Registry Defragmenter,Junk Files Cleaner, Duplicate Files Finder,Smart Uninstaller,Service Manager,Startup Manager and many more which help you get rid of all the maintenance problems for the system. I recomend this personally as it saved my sysytem from getting crashed and help me save my formatting time.
One of the coolest thing is its very easy installation and free support and service.
Check out this amazing software at WINDOW 7 TuneUp
Tuesday, October 27, 2009
Invoking AIR Application using Batch File
I am pretty sure if we are using a application which interacts with other application we need to invoke it using command propmt . Here is a simple way to invoke the application ..Also while invoking sometime we need to pass variables to the application as we do in flash vars..
First of all we need to set the environment variable for accessing the flex sdk in the system.. Add the following path to the sysytem path variable in your environment variable
C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\bin
Note : It should point to the sdk's bin location in mycase it resided in C:/ Drive .
To Run the application we will use ADL(AIR Debug Launcher) using the following syntax:-
adl [-runtime runtime-directory] [-pubid publisher-id] [-nodebug] application.xml [root-directory] [-- arguments]
In my case i used the following line on my command prompt
F:\PROJECTS\Printing\bin>adl Printing-app.xml -- 321 0 active
First i reach to the point where my application bin folder reside(having compiled swf and application descriptor file) then using adl to invoke my application-app.xml
Note:-
After the application-app.xml i added -- and then i gave three arguments separated my space.
In the application i can get the aruments as follows :-
We listen the following function in the application invoke="onInvoke(event)"
private function onInvoke(e:InvokeEvent):void
{
var arguments : ArrayCollection = new ArrayCollection( e.arguments );
}
Here i get all the arguments in a arraycollection.
Labels:
ADL AIR,
ADL Flex,
Batch File,
Command Prompt,
Invoking AIR,
Run AIR
Sunday, October 11, 2009
Reading and Writing Browser Cookie in Flex
A browser cookie is a small piece of information sent by a web server to a web browser to be stored for future use. The data in the browser cookie will be sent back to the web server whenever the browser reconnects to the web site.
Cookies are commonly used to store user preference information, such as web site options. Cookies are also used to store shopping cart contents. The most security-relevant use of browser cookies is when they are used to store authentication data, such as user names and passwords.
To Read and write Cookie from a flex application we will use Javascript
//Following function will set the cookie in the user browser
function setCookie(c_name,value,expiredays)
{
value = document.getElementById('user').value;
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}
//Following function will return Cookie
function getCookie(c_name){
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1 ;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
For reading a cookie Visitor we will use the following line in Flex code:-
var visitorId : String = ExternalInterface.call("getCookie","Visitor");
Cheers
Varun
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
Using ShareThis in Flex-Flash
Wondering when ShareThis would actually provide a .swf file to be loaded in the fash file in stead of calling a JavaScript function to open the ShareThispop in the new window.
First of all we need to go to sharethis.com publisher section and customize your widget, you will get a javascript code by registering your email address. Here is javascript code what i got :-
script type="text/javascript" src="http://w.sharethis.com/button/sharethis.js#publisher=9f363e20-dc32-444d-a8c9-afd21615fd57&type=website&popup=true&embeds=true">
// ACTIONSCRIPT CODE
private function shareThis():void
{
var url:String = "http://www.vrathore.blogspot.com";
var title:String = "VARUN-RATHORE";
ExternalInterface.call("ShareThis", url, title);
}
Using a javascript code in the html file for opening the pop window
// JAVASCRIPT CODE
function ShareThis(url, title)
{
url = window.location;
var s = SHARETHIS.addEntry({
url: url,
title: title
}, {button:false,popup:true});
s.popup()
return false;
}
Cheers
Varun Rathore
Monday, July 13, 2009
Spring ActionScript Configuration in Flash/Flex/AIR application
Just as we use the applicationContext.xml in java application where we map the classes to the objecys in the context file and mapping the variables in the class files to the properties in the configuration file, we can use a simialr methodolgy in our flex application and get the changes to the variable by just changing in the configuration file , without building or refreshing the application.
Here is the code sniplet which is used to achive the following :-
// spring actionscript config
var applicationContext : FlexXMLApplicationContext =new FlexXMLApplicationContext("config.xml");
applicationContext .addEventListener(Event.COMPLETE, onApplicationContextComplete);
applicationContext.load();
protected function onApplicationContextComplete(event:Event):void
{
var appConfig : AppConfig = applicationContext.getObject("appConfig");
model.appConfig = appConfig;
resourceManager.localeChain = [appConfig.locale];
}
// HERE model.appConfig is the actionscript class which i have mapped to the object in my configuration file.
AppConfig.as file is as follows :-
package com.infoswell.model.global
{
[Bindable]
public class AppConfig
{
// src path used as root to locate images, etc.
public var srcPath:String = "";
// locale for menu config path
// note: curently resource bundle properties locale from project compile options
public var locale:String = "en_US";
public function AppConfig()
{
}
}
}
The config.xml is as follows:-
http://www.pranaframework.org/schema/objects/prana-objects-0.6.xsd">
The swc file which is used in the application can be created as follows :-
First download the source using a subversion client from the following url:
https://src.springframework.org/svn/se-springactionscript-as/
Step into the ant folder and execute “ant” to see the options. You can create a debug enabled version, a release, documentation. I created the debug enabled version with the following command. Of course you do have to have ant on your path. Do not forget to change the build.properties. You need to change the FLEX_HOME parameter as described in the readme file that comes with the sources.
ant compile-main-debug
The swc file is created in the antbuild/compile/main/swc folder.
Use the swc created in the project libs folder and use this extra ordinary feture to load configuration from outside.
Cheers
Varun
Labels:
Actionscript,
Adobe Flex,
Configuration,
Flash,
Spring
Ammaps in Flex
Here is way to implement ammaps in flex , i used swfloader to add the ammaps in my application as follows
var str : String = "assets/ammap.swf?settings_file=assets/ammap_settings.xml&data_file=assets/ammap_data.xml"
swLoader.load(str);
where i kept all the required files(swf/xml) in assets folders of my application.
Regards
Varun
Tuesday, July 7, 2009
Making Sharper Flex Application with Sharper Fonts
I am not a multi fan of using fonts in Flex , i had to put a very smaller font which was to be very sharp , Here is a example to add it , i tried it in my css but it can be done with setStyle Attribute too, here is the code sniplet and the result
Just define following in your css
@font-face
{
src: url("../font/kroe0555.ttf");
fontFamily: StandardFont;
flashType: true;
}
Application
{
color : #CCCCCC;
focus-thickness : 0.4;
font-size : 8;
font-grid-fit-type :subpixel;
font-sharpness : 1;
font-anti-alias-type: normal;
font-weight : normal;
}
Cheers
Varun
Saturday, July 4, 2009
A great Flex Map Component Mercator.swc
Mercator Flash/Flex Component from Manfred Weber is the coolest map componet i have seen with such a cool features, to zoom, get center, lattitude,longitude with additional markers and distance lines , i tried to create the map and within minutes i created a realy cool map with color and populating the map from a xml.The component contains all countries of the world and additional 8000 cities + the corresponding latitude and longitude
Just I think he has not updated the SWC file for the markers...... i think he will do it soon check out the demo at http://dev.dschini.org/mercator-swc/demos.php
Cheers
Varun
Tuesday, May 19, 2009
Security Error 2060:Security sandbox violation: ExternalInterface caller
Many a times we see such issues that we are not able to launch the application from html file and see the following error---
Security Error 2060: Security sandbox violation: ExternalInterface caller
file:///C:/Varun/myproject.swf
cannot access
file:///C:/Varun/myproject.html
So to avoid such a error you need to make some changes in html template html
In the HTML template make sure that the parameter 'allowscriptaccess' is set to 'always'
'allowScriptAccess','always',
param name="allowScriptAccess" value=“always"
if you are making a Object of swf from a flex application you can add the following parameter to the Object
swfObject.addParam('allowscriptaccess', 'always');
Cheers
Varun Rathore
Thursday, April 23, 2009
I am on Adobe Feed Now :)
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
Wednesday, April 22, 2009
Reducing Flex Application Size Drastically
Most of us while working on Flex applications get into a big problem of downloading time , as the application size increases it takes more time to get downloaded on the client machine, here are few things which i found to reduce the size of the application which makes the download time to get reduced drastically
The following three methods acn reduce the swf size by 70%
1. go to project properties->flex build path->library path -> framework linkage->select RSL from drop down press ok
2. go to project properties->flex complier->additional complier arguments
add "-debug=false" in the end -> press apply and ok.
3. Using a modular approach for application building, this can further reduce the application size.
Cheers
Varun Rathore
Tuesday, April 21, 2009
REQUEST HEADERS in FLEX using GET - POST Methods
We can modify Request Header in Flex under the certain circumstances only
var header:URLRequestHeader = new URLRequestHeader("newHeader", "newValue");
var request:URLRequest = new URLRequest("http://www.[vrathore.blogspot].com/");
request.data = new URLVariables("name=Varun+Rathore");
request.requestHeaders.push(header);
However, its possible to modify the headers on a POST request only.
request.method = URLRequestMethod.POST;
This should be taken care that we specifically give the request method as the Flash Player will convert POST requests into GET requests if the request is empty.
Other thing which should be kept in mind is to pass atleast one variable along with the request. Otherwise the headers will remain unchanged.
var variables:URLVariables = new URLVariables();
variables.name = "newValue";
request.data = variables;
Cheers
Varun Rathore
Wednesday, March 18, 2009
Stack Component in Flex /AIR / AS3
While working on a auditors project i had a scenario where i was to upload files on every object of the for loop and i was to upload the file on the server with a returning id from the previous action , so that the coming files will be uploaded as the child of the previous files(As in the tree structure). I had to create a Stack class which solved my problem. The function defined are pop(), push() and peek().
I will be adding Linked List Component shortly......
Here is the Code :-
a) Stack Class
package
{
public class Stack
{
private var first : Node;
public function isEmpty ():Boolean
{
return first == null;
}
public function push (data : Object):void
{
var oldFirst : Node = first;
first = new Node ();
first.data = data;
first.next = oldFirst;
}
public function pop () : Object
{
if (isEmpty ())
{
trace ("Error: \n\t Objects of type Stack must containt data before you attempt to pop");
return null;
}
var data:Object = first.data;
first = first.next;
return data;
}
public function peek () : Object
{
if (isEmpty ())
{
trace ("Error: \n\t Objects of type Stack must containt data before you attempt to peek");
return null;
}
return first.data;
}
}
}
b)
Node Class as the store house object used in Stack Class
package
{
public class Node
{
public function Node()
{
}
public var next : Node;
public var data : Object;
}
}
Cheers
Varun Rathore
I will be adding Linked List Component shortly......
Here is the Code :-
a) Stack Class
package
{
public class Stack
{
private var first : Node;
public function isEmpty ():Boolean
{
return first == null;
}
public function push (data : Object):void
{
var oldFirst : Node = first;
first = new Node ();
first.data = data;
first.next = oldFirst;
}
public function pop () : Object
{
if (isEmpty ())
{
trace ("Error: \n\t Objects of type Stack must containt data before you attempt to pop");
return null;
}
var data:Object = first.data;
first = first.next;
return data;
}
public function peek () : Object
{
if (isEmpty ())
{
trace ("Error: \n\t Objects of type Stack must containt data before you attempt to peek");
return null;
}
return first.data;
}
}
}
b)
Node Class as the store house object used in Stack Class
package
{
public class Node
{
public function Node()
{
}
public var next : Node;
public var data : Object;
}
}
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 Call Methods from a External SWF (Reflection in Flex )
While loading the swf from a external source , we are always wondering what all methods it may have , the developers have to seek help from the swf coders to get the methods and commnets for the methods which they have created, sometimes the developers provide the swf but fail to provide a meaningful API with which you can interact with the swf.
The Phenomenon of seeing the properties and methods of the class is know as 'reflection', to achieve this in flex we need to use the SWF loader to load the swf into the application as follows
var swfUrl : String = "www.varunrathore.co.cc";// path to your swf
var req: URLRequest = new URLRequest(swfUrl);
var loader : URLLoader = new URLLoader(req);
Now we will be using the class to get the remote objects .Once you have the class names it was a matter of the actual introspection to see the available methods. To do this you can use the getDefinition method of the ApplicationDomain class in Flex
var classUsed:Class = loader.contentLoaderInfo.applicationDomain.getDefinition(className) as Class;
Here we get a XMl with all the methods and variables ...
var remoteSWF:Object = loader.content as Object;
Just call the method you wish to call from the SWF
remoteSWF.methodToBeCalled(); // calling the desired method with its name
Cheers
Varun Rathore
The Phenomenon of seeing the properties and methods of the class is know as 'reflection', to achieve this in flex we need to use the SWF loader to load the swf into the application as follows
var swfUrl : String = "www.varunrathore.co.cc";// path to your swf
var req: URLRequest = new URLRequest(swfUrl);
var loader : URLLoader = new URLLoader(req);
Now we will be using the class to get the remote objects .Once you have the class names it was a matter of the actual introspection to see the available methods. To do this you can use the getDefinition method of the ApplicationDomain class in Flex
var classUsed:Class = loader.contentLoaderInfo.applicationDomain.getDefinition(className) as Class;
Here we get a XMl with all the methods and variables ...
var remoteSWF:Object = loader.content as Object;
Just call the method you wish to call from the SWF
remoteSWF.methodToBeCalled(); // calling the desired method with its name
Cheers
Varun Rathore
Labels:
AIR,
Flash,
Methods from External SWF,
Reflection in Flex
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
Sunday, February 8, 2009
Debugging the Flex / Flash / AIR from outside the flex builder
Arthropod is an external Debug trace window for Flash/Flex/AIR. Drop a simple class into your project and it will accept logging from the application/swf.
You can download the sample application from :-
http://arthropod.stopp.se/
Cheers Varun Rathore
Labels:
Adobe Flex Apllication Framework,
AIR,
Arthropod,
debug,
Flash
Subscribe to:
Posts (Atom)
About Me
- vrathore
- noida, dehli, India