Conditional Operator.

June 30, 2008

The syntax in Flex for conditional operator is same as that of the other technologies like c,java,.., for newbies the syntax is here.

Syntax:

Condition?(condition=true)statement:condition=false)statement.

Or

Condition?true satement:false statement.

It is nothing but a if.. else.. block in one single line.

Example in Flex:

Private function conopeExample():void

{

txtname.text=4>1?”Kumar”:”gandhi”;

}

<mx:TextInput id=”txtname” />

<mx:Button id=”btn” click=” conopeExample” />

The conditional operator is so simple that we programmers ignore that , or not interested in that. But it’s so simple that a good programmer will use to reduce the lines of code in the Application. Finally it’s synonym of our if .. else .. statements.

Enjoy the Post.


Reading data in to ComboBox from PHP page. (corrections)

June 21, 2008

Actually I made this post long back but the post had some corrections so iam making those here. It was actually suggested by a a person called John that he didn’t get the post clearly and insisted to make another one for newbies. So I decided to make a clear one here with complete code.

The post missed one line as it was pointed out in the comment , the line is to send the HttpService you are using to get the Data.

Flex code :

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute

creationComplete=”projectsSrv.send();”>

<mx:HTTPService

id=”projectsSrv

url=”new.xml

useProxy=”false” method=”POST>

</mx:HTTPService>

<mx:ComboBox

id=”cmb1” x=”152” y=”53

dataProvider=”{projectsSrv.lastResult.records.record}

labelField=”data></mx:ComboBox>

</mx:Application>

PHP code or XML file code:

<records>

<record data=”1″ label=”Corco”/>

<record data=”5″ label=”Shell Crop Protection”/>

<record data=”7″ label=”Olin McIntosh”/>

<record data=”9″ label=”Crab Orchard”/>

<record data=”10″ label=”Shell Oil Del Amo”/>

<record data=”11″ label=”AIG South Jersey Gas”/>

<record data=”12″ label=”Husch &amp; Eppenberger Litigation-New York”/>

<record data=”22″ label=”Shell Sturbridge”/><record data=”24″ label=”Shell Southington”/>

<record data=”26″ label=”Olin Personal Injury”/>

</records>

You can send data in this format or get it from the XML file, here its from XML file “new.xml”.you can even echo these lines in PHP and a file as new.php.

As you can see the difference here, from that post is, here iam using the line creationComplete=”projectsSrv.send();” in the Application tag to send the service and read the data.

Now it will work fine and comments are welcome !


Giving title to your Flex App’s.

June 17, 2008

Usually we give title to our page from the Title Tag in the Html file but there is another way to do this from the Flex App.

There’s a property called pageTitle in the Application Tag, and there you can mention it. Then it appears on Browser Title Bar as required. Cool isn’t it !

Code Example :

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”

creationComplete=”init()” pageTitle=”Kumar Gandhi Page !”>

</mx:Application>

Enjoy the code !


Logical thinking!

June 6, 2008

I came to know the meaning of the word logical few years back but it is the word that should be thought when you start learning words, I mean at the point you start with words.

What is really logical? And what logic means? . If Thomas Alva Edison doesn’t know what is logical thinking then he couldn’t have made a bulb and can you imagine our world without it. That is the power of the word logical.

So

What is really logical?

A problem with two sides is logical and if problem takes a solution the its true logic otherwise its false logic. We need to make a solution so that our logic is true in order to make the logic true we need to figure out the solution with proper logic. Here proper logic means thinking in the right sense and this thinking start with right sense when we really analyze the problem and the steps in achieving it.

What logic means?

If(problem!=solution) then logic is false

Else if(problem==solution) then logic is true

Else logic is null

The above statements tell the logic in terms of problem and solution.

This can also be made as “Find a way to find the solution or Think till you find the right solution”

If the first way doesn’t lead you to the solution then find another logic to find the way or think to find the way for the logic.

This can also be made like this “think till you find the logic is true” , true logic which always lead you to the solution.

So

logic always resonates with TRUE and FALSE, existence and nonexistence of the solution.

Enjoy the post ! :-)


Incremental compilation in Flex.

June 4, 2008

I collected some information in Incremental Compilation and iam giving it here.

Incremental compilation means that the compiler inspects your code, determines which parts of the application are affected by your changes, and only recompiles the newer classes and assets (section of bytecode). These sections of bytecode are also referred to as compilation units.

Incremental compilation can help reduce compile time on small applications, but you achieve the biggest gains on larger applications. The default value of the incremental compiler option is true for the Flex Builder application compiler. For the mxmlc command-line compiler, the default is false.

You enable incremental compilation by setting the incremental option to true, as the following example shows: mxmlc -incremental=true MyApp.mxml

As part of the incremental compilation process, the compiler generates
a cache file that lists the compilation units of your application and information on your
application’s structure. This file is located in the same directory as the file that you are
compiling. For example, if my application is called Example.mxml, the cache file is called Example_n.cache, where n represents a checksum generated by the compiler based on compiler configuration. This file helps the compiler determine which parts of your application must be recompiled. One way to force a complete recompile is to delete the cache file from the
directory.

Hope you got the importance of it !.Enjoy the Post.