{"id":168,"date":"2005-12-20T00:52:40","date_gmt":"2005-12-19T23:52:40","guid":{"rendered":"http:\/\/www.craigmurphy.com\/blog\/?p=168"},"modified":"2005-12-20T01:00:08","modified_gmt":"2005-12-20T00:00:08","slug":"creating-swf-movies-in-delphi","status":"publish","type":"post","link":"http:\/\/www.craigmurphy.com\/blog\/?p=168","title":{"rendered":"Creating SWF movies in Delphi"},"content":{"rendered":"<p>I reviewed <a href=\"http:\/\/www.delphiflash.com\/\">Delphi+Flash<\/a> for <a href=\"http:\/\/www.thedelphimagazine.com\">The Delphi Magazine<\/a>: it&#8217;s a great product and is especially useful if you need to add animation to your application.  <\/p>\n<p><img decoding=\"async\" alt=\"Merry Xmas\" vspace=\"8\" hspace=\"8\" border=\"2\"  src=\"http:\/\/www.craigmurphy.com\/blog\/wp-images\/Dec2005\/Fig1.gif\" \/><\/p>\n<p>Here are a couple of sample animations:<\/p>\n<p><a href=\"http:\/\/www.craigmurphy.com\/blog\/wp-images\/Dec2005\/demo.swf\">Example SWF 1<\/a><br \/>\n<a href=\"http:\/\/www.craigmurphy.com\/blog\/wp-images\/Dec2005\/snow.swf\">Example SWF 2<\/a><\/p>\n<p>And some sample code:<\/p>\n<p><code><br \/>\n var Movie: TFlashMovie;<br \/>\n     label1, label2, label3, label4: TSWFOffsetMarker;<br \/>\n     EA: TSWFExportAssets;<br \/>\nbegin<br \/>\n  Movie := TFlashMovie.Create(0, 0, 400 * twips, 200 * twips, 20);<br \/>\n  Movie.Version := 6;<br \/>\n  Movie.SystemCoord := scPix;<\/p>\n<p>  Movie.AddRectangle(0, 0, 400, 300).SetLinearGradient(SWFRGBA($663300), SWFRGBA($CCFF99), 270);<br \/>\n  Movie.PlaceObject(Movie.Shapes[0], 1);<br \/>\n  Movie.BackgroundColor.RGB := SWFRGB(0,0,0);<\/p>\n<p>{ Text }<br \/>\n  Movie.AddFont(Font, false);<br \/>\n  With Movie.Fonts[0] do<br \/>\n   begin<br \/>\n    Size := 2 * twips;<br \/>\n    Name := 'Times New Roman';<br \/>\n    Bold := true;<br \/>\n   end;<br \/>\n  Movie.AddText('The Delphi Magazine', cswfWhite, Movie.Fonts[0], Point(0, 100), taRight);<br \/>\n  Movie.AddSprite;<br \/>\n  With Movie.Sprites[0] do<br \/>\n    begin<br \/>\n     PlaceObject(Movie.Texts[0], 10);<br \/>\n     with PlaceObject(Movie.Texts[0], 9) do<br \/>\n      begin<br \/>\n       SetTranslate(2, 2);<br \/>\n       InitColorTransform(true, -$FF, -$FF, -$FF, -150, false, 0, 0, 0, 0, true);<br \/>\n      end;<br \/>\n    end;<br \/>\n  Movie.PlaceObject(Movie.Sprites[0], 10000).SetTranslate(395, 0);<\/p>\n<p>{ one snow }<br \/>\n  Movie.AddStar(0, 0, 3, -3, 4).SetSolidColor(SWFRGBA($EE, $EE, $FF, $DD));<\/p>\n<p>  Movie.AddSprite;<br \/>\n  With Movie.Sprites[1] do<br \/>\n   begin<br \/>\n    PlaceObject(Movie.Shapes[1], 1);<br \/>\n    With FrameActions do<br \/>\n      begin<br \/>\n       ConstantPool(['this', '_x', '_y', 'ZielX', 'ZielY']);<br \/>\n       Push([400, 0], [vtInteger, vtConstant8]);<br \/>\n       GetVariable;<br \/>\n       Push([1], [vtConstant8]);<br \/>\n       GetMember;<br \/>\n       Less2;<br \/>\n       _Not;<br \/>\n       label1 := _If.BranchOffsetMarker;<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       Push([1, 10], [vtConstant8, vtInteger]);<br \/>\n       SetMember;<br \/>\n       SetMarker(label1);<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       Push([1], [vtConstant8]);<br \/>\n       GetMember;<br \/>\n       Push(0);<br \/>\n       Less2;<br \/>\n       _Not;<br \/>\n       label2 := _If.BranchOffsetMarker;<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       Push([1, 250], [vtConstant8, vtInteger]);<br \/>\n       SetMember;<br \/>\n       SetMarker(label2);<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       PushConstant(2);<br \/>\n       GetMember;<br \/>\n       Push(0);<br \/>\n       Less2;<br \/>\n       _Not;<br \/>\n       label3 := _If.BranchOffsetMarker;<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       Push([2, 250], [vtConstant8, vtInteger]);<br \/>\n       SetMember;<br \/>\n       SetMarker(label3);<br \/>\n       Push([300, 0], [vtInteger, vtConstant8]);<br \/>\n       GetVariable;<br \/>\n       PushConstant(2);<br \/>\n       GetMember;<br \/>\n       Less2;<br \/>\n       _Not;<br \/>\n       label4 := _If.BranchOffsetMarker;<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       Push([2, 10], [vtConstant8, vtInteger]);<br \/>\n       SetMember;<br \/>\n       SetMarker(label4);<br \/>\n       Push([3, 4], [vtConstant8, vtInteger]);<br \/>\n       RandomNumber;<br \/>\n       SetVariable;<br \/>\n       Push([4, 4], [vtConstant8, vtInteger]);<br \/>\n       RandomNumber;<br \/>\n       SetVariable;<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       PushConstant([1, 3]);<br \/>\n       GetVariable;<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       PushConstant(1);<br \/>\n       GetMember;<br \/>\n       Add2;<br \/>\n       SetMember;<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       PushConstant([2, 4]);<br \/>\n       GetVariable;<br \/>\n       PushConstant(0);<br \/>\n       GetVariable;<br \/>\n       PushConstant(2);<br \/>\n       GetMember;<br \/>\n       Add2;<br \/>\n       SetMember;<br \/>\n      end;<br \/>\n    ShowFrame;<br \/>\n    RemoveObject(1);<br \/>\n    FrameActions.GotoFrame(0);<br \/>\n    FrameActions.Play;<br \/>\n    ShowFrame;<br \/>\n   end;<\/p>\n<p>  EA := TSWFExportAssets.Create;<br \/>\n  EA.Assets.Objects[EA.Assets.Add('bot')] := Pointer(LongInt(Movie.Sprites[1].CharacterId));<br \/>\n  Movie.ObjectList.Add(EA);<\/p>\n<p>  With Movie.FrameActions do<br \/>\n   begin<br \/>\n     ConstantPool(['max', 'i', 'zufall', 'bot', 'attachMovie', '_root', '_x', '_y', '_xscale', '_yscale', '_alpha']);<br \/>\n     Push([0, 100], [vtConstant8, vtInteger]);<br \/>\n     SetVariable;<br \/>\n     Push([1, 0], [vtConstant8, vtInteger]);<br \/>\n     SetVariable;<br \/>\n     label2 := SetMarker;<br \/>\n     PushConstant(1);<br \/>\n     GetVariable;<br \/>\n     PushConstant(0);<br \/>\n     GetVariable;<br \/>\n     Less2;<br \/>\n     _Not;<br \/>\n     label1 := _If.BranchOffsetMarker;<br \/>\n     Push([2, 150], [vtConstant8, vtInteger]);<br \/>\n     RandomNumber;<br \/>\n     SetVariable;<br \/>\n     Push([1], [vtConstant8]);<br \/>\n     GetVariable;<br \/>\n     PushConstant([3, 1]);<br \/>\n     GetVariable;<br \/>\n     Add2;<br \/>\n     Push([3, 3, 4], [vtConstant8, vtInteger, vtConstant8]);<br \/>\n     CallFunction;<br \/>\n     Pop;<br \/>\n     PushConstant(5);<br \/>\n     GetVariable;<br \/>\n     PushConstant([3, 1]);<br \/>\n     GetVariable;<br \/>\n     Add2;<br \/>\n     GetMember;<br \/>\n     Push([6, 800], [vtConstant8, vtInteger]);<br \/>\n     RandomNumber;<br \/>\n     SetMember;<br \/>\n     PushConstant(5);<br \/>\n     GetVariable;<br \/>\n     Push([3, 1], [vtConstant8, vtConstant8]);<br \/>\n     GetVariable;<br \/>\n     Add2;<br \/>\n     GetMember;<br \/>\n     Push([7, 360], [vtConstant8, vtInteger]);<br \/>\n     RandomNumber;<br \/>\n     SetMember;<br \/>\n     PushConstant(5);<br \/>\n     GetVariable;<br \/>\n     PushConstant([3, 1]);<br \/>\n     GetVariable;<br \/>\n     Add2;<br \/>\n     GetMember;<br \/>\n     PushConstant([8, 2]);<br \/>\n     GetVariable;<br \/>\n     SetMember;<br \/>\n     PushConstant(5);<br \/>\n     GetVariable;<br \/>\n     PushConstant([3, 1]);<br \/>\n     GetVariable;<br \/>\n     Add2;<br \/>\n     GetMember;<br \/>\n     PushConstant([9, 2]);<br \/>\n     GetVariable;<br \/>\n     SetMember;<br \/>\n     PushConstant(5);<br \/>\n     GetVariable;<br \/>\n     PushConstant([3, 1]);<br \/>\n     GetVariable;<br \/>\n     Add2;<br \/>\n     GetMember;<br \/>\n     PushConstant([10, 2]);<br \/>\n     GetVariable;<br \/>\n     SetMember;<br \/>\n     PushConstant([1, 1]);<br \/>\n     GetVariable;<br \/>\n     Increment;<br \/>\n     SetVariable;<br \/>\n     Jump.BranchOffsetMarker := label2;<br \/>\n     label2.JumpToBack := true;<br \/>\n     SetMarker(label1);<br \/>\n   end;<\/p>\n<p>  Movie.ShowFrame;<br \/>\n  Movie.MakeStream;<br \/>\n  Movie.SaveToFile('demo.swf');<br \/>\n  Movie.Free;<\/p>\n<p>  ShellExecute(handle, 'open', 'demo.swf', nil, nil, SW_Normal);<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I reviewed Delphi+Flash for The Delphi Magazine&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,4,3],"tags":[],"class_list":["post-168","post","type-post","status-publish","format-standard","hentry","category-net","category-delphi","category-development"],"_links":{"self":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168"}],"version-history":[{"count":0,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/168\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}