Domanda

I'm working on a tutorial for a pong clone and am currently trying to add a BevelFilter to a ball image. When I type in the code it returns an error saying

undefined property bitmapfilter type

I checked on live docs and it should be valid. I marked the line with two *'s

package 
{
import flash.display.Sprite;
import flash.display.Graphics;
import flash.events.Event;
import flash.filters.BevelFilter;
import flash.filters.GlowFilter;

public class Ball extends Sprite  
{
    private const RADIUS:int = 12;
    private const COLOR:uint = 0x01A6B2;
    private const COLOR2:uint = 0x45FCFF;
**  private const BEVEL:BevelFilter = new BevelFilter(4, 90, COLOR2, 1, COLOR2, 1, 10, 10, 1, 1, BitmapFilterType.Inner, true);
    private const GLOW:GlowFilter = new GlowFilter(0xFFFFFF, .6, 0, 0, 5, 1, true);

    public function Ball():void {
        addEventListener(Event.ADDED_TO_STAGE, go);
    }

    private function go(e:Event):void {
        removeEventListener(Event.ADDED_TO_STAGE, go);
        graphics.lineStyle(2, COLOR, 1);
        graphics.beginFill(COLOR);
        graphics.drawCircle(0, 0, RADIUS);
        filters = [BEVEL, GLOW];
    }
}
}

Thanks!

È stato utile?

Soluzione

I use these on a regular basis. Your code should look like this...

private const BEVEL:BevelFilter = new BevelFilter(4, 90, COLOR2, 1, COLOR2, 1, 10, 10, 1, 1, "inner", true);

That second-to-last argument accepts a string.

Not sure why the docs represent it differently. This was off of the code hints for Adobe Flash CS6, and I know this should work.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top