Flash 8 filters

Submitted by GROL on 18 July, 2010 - 17:32
Flash 8 filters

Test Flesh 8 filters: shadow, glow, bevel, blur, adjust color.

Source archive: flash8.zip (600 KB)

 

Sample works

Some sample source: 
procedure TForm3.ButMakeClick(Sender: TObject);
var
  Movie: TFlashMovie;
  Shape: TFlashShape;
  Lbl: TFlashText;
  Mem: TMemoryStream;
  lblLev: byte;
 
  procedure PlaceLabel(Text: string; X, Y: integer);
  begin
    Lbl := Movie.AddDynamicText('', Text, cswfGreen, Movie.Fonts[0], Rect(X, Y, X + 100, Y + 20));
    Lbl.AutoSize := true;
    Movie.PlaceObject(Lbl, lblLev);
    inc(lblLev);
  end;
 
begin
  Movie := TFlashMovie.Create(0, 0, 300, 300, 12, scPix);
  Movie.Version := SWFVer8;
 // Movie.Compressed := true;
  Movie.BackgroundColor.RGB := SWFRGB(Random($FFFFFF)); 
 
  with Movie.GlobalFilterSettings do
  begin
    BlurX := EtoInt(eBlurX, 0, 100);
    BlurY := EtoInt(eBlurY, 0, 100);
    Distance := EtoInt(eDistance, 0, 100);
    Angle := EtoInt(eAngle, 0, 360);
    Knockout := not cbShowObj.Checked;
    Inner := cbInner.Checked;
    Quality := TFlashFilterQuality(RGQuality.itemIndex);
    OnTop := chOnTop.Checked;
  end;
 
  Movie.AddFont('_sans', true, False, 11);
  lblLev := 100;
  PlaceLabel('Bevel', 10, 0);
 
  Shape := Movie.AddRoundRect(20, 20, 100, 60, 8);
  Shape.SetSolidColor(0, 0, $d0, $FF);
  With Movie.PlaceObject(Shape, 1), Bevel do
  begin
 
  end;
 
  PlaceLabel('Shadow', 10, 65);
  With Movie.PlaceObject(Shape, 2), Shadow do
  begin
//    OnTop := true;
    TranslateY := 60;
  end;
 
  PlaceLabel('Glow', 10, 125);
  With Movie.PlaceObject(Shape, 3), Glow do
  begin
//    GlowColor.RGBA := cswfGreen;
    BlurX := BlurX * 3;
    BlurY := BlurY * 3;
    TranslateY := 120;
  end;
 
 
  PlaceLabel('Blur', 130, 0);
  Shape := Movie.AddStar(180, 50, 50, 10, 8, true);
  Shape.SetRadialGradient(cswfYellow, cswfRed, 50, 50);
  With Movie.PlaceObject(Shape, 4), Blur do
  begin
//    OnTop := true;
  end;
 
  PlaceLabel('Adjust color', 130, 100);
  With Movie.PlaceObject(Shape, 5), ColorMatrix do
  begin
    TranslateY := 105;
    AdjustColor(EtoInt(eBrightness, -100, 100),
                EtoInt(eContrast, -100, 100),
                EtoInt(eSaturation, -100, 100),
                EtoInt(eHue, -180, 180));
  end;      
 
  PlaceLabel('Inner bevel with custom color and yellow glow', 15, 210);
  Shape := Movie.AddCircle(0, 0, 25);
  Shape.SetRadialGradient(cswfSkyBlue, cswfBlue, 35, 35);
  with Movie.PlaceObject(Shape, 6) do
  begin
    SetPosition(150, 260);
    With Bevel do
    begin
      Knockout := false;
      InnerShadow := true;
      ShadowColor.A := 180;
      ShadowColor.R := 100;
      HighlightColor.A := 180;
    end;
    with Glow do
    begin
      Knockout := false;
      InnerGlow := false;
      GlowColor.RGBA := cswfYellow;
      BlurX := 30;
      BlurY := 30;
      Strength := 2;
    end;
  end;
 
  Movie.ShowFrame;
  Movie.MakeStream;
  Mem := TMemoryStream.Create;
  Movie.SaveToStream(Mem);
  Movie.Free;
  Mem.Position := 0;
  Player.LoadMovieFromStream(Mem);
  Mem.SaveToFile('flash8test.swf');
  Mem.Free;
end;