If the directory containing the valueObjects directory on your source
path?
 
Does it work if you use the unqualified classname ShoppingCartItem?
 
    click="outerDocument.removeItem(ShoppingCartItem)"/>
 
Although it should be OK to write valueObjects.ShoppingCartItem, it
shouldn't be necessary.
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of oim415
Sent: Saturday, February 10, 2007 5:51 AM
To: [email protected]
Subject: [flexcoders] Can someone tell me what I am doing wrong.



Hello,

I am new to Flex and am currently in the process of going through the
Adobe Flex 2 Training from the Source book.  Well everything was going
along fine until lesson 11.  I have been fighting with a compiler error
1120: Access of undefined property valueObjects.  I have the correct
import statements and have double-checked my code multiple times with
that provided by the authors.  I get the same error when I use the
author's code.  Could there be a configuration problem in my enviroment.
up to this point, erverything compiles and runs as expected.  The error
occurs on the click event of the button.  Please review the code below.
I can provide further details once the questions start.  thanks in
advance.

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml";>
    <mx:Metadata>
  ! ;      [Event(name="productRemoved",type="events.ProductEvent")]
    </mx:Metadata>

    <mx:Script>
        <![CDATA[
            import events.ProductEvent;
            import valueObjects.ShoppingCart;
            import valueObjects.ShoppingCartItem;
            import valueObjects.Product;
            import mx.controls.dataGridClasses.DataGridColumn;
            
            [Bindable]
            public var cart:ShoppingCart;
&n! bsp;           
&nb! sp;  ;          private function
renderPriceLabel(item:ShoppingCartItem,dataField:DataGridColumn):String{
                return "$"+String(item.subtotal);
            }
            
            public function removeItem(cartItem:ShoppingCartItem):void{
                var prod:Product = cartItem.product;
                var e:ProductEvent = new
ProductEvent(prod,"productRemoved");
                this.dispatchEvent(e);
            }

 &nbs! p;      ]]>
    </mx:Script>
    
    <mx:DataGrid
        id="cartView"
        dataProvider="{cart.aItems}" width="100%" height="100%"
        editable="true" draggableColumns="false"
        variableRowHeight="true">
        <mx:columns>
            <mx:DataGridColumn dataField="product" headerText="Product"
                itemRenderer="renderer.ecomm.ProductName"
editable="false"/>
            <mx:DataGridColumn dataField="quantity" 
            &n! bsp;   itemEditor="mx.controls.NumericStep! per" 
                editorDataField="value" editable="true"
headerText="Quantity" />
            <mx:DataGridColumn dataField="subtotal" headerText="Amount"
labelFunction="renderPriceLabel" editable="false" />
            <mx:DataGridColumn editable="false">
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:VBox>
                            <mx:Button 
    &nbs! p;                           label="Remove" 
 
click="outerDocument.removeItem(valueObjects.ShoppingCartItem(data))"/> 
                        </mx:VBox>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
        </mx:columns>
    </mx:DataGrid>

</mx:VBox> 

 

Reply via email to