title: Flex 3.2 casting problem
body: <p>I'm newish to flex an have recently hit a snag casting.</p>
  
  <p>this is the code I'm running.</p>
  
  <pre><code>/**
  * return background definition depending on time
  */ 
  private function findBackgroundItem( relativeTime : Number ) : CSBackgroundItem
  {
      if( this.backgroundItems == null ) return null;
      var result :CSBackgroundItem = null;
      var relative:Date = new Date(relativeTime);
      for( var i : Number = 0; i &lt; this.backgroundItems.length; i++ )
      {
          // backgroundItems is an Ilist of CSBackgroundItem.
          var colourItem : CSBackgroundItem = CSBackgroundItem( this.backgroundItems.getItemAt( i ) );
  
          // other stuff here
      }           
      return result;
  }
  </code></pre>
  
  <p>The problem occurs when the IList.getItemsAt() result is cast to the CSBackgroundItem variable colourItem. The following error is thrown</p>
  
  <pre><code>TypeError: Error #1034: Type Coercion failed: cannot convert com.mystuff::CSBackgroundItem@650e8dd1 to com.mystuff.CSBackgroundItem.
  </code></pre>
  
  <p>If I use the <code>'as'</code> keyword I get cast results in the <code>colourItem</code> being null. Using the debugger shows that the list is not empty and is indeed populated with <code>CSBackgroundItem</code> objects.</p>
  
  <p>Now this is the wacky bit.. this code works, the first time the module it's in loads.. subsequent loads (after unloading it) throw the exception.</p>
  
  <p>Can anyone shed any light on why this might happen?</p>