Don't forget Jason, we're all new to AS3, no matter how much time you
spent with AS2.  In AS3, if some outer method in your call stack has a
try/catch handler (which binding does), then if something in the "new
MyClass" line throws an error, you'll see exactly what you described.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Merrill, Jason
Sent: Friday, February 01, 2008 8:21 AM
To: [email protected]
Subject: [flexcoders] Set dataProvider method stops at midpoint?

 

I'm somewhat new to Flex, but NOT new to Actionscript, and this is the
oddest and one of the most frustrating things I have ever had to debug.
I'm sure it's just me not understanding how Flex, components, and
databinding works, but I'm at a loss.  The core of my question is:  What
could cause a method to stop executing completely in the middle and not
have the debugger complain of any errors?  I have verified this happens
in my application through trace statements, but have not been able to
reproduce it with simple test cases which mimics the same structure (as
far as I can tell).

 

I have an actionscript-written component that extends UIComponent.  In
the main app, I have some dummy data put into an ArrayCollection which
is in an init() function, which is fired upon the Flex app's
creationComplete event (see sample code at the bottom of this post). In
the component which extends UIComponent and overwrites some methods
(code snippet below), I have a set dataProvider function which takes in
the data from the dataProvider parameter for the component in MXML, but
it seems to hang up halfway through.  The method sets the dataProvider
data to a private variable, and then creates an instance of another
class:

 

//snippet

  [Bindable]
  private var _dataProvider:ArrayCollection;

 

  public function set dataProvider(_dp:ArrayCollection):void
  {
   _dataProvider = _dp;
   trace("this traces fine, and data received.");
   _myClass = new MyClass(this, _dp); //why would this stop the method?
   trace("This never traces!!!!!");
   addChild(_myClass);
  } 

 

The first trace works fine, the second never traces, and I don't get any
debugger or console messages (Flexbuilder 2)!  So I thought, maybe there
was some code in my "MyClass" (not the real name, but keeping it simple
here) which extends sprite which is not working right - but I've
searched through MyClass and the other class it uses, and all the data
comes through fine, it's constructor fires, and so does the constructor
of the other class it imports.  I spent most of yesterday trying to
debug this and I'm turning to the list now.  Here is the main app MXML
(the segment of the component is above):

 

 

//snippet

<mx:Application 
 xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " xmlns:c="components.*"
 layout="absolute" 
 applicationComplete="init()" >

 <mx:Script>
  <![CDATA[

   

    [Bindable]
    public var fakeData:ArrayCollection;

   

    private function init():void

    {

        fakeData = setFakeData();

    }

 

    private function setFakeData():void
    {
        fakeData.addItem({firstName:"David", lastName:"Branson"});

        fakeData.addItem({firstName:"Nelson", lastName:"Davidson"});

        fakeData.addItem({firstName:"Sally", lastName:""});        
    }

    ....etc etc.

 

then further down in the MXML is the component declaration:

 

    <c:MyComponent dataProvider="{fakeData}" ..blah blah/>

 

What could be going on here?  Thanks for any insights.

 

Jason Merrill 
Bank of America 
GT&O L&LD Solutions Design & Development 
eTools & Multimedia 

Bank of America Flash Platform Developer Community 

 

 

Reply via email to