And to beat a horse that might not be quite dead yet, if the problem IS
with the deferred instantiation of the container, then the best solution
is as Lach outlines in the first paragraph: update a data model
somewhere accessible, then bind the viewstack children's components to
that model.  Avoid solving the problem using creationPolicy.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Lachlan Cotter
Sent: Tuesday, December 05, 2006 6:17 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Returning values from objects on another
canvas

 

Hi,

 

There are a couple of different issues here.

 

First, why do you need to get a reference to the other view? If it is in
order to access or manipulate the data therein, the better approach is
to bind both views into some dataProvider and manipulate the data
through that.

 

Second, the reason you can't address the sub-components at compile time
is that they are not part of the canvas class (they are children of your
instance). Notwithstanding the above paragraph, if you still need to
access them this way, you might want to define your own subclass
component with these child properties, so Flex Builder can find them at
compile time.

 

Finally, just a guess but perhaps dgselectedOptions is null at runtime
because at the time your function is executing, that component has not
yet been initialised. Check the creationPolicy of the tab navigator.

 

Cheers,

Lach

 

On 05/12/2006, at 5:19 PM, michrx7 wrote:





How does one go about referencing objects on another canvas? For 
example I have a tab navigator with 4 tabs:
Register
Attendees
Membership
Payment Options

Inside the attendees tab I have a canvas: csAttendee with a datagrid: 
dgselectedOptions

When the user submits the "pay" button on the payment options tab I 
call a function to validate their input and try and reference the 
columns array for the datagrid dgselectedOptions.

Using csAttendee.dgselectedOptions gives me an error when I try to 
compile of "Access of possibly undefined property dgselectedOptions 
through a reference with static type mx.containers:Canvas."

If I try Attendees.csAttendee.dgselectedOptions gives me "Access of 
possibly undefined property csAttendee through a reference with 
static type mx.containers:Canvas."

If I try just dgselectedOptions it compiles, but when I click my 
payment button it gives: "Cannot access a property or method of a 
null object reference." Even though I can click on the Attendees tab 
and the datagrid is there and populated.

 

 

Reply via email to