Share Pastebin
Guest
Public paste!

JesterXL

By: a guest | May 12th, 2008 | Syntax: ActionScript | Size: 1.61 KB | Hits: 419 | Expires: Never
Copy text to clipboard
  1. package
  2. {
  3.         // here strictly to allow ProgramVO's to work in a Flash CS3
  4.         // List.  It arrogantly assumes that people don't mind
  5.         // adding properties to their VO's.  Rather than modify
  6.         // our data model to work within a CS3 List, we make a new
  7.         // VO.
  8.         //
  9.         // If you're not as much as an OOP Purist as I am,
  10.         // then simply add these properties to the ProgramVO class.
  11.        
  12.         import com.multicastmedia.vidego.vo.ProgramVO;
  13.        
  14.         import flash.utils.Proxy;
  15.         import flash.utils.flash_proxy;
  16.        
  17.         public class ProgramVOProxy extends Proxy
  18.         {
  19.                 public var icon:*;
  20.                 public var label:*;
  21.                 public var program:ProgramVO;
  22.                
  23.                 public function ProgramVOProxy(program:ProgramVO):void
  24.                 {
  25.                         this.program = program;
  26.                 }
  27.                
  28.                 flash_proxy override function getProperty(name:*):*
  29.                 {
  30.                         // if you need the original program, here you go!
  31.                         if (name == "program")
  32.                         {
  33.                                 return program;
  34.                         }
  35.                        
  36.                         // Rather than be a jerk, we attempt to give the List control
  37.                         // a valid label
  38.                         if (name == "label")
  39.                         {
  40.                                 return program.metadatas.title;
  41.                         }
  42.                        
  43.                         // As long as you aren't asking for 'icon',
  44.                         // we'll assume you're looking for ProgramVO data
  45.                         if (name != "icon")
  46.                         {
  47.                                 return program[name];
  48.                         }
  49.                         else
  50.                         {
  51.                                 //... otherwise, it might be here... :: shrugs ::
  52.                                 // if not, BOOM!
  53.                                 return this[name];
  54.                         }
  55.                 }
  56.  
  57.                 flash_proxy override function setProperty(name:*, value:*):void
  58.                 {
  59.                         if (name == "program")
  60.                         {
  61.                                 program = value;
  62.                         }
  63.                        
  64.                         if (name != "icon" && name != "label")
  65.                         {
  66.                                 program[name] = value;
  67.                         }
  68.                         else
  69.                         {
  70.                                 this[name] = value;
  71.                         }
  72.                 }
  73.                
  74.         }
  75. }