Please check this
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";
                                xmlns="*"
                                creationComplete="initApplication()">
        <mx:DataGrid dataProvider="{dP}">
                <mx:columns>
                        <mx:DataGridColumn headerText="User Name"
                                        columnName="username"/>
                </mx:columns>
        </mx:DataGrid>
        <mx:Script>
                <![CDATA[
                        [Bindable]
                        public var dP:Array;
                        import flash.net.Responder;
                        public var gateway:RemotingConnection;

                        public function initApplication()
                        {
                                gateway=new 
RemotingConnection("http://localhost/test/test.php";);
                                gateway.call("sample.getUsers", new 
Responder(onResult, onFault));
                        }

                        public function onResult(result:Array):void
                        {
                                dP=result;
                        }

                        public function onFault(fault:String):void
                        {
                                trace(fault);
                        }
                ]]>
        </mx:Script>
</mx:Application>


test.php

<?php
// Create new service for PHP Remoting as Class
class sample
{
function sample ()
{
// Define the methodTable for this class in the constructor
$this->methodTable = array(
"getUsers" => array(
"description" => "Return a list of users",
"access" => "remote"
)
);
}
function getUsers () {
$mysql = mysql_connect(localhost, "username");
mysql_select_db( "sample" );
//return a list of all the users
// Create table users, first
$Query = "SELECT * from users";
$Result = mysql_query( $Query );
while ($row = mysql_fetch_object($Result)) {
$ArrayOfUsers[] = $row;
}
return( $ArrayOfUsers );
}
}
?>





On Apr 21, 9:22 am, sheetal <[email protected]> wrote:
> Give me sample data for ur Array n i will try it.
>
> On Apr 20, 7:07 pm, rakshith sharma <[email protected]> wrote:
>
>
>
> > TypeError: Error #1034: Type Coercion failed: cannot convert
> > mx.collections::arraycollect...@d05f241 to
> > mx.controls.dataGridClasses.DataGridColumn.
> >     at mx.controls::DataGrid/set
> > columns()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\controls\DataGr­id.as:1099]
> >     at
> > mx.core::Container/createComponentFromDescriptor()[E:\dev\3.0.x\frameworks\­projects\framework\src\mx\core\Container.as:3587]
> >     at
> > mx.core::Container/createComponentsFromDescriptors()[E:\dev\3.0.x\framework­s\projects\framework\src\mx\core\Container.as:3485]
> >     at
> > mx.core::Container/createChildren()[E:\dev\3.0.x\frameworks\projects\framew­ork\src\mx\core\Container.as:2587]
> >     at
> > mx.core::UIComponent/initialize()[E:\dev\3.0.x\frameworks\projects\framewor­k\src\mx\core\UIComponent.as:5262]
> >     at
> > mx.core::Container/initialize()[E:\dev\3.0.x\frameworks\projects\framework\­src\mx\core\Container.as:2524]
> >     at
> > mx.core::Application/initialize()[E:\dev\3.0.x\frameworks\projects\framewor­k\src\mx\core\Application.as:847]
> >     at sandy4/initialize()[C:\Documents and Settings\rakshith\My
> > Documents\Flex Builder 3\sandy4\src\sandy4.mxml:0]
> >     at 
> > mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::childAdded()[E
> > :\dev\3.0.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:­1625]
> >     at
> > mx.managers::SystemManager/initializeTopLevelWindow()[E:\dev\3.0.x\framewor­ks\projects\framework\src\mx\managers\SystemManager.as:2482]
> >     at 
> > mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[E
> > :\dev\3.0.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:­2330]
> > [SWF] /sandy4-debug/sandy4.swf - 906,800 bytes after decompression
>
> > THIS IS THE ERROR WHICH I AM GETTIN AFTER I DEBUG THE CODE GIVEN
> > BELOW::::CAN SOME ONE HELP ME OUT WITH THIS?
> > PLZZZZZ........
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute"
>
> >     <mx:DataGrid dataProvider="{myarr}" x="254" y="143" width="255"
> > enabled="true" id="sandy">
> >         <mx:columns>
> >         <mx:ArrayCollection>
> >                 <mx:DataGridColumn dataField="user_id"/>
> >                 <mx:DataGridColumn dataField="username"/>
> >                 </mx:ArrayCollection>
> >             </mx:columns>
> >     </mx:DataGrid>
>
> >     <mx:Script>
> >         <![CDATA[
> >             import mx.collections.ArrayCollection;
> >             [Bindable]
> >             public var dp:Array;
>
> >             [Bindable]
> >             public var dp2:Object;
>
> >             [Bindable]
> >             public var myarr:ArrayCollection = new ArrayCollection();
>
> >             import flash.net.Responder;
>
> >             public var gateway : RemotingConnection;
>
> >             public function initApplication():void
> >             {
> >                 gateway = new RemotingConnection( 
> > "http://localhost/amfphp/gateway.php"; );
> >                 gateway.call( "sample.getUsers", new Responder(onResult,
> > onFault));
> >             }
>
> >             public function onResult(  result : Array ) : void
> >             {
> >                 dp = result;
>
> >                 myarr.source=dp;
>
> >             }
>
> >             public function onFault( fault : String ) : void
> >             {
> >                 trace( fault );
> >             }
>
> >         ]]>
> >     </mx:Script>
> >     <mx:Button x="127" y="376" label="submit" id="rak" enabled="true"
> > click="initApplication()"/>
>
> > </mx:Application>- Hide quoted text -
>
> - Show quoted text -

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to