topical media & game development

talk show tell print

#graphic-player-10-pixel-filter-crystallize.mx

#graphic-player-10-pixel-filter-crystallize.mx [swf] [flash] flex


  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
  xmlns:ae="*"
  layout="absolute"
  applicationComplete="onApplicationComplete()">
  
          <mx:Script>
                  <![CDATA[
                          import flash.filters.*;
                          import flash.utils.ByteArray;                
  
                          //the file that contains the binary bytes of the PixelBender filter
                          [Embed("graphic-player-10-pixel-filter-shaders-Crystallize.pbj", mimeType="application/octet-stream")]
                          private var TestFilter:Class;        
                          
                          
              import flash.media.Camera;
              private var camera:Camera; // = Camera.getCamera();
    
              private function attach() : void {
              camera = Camera.getCamera();
              ca.attachCamera(camera);
              }
                          
                          private var state:Number = 0;
                          private function next():void {
                          if (state == 0) {
                            state++;
                            vd.filters = [filter];
                            vd.visible = true;
                            im.visible = false;
                            ca.visible = false;
                          } else if (state == 1) {
                            state++;
                            im.filters = [filter];
                            im.visible = true;
                            vd.visible = false;
                            ca.visible = false;
                          } else if (state == 2) {
                            attach();
                            state = 0;
                            ca.filters = [filter];
                            im.visible = false;
                            vd.visible = false;
                            ca.visible = true;
                          }
                          
                          }
  
              private var shader:Shader;
              private var filter:ShaderFilter;
              
                          private function onApplicationComplete():void
                          {
                                  //Pass the loaded filter to the Shader as a ByteArray
                                  shader = new Shader(new TestFilter() as ByteArray);
  
                                  shader.data.size.value = [20.0];
                                  filter = new ShaderFilter(shader);
  
                                  //add the filter to the image
                                  im.filters = [filter];
                          }
                  ]]>
          </mx:Script>
       <ae:component_screen id="display"/>
          <mx:Image id="im" click="next();" right="0" left="0" top="0" bottom="0" maintainAspectRatio="false" source="soutine.jpg"/>
          <mx:Image id="vd"  click="next();" visible="false" right="0" left="0" top="0" bottom="0" maintainAspectRatio="false" source="@walk.png"/>
          <mx:VideoDisplay id="ca"  click="next();" visible="false" right="0" left="0" top="0" bottom="0" maintainAspectRatio="false" source="@walk.png"/>
      <mx:HBox right="5" bottom="10">
      <mx:Button color="gray" borderColor="0" fillAlphas="[0, 0]" label="||" click="display.toggle();"/>
      </mx:HBox>
  </mx:Application>
  


(C) Æliens 04/09/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.