3G iPhone Price slahed to $199

June 11, 2008 at 12:57 pm (news)

3G iPhone

It looks awesome, can talk aboutr it for long long time?

Permalink Leave a Comment

ActionScript 3 optimization techniques ::

June 11, 2008 at 8:28 am (Air, Flex, flash)

follow the link below for PDF

http://je2050.de/files/misc/as3opt.pdf

Permalink Leave a Comment

Filter ArrayCollection on the basis of dates;

June 10, 2008 at 7:03 am (Flex) (, , )

Function to filter the ArrayCollention on the basis of start and end date range in the respective DateField

Set the following filter function to the Arraycollection having an object with date (having value as ‘date’ as type = Date) as attribute.

I.E. Arraycollection.filterFunction = dateFilter;

// Filter function
public function dateFilter(item:Object):Boolean
{
if ((dateStart.selectedDate == null
|| dateStart.selectedDate <= item.date)
&& (dateEnd.selectedDate == null
|| dateEnd.selectedDate >= item.date))
{
return true;
}

return false;
}

Use Arraycollection.refresh() to excute the filterfunction;

Hope this helps you.

Permalink Leave a Comment

Loading and Running JavaScript function at runtime with ExternalInterface.

June 5, 2008 at 9:28 am (Air, Flex, flash) (, , )

The only mandatory thing is the swf should run in the browsers that support NPRuntime.
Which almost all browsers support.

Please find the xml and AS3 Code below.

:: Download Sample

::XML

<?xml version=”1.0″ ?>
<data>
<createNamespace_js>
<script>
<![CDATA[
function(){
// Creates a global namespace called
// "Dojo" if one doesn't already exist.
// Here's one way to do this *safely*.
// If Dojo is a valid object of any type,
// including objects and functions, it will
// be left alone. If it doesn't exist, an
// exception is thrown, trapped, and
// "Dojo" is globally created.
try {
Dojo
}catch(e){
Dojo = new Object();
}
}
]]>
</script>
</createNamespace_js>
<addFunction_js>
<script>
<![CDATA[
function(){
var snafu = 'You said';
var exists = false;
// "Dojo" is a JavaScript library object
// that was created by another script,
// and exists globally.
// Just to be safe, though, we make sure
// it exists before writing to it, otherwise
// an exception is thrown.
try {
Dojo;
exists = true;
} catch(e) {
exists = false;
}

if(exists){
Dojo.myVar = 'foo';
Dojo.myFunction = function (str) {
alert(snafu + ":" + str);
}
};
}
]]>
</script>

</addFunction_js>
<callFunction_js>
<script>
<![CDATA[
function(txt, txt2){
txt = txt + " World, " + txt2;
Dojo.myFunction(txt);
}
]]>
</script>
</callFunction_js>
</data>

:: AS3

import flash.external.ExternalInterface;

var createNamespace_js:XML ;
var addFunction_js :XML ;;
var callFunction_js :XML ;;
var functionArray:Array = ["createNamespace_js","addFunction_js","callFunction_js"];

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, onLoadXML);

function callFunctions():void
{
// calling virtual function to create global object DOjo;
ExternalInterface.call(createNamespace_js);
// calling virtual function to add function and var to global object DOjo;
ExternalInterface.call(addFunction_js);
// calling Dojo.myFunction with 1 parameter;
ExternalInterface.call(“Dojo.myFunction”, “First call to DOjo.myFunction ;-) “);
// calling virtual function which internally alls the Dojo.myFunction ; with 2 parameters
ExternalInterface.call(callFunction_js, “Hello”, “from virtual function ” );
}

function onLoadXML(ev:Event){
try{
//Convert the downloaded text into an XML
var myXML:XML = new XML(ev.target.data)
var list:XMLList = myXML.children();
for(var i=0; i<list.length(); i++){
var temp:XML = new XML(list[i]);
for( var j in functionArray){
if(functionArray[j] == temp.name()){
this[functionArray[j]] = new XML(temp.script);
}
}
}
} catch (e:TypeError){
trace(“Could not parse the XML”)
trace(e.message)
}
callFunctions();
}
loader.load(new URLRequest(“sample.xml”));

stop()

Permalink Leave a Comment

AS3 Function for Flash to Convert Datagrid data To CSV format ::

June 4, 2008 at 11:16 am (Flex, flash) (, )

function exportCSV(dg:DataGrid, csvSeparator:String=”\t”, lineSeparator:String=”\n”):String {
var data:String = “”;
var columns:Array = dg.columns;
var columnCount:int = columns.length;
var column:DataGridColumn;
var header:String = “”;
var headerGenerated:Boolean = false;
var dataProvider:DataProvider = dg.dataProvider;
var rowCount:int = dataProvider.length;
var dp:Object = null;
var j:int = 0;
//loop through rows
while (j<rowCount) {
var obj:Object = null;
obj = j;
//loop through all columns for the row
for (var k:int = 0; k < columnCount; k++) {
column = columns[k];
//Exclude column data which is invisible (hidden)
if (!column.visible) {
continue;
}

data += “\”"+ column.itemToLabel(dg.getItemAt(j))+ “\”";
trace(column.itemToLabel(dg.getItemAt(j))+”—-”+ data)
if (k < (columnCount -1)) {
data += csvSeparator;
}
//generate header of CSV, only if it’s not genereted yet
if (!headerGenerated) {
header += “\”" + column.headerText + “\”";
if (k < columnCount – 1) {
header += csvSeparator;
}
}
}
headerGenerated = true;
if (j < (rowCount – 1)) {
data += lineSeparator;
}
j++;
//cursor.moveNext();
}
//set references to null:
dataProvider = null;
columns = null;
column = null;
return (header + “\r\n” + data);
}

for use in flex you can look at :: http://www.abdulqabiz.com/files/DataGridDataExporter/DataGridCSVExportExample.swf

Permalink Leave a Comment