July 18, 2007
The sharedObject class is used to store and read data on user’s computer or on a server. Local shared objects can be used as browser cookies. You can also store custome object into the sharedObject, this problem I got resolved with the help of google flex_india group. Thanks for their quick help on this matter.
Follow the thread for discuss issue about storing the custome object in the sharedObject
http://groups.google.com/group/flex_india/browse_thread/thread/92362f8ee4df6c1a/23d620ed37d81503
You can create the local shared object with following syntax:
//Create “testLocalSharedObject”
var testSO:SharedObject = SharedObject.getLocal(”testLocalSharedObject”);
To store any data into the sharedObject use data property.
//This will store the myname value, the same can be retrieved from it.
testSO.data.myname =”vijay khambalkar”;
//To store the this data into the local file, use flush method. This method writes the content immediately to the local file.
testSO.flush();
//To destroy object from the local file, use clear method. This method clears all the data from the sharedObject and deletes the sharedObject from the disk
testSO.clear()
Leave a Comment » |
Flex |
Permalink
Posted by Vijay Khambalkar
July 12, 2007
I know there are such tools available but building one is nice experience and then using it
We are using cairngorm framework in our project. I found generating the cairngorm module classes is repeatative and time consuming. To make my life easier, I written a small utility with PHP which allows me to generate this classes by specifying the package and module name. This one I had done for my project. This can be utilize to generate module classes for any project. Generated files needs very few modification that may differ from the personal preferences.
It help me saving the lots of copy paste time.
Click here to generate the cairngorm classes.
suggest me if anyway I can make it better.
Leave a Comment » |
Cairngorm, Flex |
Permalink
Posted by Vijay Khambalkar
June 2, 2007
This is the most common question asked in every interview for the database. As I am more familiar with mysql , Its so simple with the following query
SELECT * FROM employee ORDER BY salary DESC LIMIT 2,1
This query will bring the second highest salary from the table employee.
But Query should work with every database so here is the correct query and its details explaination which will bring specified highest salary from the table
select * from employee emp where 3 = (select count(*) from employee emp where a.salary <= b.salary) ;
I made a details comparision set about the operations of query.
Table employee is having the 6 record with salary ranging from 1000 to 6000
Query:
====
SELECT * FROM employee emp WHERE 3 = (SELECT COUNT(*) FROM employee emp WHERE a.salary <= b.salary) ;
Detail Record Condition Check
=====================
1)a <= b
1000<=1000
1000<=2000
1000<=3000
1000<=4000
1000<=5000
1000<=6000
[count=6]
2)a <= b
2000<=1000
2000<=2000
2000<=3000
2000<=4000
2000<=5000
2000<=6000
[count=5]
3)a <= b
3000<=1000
3000<=2000
3000<=3000
3000<=4000
3000<=5000
3000<=6000
[count=4]
4)a <= b
4000<=1000
4000<=2000
4000<=3000
4000<=4000
4000<=5000
4000<=6000
[count=3]
5)a <= b
5000<=1000
5000<=2000
5000<=3000
5000<=4000
5000<=5000
5000<=6000
[count=2]
6)a <= b
6000<=1000
6000<=2000
6000<=3000
6000<=4000
6000<=5000
6000<=6000
[count=1]
Result : 4000 as its count is matching the condition ie. 3
4 Comments |
Database |
Permalink
Posted by Vijay Khambalkar
April 20, 2007
After a very long time I got time to code something. I thought what to write, various technology which one to go with PHP, Coldfusion, flex, javascript. After thinking for a min, I started with Flex. What to create? Autosuggest TextBox!.
So I created a autosuggest textbox, I quickly thought what all I need
Textbox, Allow user input.
Listbox, To hold the list the matched list from the textbox.
Tweening, Which will give a feel of panel movement comig out of the textbox with matched value.
Algorithm
=========
1.Track keyUp event on the textbox which in turn filter the main array which is holding the entire values.
2.Apply regExp which will hold the format to look for.
eg. typing A, should give me all the values starting from the ‘A’ character.
3.test the regular expression against the main array by looping over each value.
4.If test successful then hold these value into the new array which in turn binded with the list box.
5.Animate the list box with resize event if filteredArray has more values into it from the step 4.
Notes
=====
We can supply the list to main array from database, or keep it hardcoded.
You are ready with your autosuggest box.
Click here to view the Working sample
Happy coding
5 Comments |
Flex |
Permalink
Posted by Vijay Khambalkar
April 13, 2007
We were struggling from last several days about how to restrict some special character entry into TextInput field. We tried applying our own logic for implementing this functionality by tracking the keydown event and checking the ascill/regular expression but did not succeeded into this.
Finally I thought to look into the help and suprisingly we find that TextInput has restrict property to which we can supply the range of character that the TextInput should accept.
<mx:TextInput x=”104″ y=”151″ width=”190″ id=”charInput” restrict=”a-z A-Z”/>
Complex problem always has very simple solution
1 Comment |
Flex |
Permalink
Posted by Vijay Khambalkar
March 5, 2007
You can scroll div with javascript. You need to have one mainContainer which will contain the child for it. eg.
I will have mainArea div with child div myReport.
<div id=”mainArea”>
<div id=”myReport”>
</div>
</div>
You need to fixed the height for the mainArea div with style
<div id=”mainArea” style=”height:400px;overflow:auto”>
<div id=”myReport”>
</div>
</div>
Now your div can scroll, You now need to write one line code in any javascript function
function scrollMainArea()
{
document.getElementById(”mainArea”).scrollTop = 0;
}
This will move your myReport div to show the top portion of your division.
I am using this codes in my chat application to scroll the messages automatically.
Leave a Comment » |
AJAX, DHTML, HTML, Javascript |
Permalink
Posted by Vijay Khambalkar
February 28, 2007
I am very excited today, I have finally my chat app ready and working. I have shown my application to all my collegues they throughly enjoyed it.
Soon I will be writing the article about the entire development of this chat application.
PHP and Power of Javascript make this application possible for me. UI is not that good, the application is about functionality. I will work on UI someday Later.
I have created three user for the test.
user:tom, password:tom
user:dick, password:dick
user:harry, password:harry
After logging inside you will find a list of User on the left panel, click on the user and start sending messages to them.
So lets have a real feel of the application. Click here to start
1 Comment |
AJAX, DHTML, HTML, Javascript, php |
Permalink
Posted by Vijay Khambalkar
February 16, 2007
After trying for some half an hour I finally solved the problem of posting values from flash to PHP. I used LoadVars Object for this purpose. LoadVars object is used for transffering values between Flash and Server. It has various properties, methods and events which also helps in determining the successful data loading and communication between server.
In flash you can create LoadVars in following way
var loadVarObj = new LoadVars();
loadVarObj.firstName = “Vijay”;
loadVarObj.lastName = “Khambalkar”;
loadVarObj.skills = “PHP, ASP, Coldfusion, Flex, Javascript”;
loadVarObj.send(URL,loadVarObj,”POST”);
This is how your typical loadvars code will look like in case when you need to post values to server side. I found it interesting and thought to share.
One more thing I noticed about the loadVarObj documentation
public send(url:String, target:String, [method:String]) : Boolean
But this part didnt work, you need to event pass object itself as a second parameter. Only then your values is get posted. This is problem where I stuck initially.
Hope this much information will help you.
Leave a Comment » |
Flash, Miscellaneous |
Permalink
Posted by Vijay Khambalkar
February 15, 2007
We are developing a Flex Application with PHP as a middleware. Flex Httpservice component we are using to communicate with the PHP. We have several developers who are doing separate modules. They doing both Flex as well as PHP code. I thought its not proper and need to have a solution where our code will reside on the single url.
How we achieve this?
I thought of developing a architecture which will take a className and methodName from URL and call methods and the supplied object dynamically.
eg. http://localhost/PHP/Flex/index.php?className=MyClass&methodName=getUser
This above url calls getUser method on MyClass Object. I used call_user_method function of PHP which allows me to achieve this.
One trick for this part is also instantiating the object dynamically. I coded like this
function getObject($class)
{
static $instance ;
if(!isset($instance))
{
$instance =& new $class;
}
return $instance;
}
getObject method accepts className and checks wheather that object exists or not. If object is not set then it creates a object and just return it.
It was a great experience while building something which allows my developers to simplify their code integration. Now every developers is working on their respective classes and using this method.
Cheers
5 Comments |
Flex, Frameworks, php |
Permalink
Posted by Vijay Khambalkar
February 12, 2007
Many times our client report that you had debug string into an application. This debug string could be printed array, values echo from database, database queries and many other things. Even in flex/javascript application client report that their are unnecessary alert that is coming in between. These are not actually a errors these are the development level debug messages which we mistaken unable to comment.
What is the solution to this common problem?
The day I realized that I can control this, I started using the concept. Thanks to my previous boss Kaushik Chatterjee who bring this forward for me. Concept is fairly very simple. Define a global level debug variable with default value 0. Following code will explain what I am trying to convince.
<script language=”javascript”>
var debug = 0;
function debugMessages(message)
{
if(debug)alert(message);
}
function getUserName()
{
debugMessages(”I am in this function”);
}
</script>
Above code is pretty simple to understand the concept.
First line of code defines debug variable with value 0 i.e 0 disable/ 1 enable
function debugMessages is responsible for all debugging messages. All messages will route through this function. Inside this its checking whats the value of debug variable. If its true then show alert message or simply discard it. So you can kept the value of debug variable always true as and when working on the development version. At production level simply turn off this variable and there will be no extra debug alert/message in the application.
Applying smart use of this technique, we can achieve alot and stop client from complaining these silly points which we really dont mean too. Atleast it will remove one bug from your system as entered by client as a bug.
Leave a Comment » |
Javascript, Miscellaneous |
Permalink
Posted by Vijay Khambalkar