Hello!

I've followed the tutorial from How To Forge 
(http://howtoforge.com/amfphp_adobe_flex2_sdk) on how to use amfphp 1.9 
and Flex 2. Everything seems to work fine, except one little thing.

Flex keeps giving me this error message:
TypeError: Error #1034: Type Coercion failed: cannot convert 
[EMAIL PROTECTED] to Users.Person.

Here's what I've done:

Made a package called Users, with a class called Person. And this is 
what it looks like:

package Users
{
    import flash.net.registerClassAlias;
    [RemoteClass(alias="test.Person")]
   
    [Bindable]
    public class Person
    {
        public var firstName:String;
        public var lastName:String;
        public var phone:String;
        public var email:String;
    }
}

In my MXML file, I have an event handler which is supposed to take the 
result from the Amfphp-class, turn it into an instance of the Person 
class (correct?), and then populate the DataGrid.

My event handler:
private function changeHandler(event:Event):void {
    selectedPerson = Person(DataGrid(event.target).selectedItem);
}

selectedPerson is defined like this:
[Bindable]
private var selectedPerson:Person = new Person();

The PHP-class:

<?php

class Person {
    var $firstName;
    var $lastName;
    var $phone;
    var $email;
    // explicit actionscript package
    var $_explicitType = "Users.Person";
}

?>


Obviously, Flex tries to convert an Object into Users.Person, but fails. 
Does anyone have any ideas on what went wrong?

I found a tutorial on Adobe's website which does the same thing, but 
with SabreAMF. The code looks pretty much the same except that the 
tutorial uses PHP5, and I'm on PHP4 (because of my webhost). But that 
tutorial didn't make me any smarter...



Best regards,
Thomas Viktil


Reply via email to