When you use the <mx:component> tag, it does some voodoo and creates a
completely new class for you, extending whatever is the first child (in your
case, the new class would extend HBox).

This class has its own scope, so it doesn't have member access to anything
in the scope of your existing application.

There's a few options for you here:

1) You can call Application.application.doThis(event) - this is quick, but
not so nice. Not how I'd do it. doThis() must be public or you'll get a
run-time error

2) You can do add a function to your custom component that dispatches a new
event, and listen to the event from your application, you just have to put
true, for "bubbles" when you instantiate your event. This is how I'd do it.
You can subclass Event, or just use a DynamicEvent if you want to pass extra
information up to the application-level handler.

And yes, I do have a hard-on for event-based programming. It's the right way
to do things in most cases :)

-J

On Thu, May 22, 2008 at 2:07 PM, timgerr <[EMAIL PROTECTED]> wrote:

>   Hello all,
> I have a datagrid that I added a button to it. I am having troubles
> with the button and other things, Here is some code:
>
> public function DoThis(e:DataGridEvent):void
> {
> trace(dta.selectedItem.cert;)
>
> }
> <mx:DataGrid x="311" y="208" dataProvider="{dataArrayItemOne}" id="dta">
> <mx:columns>
> <mx:DataGridColumn headerText="Cert Date" dataField="certdate"/>
> <mx:DataGridColumn headerText="Certification" dataField="cert"/>
> <mx:DataGridColumn headerText="" dataField="test_id" width="80">
> <mx:itemRenderer>
> <mx:Component>
> <mx:HBox horizontalAlign="center">
> <mx:Button label="Press Me" click="DoThis(event)"/>
> </mx:HBox>
> </mx:Component>
> </mx:itemRenderer>
> </mx:DataGridColumn>
> </mx:columns>
> </mx:DataGrid>
>
> The first problem is I am getting an error "Call to possibly undefined
> method DoThis". And can I use the event to trigget the method and get
> the DataGridEvent?
>
> Thanks,
> timgerr
>
>  
>



-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]

Reply via email to