Wednesday 17 December 2014

THis is the veryuseful link for the bower installtion

http://blog.teamtreehouse.com/getting-started-bower

http://stackoverflow.com/questions/20666989/bower-enogit-git-is-not-installed-or-not-in-the-path

https://www.npmjs.com/package/jquery

Monday 15 October 2012

AS3 – internal class, public method


package testPackage {
   public class PublicClass {
 
      public function returnInternalClassRef():InternalClass {
         return new InternalClass();
      }
   }
}

package testPackage {
   internal class InternalClass {
 
      public function doSomething():void {
         trace("InternalClass did something!!");
      }
 
      internal function doSomethingInternally():void {
         trace("InternalClass did something internally!!");
      }
   }
}

package {
 
   import flash.display.Sprite;
   import testPackage.PublicClass;
 
   public class InternalTest extends Sprite {
      public function InternalTest() {
 
         var publicClass:PublicClass = new PublicClass();
         var ref:Object = publicClass.returnInternalClassRef();
         ref.doSomething();
         ref.doSomethingInternally();
      }
   }
}



Now make a guess, what happens?
Well, it’s not too hard to figure out, right? But interesting to remember anyway. The call for doSomething() works, whereas the call for doSomethingInternally() ends up in an exception. So if you define an internal class, you can still pass its reference outside its package (loosing the type obviously). Any public methods can be called then, but internal methods not. Makes sense, does it? I was just thinking about it, because i asked myself, why one would declare a class internal, but still have public methods.
So it only makes sense, if you want to pass it around as either an untyped reference or as a casted interface implementation. Means, you could have an interface outside the package and the internal class implements it. Then within the package you could use the class by its direct class type and outside you would use it by its interface type.

Sunday 29 July 2012

Introducing Flash Player 11.4/AIR 3.4 beta


Finally, after some long waiting and nagging for it, Adobe has released Flash Player 11.4 and AIR 3.4 beta today. This release has a lot of awesomeness to it. Let’s look at what’s inside.
First of all, there is the concept of multi threading that is being introduced in ActionScript. For those of you who don’t know what multi threading is, it is a system where you can run multiple tasks at the same time and they all get a separate thread assigned, which means they get CPU time all together. Very simply put, if you have a quad-core CPU and 4 tasks to run simultaneous, each task will get a full core to its disposal.
In Actionscript, these threads are called Actionscript workers. Thibault Imbert hassome great basic examples that you can download and explore for yourself.
Although this system is mainly conceived for gaming purposes, all developers can use this to their advantage, be it for heavy duty batch processing in the background or optimization of multiple user access. As an enterprise developer, I’m really happy with this, because this will increase the performance of some of the applications I’m writing.
There is however some sad news as well. To be able to fully take advantage of this new feature you’ll need full support in Flash Builder (for debugging), which is not there yet. But it will be here soon. It will become public in August, so they promise.
Secondly, there is now camera support for StageVideo, using the attachCamera() method. This makes using the camera in your application uses very little precious CPU time, because it will now work on the GPU.
Next up is the image processing from the camera. If you wanted to use the image from the camera to work on, up until now you needed to work withBitmapData.draw() to get those pixels. That meant a lot of development overhead in creating additional objects just to get the camera image. Now, you can simply use these 3 new methods:
  • drawToBitmapData(destination:BitmapData)
  • copyToByteArray(rect:Rectangle, destination:ByteArray)
  • copyToVector(rect:Rectangle, destination:Vector)

This makes it a lot easier to work with the camera data, because you can simply create the necessary buffer to store the data, call these methods and don’t have to worry about the rest.
Another major upgrade for this release of AIR3.4 beta is the fact that it now supports debug deployments directly onto iOS devices. Up until now, when you wanted to test an application on iOS devices, it was quite the hassle to get there. You had to use iTunes or the iPhone configuration utility. But now the ADT supports direct launch of debug apps on iOS devices. Of course, that means that you still will have to wait on the Flash Builder update to run it from within the tool itself.
There are a lot more feature updates as well, but for myself, these are the major ones. And I can’t wait to play around with it. To download the Flash Player 11.4 and AIR 3.4 beta versions, just go to http://labs.adobe.com.

Friday 27 July 2012

Runtime CheckBox in Datagrid

DataGridMCSSExample.mxml



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import mx.controls.DataGrid;
import flash.utils.getDefinitionByName;

private var o:DataGrid = null;
private var mcssDataGridComponent:MCSSDataGridComponent;

private function init():void
{
var urlRequest:URLRequest = new URLRequest("template.xml");
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, onXMLLoadComplete);
urlLoader.load(urlRequest);
}

private function onXMLLoadComplete(e:Event):void
{
var dataXML:XML = XML(e.currentTarget.data);
this.parseXML(dataXML.children(),this);
}

private function parseXML(data:XMLList, parent:*):void
{
var iCount:int = 0;
var iCountLen:int = data.length();
for(iCount = 0; iCount < iCountLen; ++iCount)
{
var classRef:String = data[iCount].@classRef;
var oClass:Class = getDefinitionByName(classRef) as Class;
var child:ICustomComponent = new oClass();
child.parseXML(data.children());
parent.addChild(child);
}
}

]]>
</mx:Script>
<!--local:MCSSDataGridComponent dataProvider="{dgArrayCollection}" />-->
</mx:Application>





CustomCheckboxItemRenderer.as


package
{
import flash.events.Event;
import flash.events.MouseEvent;

import mx.controls.CheckBox;
import mx.controls.dataGridClasses.DataGridListData;
import mx.events.ListEvent;


public class CustomCheckboxItemRenderer extends CheckBox 
{
private var value:XML;
override public function set data(value:Object):void
    {
    this.value = XML(value);
    var passedData:String = value[DataGridListData(listData).dataField];
    this.selected = (passedData.toLowerCase() == "true")?true:false;
   
}  

override protected function clickHandler(event:MouseEvent):void
{
super.clickHandler(event);
this.value[DataGridListData(listData).dataField] = this.selected;
this.listData.owner.dispatchEvent(new ListEvent(ListEvent.CHANGE));
}

}
}







ICustomComponent.as


package
{
import mx.collections.ArrayCollection;

public interface ICustomComponent
{
function parseXML(data:XMLList):void;
}
}









MCSSDataGridComponent.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="50%" height="50%" implements="ICustomComponent">
<mx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridColumn;
import flash.utils.getDefinitionByName;
import mx.collections.ArrayCollection;
import mx.controls.Label;
import mx.controls.RadioButton;


private var o:Label = null;
private var c:CustomCheckboxItemRenderer = null;
private var r:RadioButton = null
private var arrColumns:Array = new Array();

[Bindable]
private var dataProvider:XMLList;

public function setDataProvider(dataProvider:XML):void
{
this.dataProvider = dataProvider.children();
}

public function parseXML(data:XMLList):void
{
var iCount:int = 0;
var iCountLen:int = data.length();
var id:String = "";
for(iCount = 0; iCount < iCountLen; ++iCount)
{
id = data[iCount].@id;
if(id == "dataProvider")
{
setDataProvider(XML(data[iCount]));
}
else
{
var itemRenderer:String = data[iCount].@itemRenderer;

var fieldName:String = data[iCount].@id;
var headerText:String = fieldName.charAt(0).toUpperCase() + fieldName.substr(1);

var headerText:String = headerText;//data[iCount].@id;
var dataField:String = data[iCount].@id;
var dataGridColumn:DataGridColumn = new DataGridColumn();
var oClass:Class = getDefinitionByName(itemRenderer) as Class;
dataGridColumn.itemRenderer = new ClassFactory(oClass); 
dataGridColumn.headerText = headerText;
dataGridColumn.dataField = dataField;

var customLabelFunction:Function = this["covertColumnDataTo"+String(data[iCount].@type)] as Function;
dataGridColumn.labelFunction = customLabelFunction;
arrColumns.push(dataGridColumn);
}
}
}

private function covertColumnDataToString(item:Object, column:DataGridColumn):String
{
var value:String = XML(item)[column.dataField].toString();
       return value;


private function covertColumnDataToBoolean(item:Object, column:DataGridColumn):String
{
var value:String = XML(item)[column.dataField].toString();
       return value;


private function onCreationCompleteHandler():void
{
myDataGrid.columns = arrColumns;
myDataGrid.dataProvider = this.dataProvider;
}

private function onChangeHandler():void
{
trace("onChangeHandler"+dataProvider.toXMLString())
}

]]>
</mx:Script>
<mx:DataGrid id="myDataGrid" creationComplete="onCreationCompleteHandler()" change="onChangeHandler()">  
</mx:DataGrid>
</mx:Canvas>









template.xml


<data>
<component id="myDataGrid" classRef="MCSSDataGridComponent">
<component id="question" itemRenderer="mx.controls.Label" type="String" dataField="question" classRef="mx.controls.Label"/>
<component id="option1" itemRenderer="CustomCheckboxItemRenderer" type="Boolean" dataField="option1" classRef="mx.controls.dataGridClasses.DataGridColumn"/>
<component id="option2" itemRenderer="CustomCheckboxItemRenderer" type="Boolean" dataField="option2" classRef="mx.controls.dataGridClasses.DataGridColumn"/>
<component id="option3" itemRenderer="CustomCheckboxItemRenderer" type="Boolean" dataField="option3" classRef="mx.controls.dataGridClasses.DataGridColumn"/>
<component id="option4" itemRenderer="CustomCheckboxItemRenderer" type="Boolean" dataField="option4" classRef="mx.controls.dataGridClasses.DataGridColumn"/>
<component id="dataProvider">
<node id="question1">
<question>Question 1</question>
<option1>true</option1>
<option2>true</option2>
<option3>true</option3>
<option4>true</option4>
</node>
<node id="question2">
<question>Question 2</question>
<option1>false</option1>
<option2>true</option2>
<option3>true</option3>
<option4>true</option4>

</node>
</component>
</component>
</data>







Custom Event Example

MyComponent.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" height="100%" width="100%">
<mx:Metadata>
    [Event( name="addProduct", type="AddProductEvent") ]
    </mx:Metadata>
<mx:Script>
<![CDATA[


private function onClikHanlder(e:MouseEvent):void
{
var myEventObj:AddProductEvent = new AddProductEvent( "addProduct", {id:1 ,fistName:"Amit" ,lastName :"Patel"} );
dispatchEvent( myEventObj );
}
]]>
</mx:Script>
<mx:Button id="btn" click="onClikHanlder(event)" label="Click"/>
</mx:Canvas>



AddProductEvent.as
package{

   import flash.events.Event;

   public class AddProductEvent extends Event {

      public var obj:Object;

      public function AddProductEvent( type:String, value:Object ) {

         super( type );
         this.obj = value;

      }

      override public function clone():Event {
         return new AddProductEvent( type, obj );
      }

   }
}



<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  xmlns:local="*">

  <mx:Script>
  <![CDATA[
  import mx.controls.dataGridClasses.DataGridColumn;
  import mx.controls.DataGrid;
  import mx.controls.Alert;
  import AddProductEvent;

private function onAddProduct( event:AddProductEvent):void {

var dg:DataGrid = new DataGrid();
dg.dataProvider = event.obj;
addChild(dg);
}
  ]]>
  </mx:Script>

    <local:MyComponent id="myComponent" addProduct="onAddProduct( event );"/>
   
</mx:Application>


Monday 31 October 2011

Aodbe Air

Adobe Air is used into the Desktop Application Too









Simple Dispatch Event

eve = new ItemClickEvent("IMG_MOUSE_OVER",true);
            eve.item = img.source;
            dispatchEvent(eve);