A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] Error #1123: Filter operator not supported on type

  1. #1
    Member
    Join Date
    May 2010
    Posts
    32

    resolved [RESOLVED] Error #1123: Filter operator not supported on type

    Hey guys,

    I really don't know how to make this question easy, but I'll try. If you're looking for a challenge i suggest this :P

    I'm making a game so far with 2 characters (in 2 classes); Adeiza and Dooray. Combat and movement are all fine, but now I need to make a ranged special. I've created a MovieClip and a class file for AdzFire, which is basically a fireball created by Adeiza in a certain frame. This fireball is created and moves in the direction I ask it to, which is fine. My problem lies with it hitting the opposing character (currently Dooray). Here are the codes I think are affected;

    1. The code in AdzFire.as, called with an enterframe event.
    Code:
    public function fire(evt:Event) {
     if (shotDirect==-1) {
       this.x-=20;
     }
     if (shotDirect==1) {
       this.x+=20;
     }
    }
    1. The code in frame 1 of the AdzFire movieclip.
    Code:
    for (var n:int=0; n<this.parent.(charHolder as DisplayObjectContainer).numChildren; n++) {
     if (this.hitTestObject(this.parent.(charHolder as DisplayObjectContainer).getChildAt(n)) 
              && !(this.parent.(charHolder as DisplayObjectContainer).getChildAt(n) is Adeiza)) {
       this.parent.(charHolder as DisplayObjectContainer).getChildAt(n).takeDamage(this.power);
       this.parent.removeChild(this);
       this.removeEventListener(Event.ENTER_FRAME, fire);
     } else if (this.x<0||this.x>1000) {
       this.parent.removeChild(this);
       this.removeEventListener(Event.ENTER_FRAME, fire);
     }
    }
    charHolder is where all the characters are added. Sorry bout the unkempt code, didn't know how else to do this part :S

    The code in my main frame.
    Code:
    function controls(evt:Event):void {
    //...
    
    if(lKey && lReleased){
      p1.shoot();
      lReleased=false;
    }
    
    //...
    }

    The shoot method in Adeiza.as
    Code:
    public function shoot():void {
      if(!attackLock && sp>=30){
        cstate="shoot";
        specialTimer.start();
        this.gotoAndPlay("shoot");
        sp-=30;
        attackLock=true;
      }
    }
    and finally my output error. This comes up when the fireball is created :S

    Code:
    TypeError: Error #1123: Filter operator not supported on type flash.display.MovieClip.
      at AdzFire/frame1()
      at flash.display::MovieClip/gotoAndStop()
      at KnockoutGame_fla::MainTimeline/controls()
    Thanks for your help in advance ^^

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Code:
    public function fire(evt:Event) {
     if (shotDirect==-1) {
       this.x-=20;
     }
     if (shotDirect==1) {
       this.x+=20;
     }
    }
    That is equivalent to this:
    Code:
    public function fire(evt:Event) {
       this.x += 20*shotDirect;
    }
    But that's just ugly, not an actual problem. Now THIS
    this.parent.(charHolder as DisplayObjectContainer)
    Is just nonsense, and the cause of your error. That syntax is being mistaken for an e4x filter operation. I'm not sure what you think you're trying to do there, but you should only have to do it once. Try something more like:
    Code:
    var charHolder:DisplayObjectContainer = MovieClip(this.parent).charHolder;
    for (var n:int=0; n<charHolder.numChildren; n++) {
      var child:MovieClip = MovieClip(charHolder.getChildAt(n));
      if (!(child == this) && this.hitTestObject(child)) {
       child.takeDamage(this.power);
       cleanUp();
      } else if (this.x<0||this.x>1000) {
        cleanUp();
      }
    }
    
    function cleanUp():void{
       this.parent.removeChild(this);
       this.removeEventListener(Event.ENTER_FRAME, fire);
    }

  3. #3
    Member
    Join Date
    May 2010
    Posts
    32
    Thanks for your help. I tried what you said, but now I get and error saying;

    Code:
    1046: Type was not found or was not a compile-time constant: DisplayObjectContainer.
    var charHolder:DisplayObjectContainer = MovieClip(this.parent).charHolder;
    Its parent is meant to be the stage, is it still ok to cast it as a MovieClip?
    Last edited by sodiumbadams; 07-20-2010 at 07:47 AM.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You need to import DisplayObjectContainer. At the top of the frame:
    Code:
    import flash.display.DisplayObjectContainer;
    If the parent really is the stage, then no you cannot cast to MovieClip. However, the parent is almost certainly NOT the stage. You probably mean the root, which is the main timeline. You can cast the root to MovieClip just fine, so long as the main timeline is actually an instance of MovieClip. Unless you're using a document class which extends from Sprite, the root will be a MovieClip. Since you're using frame code, I am fairly sure that your main timeline is a MovieClip.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center