topical media & game development

talk show tell print

lib-flex-cover-com-dougmccune-containers-materials-FlexMaterial.ax

lib-flex-cover-com-dougmccune-containers-materials-FlexMaterial.ax (swf ) [ flash ] flex


  package com.dougmccune.containers.materials
  {
          import flash.display.DisplayObject;
          import flash.events.Event;
          
          import mx.core.Container;
          import mx.core.UIComponent;
          import mx.events.FlexEvent;
          
          import org.papervision3d.materials.MovieMaterial;
  
          public class @ax-lib-flex-cover-com-dougmccune-containers-materials-FlexMaterial extends MovieMaterial
          {
                  public function @ax-lib-flex-cover-com-dougmccune-containers-materials-FlexMaterial(movieAsset:DisplayObject=null, transparent:Boolean=true)
                  {
                          if(movieAsset is UIComponent) {
                                  addUpdateListeners(UIComponent(movieAsset));
                          }
                          
                          super(movieAsset, transparent, false);        
                  }
                  
                  private function addUpdateListeners(component:UIComponent):void {
                          component.addEventListener(FlexEvent.UPDATE_COMPLETE, handleUpdateComplete, false, 10, true);
                          
                          if(component is Container) {
                                  var n:int = Container(component).numChildren;
                                  
                                  for(var i:int=0; i<n; i++) {
                                          var child:DisplayObject = component.getChildAt(i);
                                          
                                          if(child is UIComponent) {
                                                  addUpdateListeners(UIComponent(child));
                                          }
                                  }
                          }
                  }
                  
                  private function handleUpdateComplete(event:Event):void {
                          updateBitmap();
                  }
          }
  }


(C) Æliens 18/6/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.