Snow
Submitted by eLenka on 4 August, 2010 - 15:17

Demonstration of using Action instructions for creating the snowing effect.
Source archive: show.zip (193 KB)
Sample works
Some sample source:
var Movie: TFlashMovie; label1, label2, label3, label4: TSWFOffsetMarker; EA: TSWFExportAssets; begin Movie := TFlashMovie.Create(0, 0, 400 * twips, 300 * twips, 20); Movie.Version := 6; Movie.SystemCoord := scPix; { Background } Movie.AddRectangle(0, 0, 400, 300).SetLinearGradient(SWFRGBA($663300), SWFRGBA($CCFF99), 270); Movie.PlaceObject(Movie.Shapes[0], 1); Movie.BackgroundColor.RGB := SWFRGB(0,0,0); { Text } Movie.AddFont(Font, false); With Movie.Fonts[0] do begin Size := 30 * twips; Name := 'Times New Roman'; Bold := true; end; Movie.AddText('Delphi SWF SDK', cswfWhite, Movie.Fonts[0], Point(0, 0), taRight); Movie.AddSprite; With Movie.Sprites[0] do begin PlaceObject(Movie.Texts[0], 10); with PlaceObject(Movie.Texts[0], 9) do begin SetTranslate(2, 2); InitColorTransform(true, -$FF, -$FF, -$FF, -150, false, 0, 0, 0, 0, true); end; end; Movie.PlaceObject(Movie.Sprites[0], 10000).SetTranslate(395, 0); { one snow } Movie.AddStar(0, 0, 3, -3, 4).SetSolidColor(SWFRGBA($EE, $EE, $FF, $DD)); Movie.AddSprite; With Movie.Sprites[1] do begin PlaceObject(Movie.Shapes[1], 1); With FrameActions do begin ConstantPool(['this', '_x', '_y', 'ZielX', 'ZielY']); Push([400, 0], [vtInteger, vtConstant8]); GetVariable; Push([1], [vtConstant8]); GetMember; Less2; _Not; label1 := _If.BranchOffsetMarker; PushConstant(0); GetVariable; Push([1, 10], [vtConstant8, vtInteger]); SetMember; SetMarker(label1); PushConstant(0); GetVariable; Push([1], [vtConstant8]); GetMember; Push(0); Less2; _Not; label2 := _If.BranchOffsetMarker; PushConstant(0); GetVariable; Push([1, 250], [vtConstant8, vtInteger]); SetMember; SetMarker(label2); PushConstant(0); GetVariable; PushConstant(2); GetMember; Push(0); Less2; _Not; label3 := _If.BranchOffsetMarker; PushConstant(0); GetVariable; Push([2, 250], [vtConstant8, vtInteger]); SetMember; SetMarker(label3); Push([300, 0], [vtInteger, vtConstant8]); GetVariable; PushConstant(2); GetMember; Less2; _Not; label4 := _If.BranchOffsetMarker; PushConstant(0); GetVariable; Push([2, 10], [vtConstant8, vtInteger]); SetMember; SetMarker(label4); Push([3, 4], [vtConstant8, vtInteger]); RandomNumber; SetVariable; Push([4, 4], [vtConstant8, vtInteger]); RandomNumber; SetVariable; PushConstant(0); GetVariable; PushConstant([1, 3]); GetVariable; PushConstant(0); GetVariable; PushConstant(1); GetMember; Add2; SetMember; PushConstant(0); GetVariable; PushConstant([2, 4]); GetVariable; PushConstant(0); GetVariable; PushConstant(2); GetMember; Add2; SetMember; end; ShowFrame; RemoveObject(1); FrameActions.GotoFrame(0); FrameActions.Play; ShowFrame; end; EA := TSWFExportAssets.Create; EA.Assets.Objects[EA.Assets.Add('bot')] := Pointer(LongInt(Movie.Sprites[1].CharacterId)); Movie.ObjectList.Add(EA); With Movie.FrameActions do begin ConstantPool(['max', 'i', 'zufall', 'bot', 'attachMovie', '_root', '_x', '_y', '_xscale', '_yscale', '_alpha']); Push([0, 100], [vtConstant8, vtInteger]); SetVariable; Push([1, 0], [vtConstant8, vtInteger]); SetVariable; label2 := SetMarker; PushConstant(1); GetVariable; PushConstant(0); GetVariable; Less2; _Not; label1 := _If.BranchOffsetMarker; Push([2, 150], [vtConstant8, vtInteger]); RandomNumber; SetVariable; Push([1], [vtConstant8]); GetVariable; PushConstant([3, 1]); GetVariable; Add2; Push([3, 3, 4], [vtConstant8, vtInteger, vtConstant8]); CallFunction; Pop; PushConstant(5); GetVariable; PushConstant([3, 1]); GetVariable; Add2; GetMember; Push([6, 800], [vtConstant8, vtInteger]); RandomNumber; SetMember; PushConstant(5); GetVariable; Push([3, 1], [vtConstant8, vtConstant8]); GetVariable; Add2; GetMember; Push([7, 360], [vtConstant8, vtInteger]); RandomNumber; SetMember; PushConstant(5); GetVariable; PushConstant([3, 1]); GetVariable; Add2; GetMember; PushConstant([8, 2]); GetVariable; SetMember; PushConstant(5); GetVariable; PushConstant([3, 1]); GetVariable; Add2; GetMember; PushConstant([9, 2]); GetVariable; SetMember; PushConstant(5); GetVariable; PushConstant([3, 1]); GetVariable; Add2; GetMember; PushConstant([10, 2]); GetVariable; SetMember; PushConstant([1, 1]); GetVariable; Increment; SetVariable; Jump.BranchOffsetMarker := label2; label2.JumpToBack := true; SetMarker(label1); end; Movie.ShowFrame; Movie.MakeStream; Movie.SaveToFile('snow.swf'); Movie.Free;