Ok i think you can't do that since I am looking at Adobe Flex Professional 2.0 
wrox book and they have a similar example and what they did was
EmployeeVO.employeeID = objectName.employeeID;


----- Original Message ----
From: Derrick Anderson <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, June 9, 2008 1:51:08 PM
Subject: Re: [flexcoders] new to VO's, why won't this cast?


ok, here is EmployeeVO.as

package com.winn.vo
{
    [Bindable]
    public class EmployeeVO
    {
        public var employeeID:uint;
        public var roleID:Number;
        public var employeeTypeID: Number;
        public var employeeStatusID: Number;
        
    }
}

then in my mxml file i have a simple datagrid

<mx:DataGrid 
        id="employeeDataGrid" 
        width="100%" height="100%" 
        dataProvider="{ EmployeesModel. getInstance( ).employeesList }" 
        >
with a click listener

employeeDataGrid. addEventListener ( MouseEvent.CLICK, clickHandler );

and here is clickHandler

public function clickHandler( event:MouseEvent ):void
        {
            var testVO:EmployeeVO = EmployeeVO(event. currentTarget. 
selectedItem) ;
            Alert.show(testVO. employeeID. toString( ));
        }

and the selectedItem has these properties.. .

employeeID = 1830 [0x726]
employeeStatusID = 2
employeeTypeID = 1
mx_internal_ uid = "D3C...."
roleID = 3




On Mon, Jun 9, 2008 at 2:39 PM, Sherif Abdou <[EMAIL PROTECTED] com> wrote:

can you give me a bit of code and I'll look at it so i can compile the examples 


----- Original Message ----
From: Derrick Anderson <no.way.this. is.in.use@ gmail.com>
To: [EMAIL PROTECTED] ups.com
Sent: Monday, June 9, 2008 1:21:51 PM
Subject: Re: [flexcoders] new to VO's, why won't this cast?


i tried your first suggestion, the second one I had already tried- at least 
with this one I get an error

TypeError: Error #1034: Type Coercion failed: cannot convert [EMAIL PROTECTED] 
to com.winn.vo. EmployeeVO.

Still the same question though, the datatypes seem to be compatible- so why the 
error?

thanks,
d.


On Mon, Jun 9, 2008 at 2:07 PM, Jon Bradley <[EMAIL PROTECTED] l.com> wrote:



On Jun 9, 2008, at 1:54 PM, Derrick Anderson wrote:

var testVO:EmployeeVO = DataGrid(event. currentTarget) .selectedItem as 
EmployeeVO;


Maybe this will help:

var testVO:EmployeeVO = EmployeeVO(event. currentTarget. selectedItem) ;

or
var testVO:EmployeeVO = event.currentTarget .selectedItem as EmployeeVO;


good luck,

jon 

 
    


      

Reply via email to