3 Replies Latest reply on Sep 8, 2009 6:45 AM by Ned Murphy

    trouble loading class


      I came upon a really nice class that loads a pixel bender filter and applies it to an image,  but so far havent really managed to call it to from within a different  flash application.


      The class is called PB;


      i tried:


            var p_b:PB = new PB();
            addChild (PB)

      and got an error massage that states:

      1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.


      I am new to classes but have been able to implement other classes before. Cannot figure out what I am doing wrong here.


      Thanks for any help.




      import flash.display.MovieClip;
      import flash.display.*;
      import flash.events.*;
      import flash.filters.*;
      import flash.utils.Timer;
      import flash.net.*;
      import gs.*;
      import gs.easing.*;

      public class PB extends Sprite
        private var image_c:Class;
        private var loader:URLLoader;
        private var shader:Shader;
        private var filter:ShaderFilter;
        public var im:Bitmap;
        private var my_timer:Timer;
        function PB():void
         im = new image_c() as Bitmap;
         loader = new URLLoader();
         loader.dataFormat = URLLoaderDataFormat.BINARY;
         loader.addEventListener(Event.COMPLETE, onComplete);
         loader.load(new URLRequest("resources/pixelate.pbj"));
         im.alpha = 0;
        private function onComplete(e:Event):void
         var repeat:Number = 20;
         var delay:Number = 1;
         var Amount:Number = 80;
         my_timer = new Timer(delay, repeat);
         my_timer.addEventListener(TimerEvent.TIMER, timer_handler);
         my_timer.addEventListener(TimerEvent.TIMER_COMPLETE, timer_complete);
         function timer_handler(evt:TimerEvent):void
          repeat --;
          shader = new Shader(loader.data);
          shader.data.dimension.value = [Amount];
          filter = new ShaderFilter(shader);
          im.filters = [filter];
          Amount -= 4;
          //delay +=100;
          trace (Amount)
         function timer_complete(evt:TimerEvent):void
          im.filters = null;