Hi,
>From the look if it
;ComboBox(event.target).selectedItem
seems to be where the null pointer is. Make sure you actually have a
selectedItem in the list.
I have actually done this myself when testing and actually forgot to
'select' an item before a service call.
Mike
On Mon, Jun 9, 2008 at 6:52 AM, xaero <[EMAIL PROTECTED]> wrote:
> Hi
> I'my working whit flex and amfphp.
> In my exercise, the flex debug say this error:
>
> TypeError: Error #1009: Cannot access a property or method of a null object
> reference.
> at cys/changeHandler()[D:\My
> Documents\FlexBuilder3\cys\src\cys.mxml:51]
> at cys/__atclass_close()[D:\My
> Documents\FlexBuilder3\cys\src\cys.mxml:70]
>
> line around 51:
>
> public function changeHandler(event:Event):void
> {
> var atClass:Object = new Object;
> atClass.atcls = ComboBox(event.target).selectedItem.data;
>
> gateway.call("Cys.getStudents", new Responder(getResult,
> onFault), atClass); // this is line 51
> }
>
> getResult is another function that give the result to ComboBox's
> dataProvider:
> public function getResult(result:Array):void
> {
> ssProvider = result;
> }
>
> onFault:
> public function onFault(fault:String ):void
> {
> trace(fault);
> }
>
> line 70:
> <mx:ComboBox y="202" id="atclass" close="changeHandler(event);"
> dataProvider="{atClassProvider}" fontSize="12" x="40"></mx:ComboBox>
> this comboBox can display properly.
>
> Cys is a Class, it is under amfphp/services and its file code:
> <?php
> Define('DATABASE_SERVER', 'localhost');
> Define('DATABASE_USERNAME', 'root');
> Define('DATABASE_PASSWORD', '123456');
> Define('DATABASE_NAME', 'cys');
>
> class Cys
> {
> var $mysqli;
>
> function Cys()
> {
> # Connect to MySQL database....
> $this->mysqli = new mysqli(DATABASE_SERVER, DATABASE_USERNAME,
> DATABASE_PASSWORD, DATABASE_NAME);
> # Check MySQL connection
> if (mysqli_connect_errno()) {
> # Dont use die (Fatal Error), return useful info to the client
> trigger_error("AMFPHP Remoting class could not connect: " .
> mysqli_connect_error());
> }
> }
> function getStudents($atClass) {
> # Return a list of all the users
> $atcls =
> $this->mysqli->real_escape_string(trim($atClass['atcls']));
> $sql = "SELECT * from students where atclass = '".$atcls."'";
> if ([EMAIL PROTECTED]>mysqli->query($sql)) {
> $errno=$this->mysqli->errno;
> $this->mysqli->close();
> trigger_error("AMFPHP Remoting class database SELECT query
> error: " . $errno);
> }
> while ($row = $result->fetch_assoc()) {
> $user_array[] = $row;
> }
> return($user_array);
> }
> }
> ?>
>
>
--
Teoti Graphix, LLC
http://www.teotigraphix.com
Teoti Graphix Blog
http://www.blog.teotigraphix.com
You can find more by solving the problem then by 'asking the question'.