views:

31

answers:

0

I see that others are reporting bugs relating to a spurious "Stack depth is unbalanced" error, so I don't know whether the error I'm getting is my programming error or a bug in FB4 b2.

It it legal to instantiate a class that raises an event in an eventHandler? I'm getting such an error at the place located below. All of these classes extend EventDispatcher.

Thanks for the help.

    myFoo: Foo = new Foo();
    myFoo.addEventListener("FetchCustomerEvent", onCustomer);


    private function onCustomer(e: FetchCustomerEvent): void {
        Foo(e.target).removeEventListener("FetchCustomerEvent", onCustomer);
        var custId: int = (int) e.custId;
        var myOrders: CustomerOrders = new CustomerOrders(custId);
        myOrders.addEventListener(e:OrdersFoundEvent, onOrdersFound);
     myOrders.find(); // CustomerOrders class raises OrdersFoundEvent
   }

    private function onOrdersFound(e: OrdersFoundEvent): void {
        CustomerOrders(e.target).removeEventListener("CustomerOrdersFound", onCustomerOrders;
        var myDiscountCalculator: DiscountCalculator = new DiscountCalculator(e.Orders);
        myDiscountCalculator.addEventListener("DiscountCalculatedEvent", onDiscountCalculated);
        myDiscountCalculator.calculate();  **// "Stack depth is unbalanced 1 != 0" error occurs here**
    }