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 :-
// 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; }
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";
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.
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; }
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
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.
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;
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; } }