RICH – RIA

Icon

RIA Blog

Drag and drop files in AIR add them to data grid.

Yeah , I know its very simple..,but a friend asked me to do it for him.. so as well putting it here too…

(I am too lazy to specially write examples for blog :) :) )

Not much to explain in code.. very simple use of native methods of DragManager in AIR  and Datagrid

here it is …

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:WindowedApplication
creationComplete=”onCreationComplete()”
xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>

<mx:Script >
import flash.desktop.ClipboardFormats;
import flash.events.NativeDragEvent;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;

import mx.managers.DragManager;

//called when app has initialized and is about to display
private function onCreationComplete():void
{
//register for the drag enter event
addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, onDragIn);

//register for the drag drop event
addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onDragDrop);
}

//called when the user drags an item into the component area
private function onDragIn(e:NativeDragEvent):void
{
//check and see if files are being drug in
if(e.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT))
{
var files:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
DragManager.acceptDragDrop(this);

}
}

//called when the user drops an item over the component
private function onDragDrop(e:NativeDragEvent):void
{
//get the array of files being drug into the app
var arr:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
uploadGrid.dataProvider = arr;

}

</mx:Script>
<mx:VBox x=”70″ y=”10″ width=”355″>
<mx:DataGrid id=”uploadGrid” height=”130″  width=”100%” >

<mx:columns>

<mx:DataGridColumn width=”150″  dataField=”name”/>
<mx:DataGridColumn  width=”150″ dataField=”size” />

</mx:columns>

</mx:DataGrid>
<mx:Text text=”Drag a Text File into the Application”
width=”233″ height=”148″ top=”11″ left=”10″/>
</mx:VBox>

</mx:WindowedApplication>

Filed under: RIA/ FLEX/ AS , ,

Getting weborb to work with rails 2.2 (const_missing’: uninitialized constant Rails::Plugin::Dependencies)

I am a Flex developer… but trying to get my hands dirty with rails.. my friend Mayur did a awesome job at integrating.. rails with flex using weborb , and she used .. danny paterson’s remoting component for connecting to backend.. she is actively usign that into her projects since year and half . looking at that I also got excited about chemistry called rails and flex.

But with rails 2.2 it took me forever to get the samples working… I could have used net connection object (as in danny’s code) and also could have written some controller and could have got my flex app working..but after installing weborb as plugin , my mongrel refused to start properly and i was getting this error :

c:/ruby/lib/ruby/gems/1.8/gems/actives
upport-2.2.2/lib/active_support/dependencies.rb:105:in `const_missing’: uninitia
lized constant Rails::Plugin::Dependencies (NameError)
from F:/trails/m2/vendor/plugins/weborb/init.rb:30:in `evaluate_init_rb

Dont know why?? i tried many things.. after long search on google, debug statements in ruby files….another friend came to rescue and this is the solution :

write this in init.rb in /vendor/plugins/weborb/init.rb

ActiveSupport::Dependencies.mechanism = :load

in place of

Dependencies.mechanism = :load

yeah now.. restart mongrel ..yes it works.. reason : dependencies are part of ActiveSupport now :) ok.. need to drill down it more.. but for now..this lets my mongrel works..

But still , when I tried to run , examples/main.html that comes with weborb.. i could not get thru .. and I was getting this error :

This application has failed to start because LIBMYSQL.dll was not found.

reason: mysql gem is not included in rails 2.2 .. okay no need to panic here.. solution is easy

do this:
[1] gem install mysql
[2] you will see like error syntac but dont pay attention to it
[3] find LIBMYSQL.DLL from your mysql/bin folder in your mysql folder
not ruby folder.
[4] copy & paste that file to ruby/bin
[5] restart your server or console, if you are already run it.

and now run your examples/main.html..
yeah thats right.. it works

Now , I am all set to go :)

Enjoy flexing rails

Filed under: RIA/ FLEX/ AS

Multiple sets of visual children have been specified for this componen

This is the error that we get when we try to inherit our mxml component.. ie trying to templatise it..

so what does templatising mxml component  mean ?

it means following

compx :

<mx:canvas>

</mx:canvas>

and defination of anyother component say ‘compy’ is,

<compy>

<mx:HBox/>

</compy>

and in main application we have created instance of compy;

theoretically  we try to do nothing worng.. then why it is messed up and why this error… does that mean we can not inherit our mxml component.??

there is a workarround and there is logical reason also for this error ..

lets look at work arround first,

do this in ur base component .. say ‘basemxmlcomp’

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Canvas xmlns:mx=”http://www.adobe.com/2006/mxml”
width=”400″ height=”300″ creationComplete=”init()”>

<mx:Script>
<![CDATA[
import mx.controls.Alert;

private var _component:Array = new Array();

public function set Mcomponent( arr : Array ) : void {
_component =  arr;
}
public function init():void
{
mx.controls.Alert.show('sdds')
for(var i:int ; i<_component.length ;i++) {
addChild( _component[i] )
}
}
]]>
</mx:Script>
<mx:HBox width=”191″ height=”147″ backgroundColor=”#6B0A0A”>

</mx:HBox>
</mx:Canvas>

and in your child component say childmxmlcomp

<?xml version=”1.0″ encoding=”utf-8″?>
<local:basemxmlcomp xmlns:mx=”http://www.adobe.com/2006/mxml” width=”400″ height=”300″ xmlns:local=”*”>

<local:Mcomponent>
<mx:Panel/>
</local:Mcomponent>

</local:basemxmlcomp>

and now try to create instance of  childmxml component in main application ,

yeah it works ..

now let get to reason for error :

No specific reason . It should have done to directly add child component class’s children to parent class’s display list.. it might be available in the next future release of the sdk.. its just missed this time … but the effect would be same .. but due to this.. we developers or designers can see our both parent and and sub class’s structure at developement time in desing view..

Filed under: RIA/ FLEX/ AS