Home | Delphi SWF SDK | SlideShow Engine | Free source samples | Code library | Forum | Contact

Delphi SWF SDK

 

Demo with source

The part of code that creates this banner is below.

Discuss or ask at the forum>>
Download full delphi project BannerMaker binary (380Kb) and source.

The part of code UBanner.pas

  1. unit UBanner;
  2.  
  3. interface
  4.  
  5. uses
  6. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7. Dialogs, StdCtrls, ExtCtrls;
  8.  
  9. type
  10. TForm1 = class(TForm)
  11. Button1: TButton;
  12. SD: TSaveDialog;
  13. vclD: TImage;
  14. vclF: TImage;
  15. Button2: TButton;
  16. procedure Button1Click(Sender: TObject);
  17. procedure Button2Click(Sender: TObject);
  18. private
  19. { Private declarations }
  20. public
  21. { Public declarations }
  22. end;
  23.  
  24. var
  25. Form1: TForm1;
  26. implementation
  27. uses FlashObjects, SWFConst, SWFTools, ShellAPI, Math, SWFObjects;
  28.  
  29. {$R *.dfm}
  30. const _FPS = 14;
  31.  
  32. Function CalcFrame(sec: single): word;
  33. begin
  34. Result := Round(sec * _FPS);
  35. if Result = 0 then Result := 1;
  36. end;
  37.  
  38. Function Ease(k, x: single; less: boolean): single;
  39. begin
  40. if X = 0 then Result := 0
  41. else Result := Exp( (1 + k ) * Ln(Abs(x)));
  42. if less then Result := 1 - Result;
  43. end;
  44.  
  45. // =====================================================================
  46. // |
  47. // 468 x 60 |
  48. // |
  49. // =====================================================================
  50.  
  51. procedure TForm1.Button1Click(Sender: TObject);
  52. var
  53. il, FrCount: word;
  54. Movie: TFlashMovie;
  55. fntTahoma, fntCourier, fntDinCond: TFlashFont;
  56. Txt1, Txt2: TFLashText;
  57. SprButton1, SprButton2, SprStrel, TotalMC, ButEdg: TFlashSprite;
  58. ButSee, ButReply: TFlashButton;
  59. RR1, RR2, Strel, rImageD, rImageF, WhiteRect, Ballon: TFlashShape;
  60. imgD, imgF: TFlashImage;
  61. MTime: single;
  62. label1, label2: TSWFOffsetMarker;
  63.  
  64. Procedure FadeOut;
  65. var il: word;
  66. begin
  67. For il := 0 to CalcFrame(0.6) do
  68. with Movie.PlaceObject(WhiteRect, 103) do
  69. begin
  70. SetScale(1, 10);
  71. ColorTransform.addA := Round((il - CalcFrame(0.6)) / CalcFrame(0.6) * $FF);
  72. if il > 0 then RemoveDepth := true;
  73. Movie.ShowFrame;
  74. end;
  75. end;
  76.  
  77. Procedure FadeIn;
  78. var il: word;
  79. begin
  80. For il := 0 to CalcFrame(0.6) do
  81. with Movie.PlaceObject(WhiteRect, 103) do
  82. begin
  83. SetScale(1, 10);
  84. ColorTransform.addA := - Round(il / CalcFrame(0.6) * $FF);
  85. if il > 0 then RemoveDepth := true;
  86. Movie.ShowFrame;
  87. end;
  88. end;
  89.  
  90. begin
  91. if not SD.Execute then Exit;
  92. Movie := TFlashMovie.Create(0, 0, 468, 60, _FPS, scPix);
  93. Movie.Compressed := true;
  94. Movie.Protect := true;
  95.  
  96. // set movie background
  97. Movie.BackgroundColor.RGB := SWFRGB(clWhite);
  98.  
  99. // add font objects to use
  100. fntTahoma := Movie.AddFont(Font);
  101. fntTahoma.AntiAlias := true;
  102.  
  103. fntCourier := Movie.AddFont(Font);
  104. fntCourier.Name := 'Courier New';
  105. fntCourier.Bold := true;
  106. fntCourier.Size := 20;
  107.  
  108. fntDinCond := Movie.AddFont(Font);
  109. fntDinCond.Name := 'DinCond';
  110. fntDinCond.Size := 40;
  111.  
  112. //============================= SCENE 1 ============================================
  113. Movie.AddRectangle(0, 0, 468, 60).SetSolidColor(cswfTransparent);
  114. With Movie.AddButton(false, false) do
  115. begin
  116. AddRecord(Movie.Shapes[0], SWFButtonStateAll);
  117. OnClickActions.GetUrl('http://www.torry.net/cgi-bin/banners.fpl?region=34&campaign=266&banner=245&mode=CLICK', '_blank');
  118. end;
  119. Movie.PlaceObject(Movie.Buttons[0], 200);
  120.  
  121. Txt1 := Movie.AddText('This banner is created by', SWFRGBA(clBlack), fntCourier, Point(83, 8));
  122. Movie.PlaceObject(Txt1, 100);
  123.  
  124. // make the edit caret
  125. WhiteRect := Movie.AddRectangle(0, 0, 468, 22);
  126. WhiteRect.SetSolidColor(cswfWhite);
  127. Strel := Movie.AddLine(0, 0, 0, 22);
  128. Strel.SetLineStyle(2, cswfBlack);
  129. SprStrel := movie.AddSprite;
  130. SprStrel.PlaceObject(WhiteRect, 1);
  131. SprStrel.PlaceObject(Strel, 2);
  132. SprStrel.ShowFrame(CalcFrame(0.4));
  133. SprStrel.RemoveObject(2);
  134. SprStrel.ShowFrame(CalcFrame(0.4));
  135.  
  136. // move the caret alike entering the first line text
  137. for il := 0 to length(Txt1.Text) do
  138. with Movie.PlaceObject(SprStrel, 103) do
  139. begin
  140. SetTranslate(83 + il*12, 8);
  141. Movie.ShowFrame(CalcFrame(0.15));
  142. if il = 0 then Movie.ShowFrame(CalcFrame(1.45))
  143. else RemoveDepth := true;
  144. end;
  145.  
  146. Movie.ShowFrame(CalcFrame(1));
  147.  
  148. Txt1 := Movie.AddText('Delphi SWF SDK', SWFRGBA(clRed), fntCourier, Point(150, 30));
  149. Movie.PlaceObject(Txt1, 101);
  150.  
  151. // move the caret alike entering the second line text
  152. for il := 0 to length(Txt1.Text) do
  153. with Movie.PlaceObject(SprStrel, 103) do
  154. begin
  155. SetTranslate(150 + il*12, 30);
  156. Movie.ShowFrame(CalcFrame(0.15));
  157. if il = 0 then Movie.ShowFrame(CalcFrame(1.45));
  158. RemoveDepth := true;
  159. end;
  160.  
  161. Movie.ShowFrame(CalcFrame(0.5));
  162. Movie.RemoveObject(103);
  163. Movie.ShowFrame(CalcFrame(0.5));
  164.  
  165. FadeOut;
  166.  
  167. Movie.RemoveObject(100);
  168. Movie.RemoveObject(101);
  169.  
  170. // ========================= Scene 2 ======================================
  171.  
  172. // create image data from bitmap
  173. imgD := Movie.AddImage;
  174. imgD.LoadDataFromHandle(vclD.Picture.Bitmap.Handle);
  175.  
  176. rImageD :=Movie.AddShapeImage(imgD);
  177. Movie.PlaceObject(rImageD, 1).SetTranslate(150, 0);
  178. Txt1 := Movie.AddText('Delphi', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(220, 5));
  179. Movie.PlaceObject(Txt1, 10);
  180.  
  181. FadeIn;
  182. Movie.ShowFrame(CalcFrame(0.5));
  183. FadeOut;
  184.  
  185. Movie.RemoveObject(1);
  186. Movie.RemoveObject(10);
  187. // ========================= Scene 3 ======================================
  188.  
  189. Txt1 := Movie.AddText('+', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(230, 5));
  190. Movie.PlaceObject(Txt1, 10);
  191. FadeIn;
  192. Movie.ShowFrame(CalcFrame(0.2));
  193. FadeOut;
  194. Movie.RemoveObject(10);
  195. // ========================= Scene 4 ======================================
  196.  
  197. imgF := Movie.AddImage;
  198. imgF.LoadDataFromHandle(vclF.Picture.Bitmap.Handle);
  199.  
  200. rImageF :=Movie.AddShapeImage(imgF);
  201. Movie.PlaceObject(rImageF, 1).SetTranslate(150, 6);
  202. Txt1 := Movie.AddText('Flash', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(220, 5));
  203. Movie.PlaceObject(Txt1, 10);
  204.  
  205. FadeIn;
  206. Movie.ShowFrame(CalcFrame(0.5));
  207. FadeOut;
  208.  
  209. Movie.RemoveObject(1);
  210. Movie.RemoveObject(10);
  211.  
  212. // ========================= Scene 5 ======================================
  213.  
  214. Txt1 := Movie.AddText('et crossroad two technologies', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(30, 5));
  215. Movie.PlaceObject(Txt1, 10);
  216. FadeIn;
  217. Movie.ShowFrame(CalcFrame(2));
  218. FadeOut;
  219. Movie.RemoveObject(10);
  220.  
  221. // ========================= TotalMC ======================================
  222.  
  223. TotalMC := Movie.AddSprite;
  224.  
  225. // balls
  226. Ballon := Movie.AddCircle(0, 0, 5);
  227. Ballon.SetRadialGradient(SWFRGBA($FF, $FF, $DD, $FF), SWFRGBA(clNavy), 35, 35);
  228. TotalMC.PlaceObject(Ballon, 30).SetTranslate(170, 11);
  229. TotalMC.PlaceObject(Ballon, 31).SetTranslate(315, 11);
  230. TotalMC.PlaceObject(Ballon, 9).SetTranslate(242, 53);
  231.  
  232. // images
  233. TotalMC.PlaceObject(rImageD, 1).SetTranslate(85, 0);
  234. TotalMC.PlaceObject(rImageF, 2).SetTranslate(350, 6);
  235.  
  236. // text
  237. Txt1 := Movie.AddText('Delphi + Flash', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(0, 0));
  238. With TotalMC.PlaceObject(Txt1, 20) do
  239. begin
  240. SetPosition(185, -2);
  241. SetScale(0.55, 0.55);
  242. end;
  243. // white background
  244. With TotalMC.PlaceObject(Txt1, 19) do
  245. begin
  246. SetPosition(187, -1);
  247. SetScale(0.55, 0.55);
  248. ColorTransform.addR := $FF;
  249. ColorTransform.addG := $FF;
  250. ColorTransform.addB := $FF;
  251. end;
  252. With TotalMC.PlaceObject(Txt1, 18) do
  253. begin
  254. SetPosition(184, -1);
  255. SetScale(0.55, 0.55);
  256. ColorTransform.addR := $FF;
  257. ColorTransform.addG := $FF;
  258. ColorTransform.addB := $FF;
  259. end;
  260.  
  261. Txt1 := Movie.AddText('Delphi SWF SDK', cswfRed, fntDinCond, Point(0, 0));
  262. With TotalMC.PlaceObject(Txt1, 17) do
  263. begin
  264. SetPosition(182, 25);
  265. SetScale(0.55, 0.55);
  266. end;
  267. // white background
  268. With TotalMC.PlaceObject(Txt1, 16) do
  269. begin
  270. SetPosition(184, 25);
  271. SetScale(0.55, 0.55);
  272. ColorTransform.addR := $FF;
  273. ColorTransform.addG := $FF;
  274. ColorTransform.addB := $FF;
  275. end;
  276. With TotalMC.PlaceObject(Txt1, 15) do
  277. begin
  278. SetPosition(181, 25);
  279. SetScale(0.55, 0.55);
  280. ColorTransform.addR := $FF;
  281. ColorTransform.addG := $FF;
  282. ColorTransform.addB := $FF;
  283. end;
  284.  
  285.  
  286. TotalMC.FrameActions.Stop;
  287. TotalMC.ShowFrame;
  288.  
  289. // drawing oval
  290. SprStrel := Movie.AddSprite;
  291. For il := 1 to CalcFrame(1) do
  292. begin
  293. RR1 := Movie.AddArc(0, 0, 61, - 45, il / CalcFrame(1) * 360 - 45, false);
  294. RR1.SetLineStyle(1, SWFRGBA(clNavy));
  295. with SprStrel.PlaceObject(RR1, 1) do
  296. begin
  297. SetScale(1, 0.2);
  298. SetSkew(0, - 0.34);
  299. if il > 1 then RemoveDepth := true;
  300. end;
  301.  
  302. if il = CalcFrame(1) then
  303. With SprStrel.FrameActions do
  304. begin
  305. Stop;
  306. SetTarget('_parent');
  307. Play;
  308. end;
  309. SprStrel.ShowFrame;
  310. end;
  311. TotalMC.PlaceObject(SprStrel, 3).SetTranslate(275, 33);
  312. With TotalMC.PlaceObject(SprStrel, 4) do
  313. begin
  314. SetTranslate(210, 33);
  315. SetScale(-1, 1);
  316. end;
  317. // sprite is stoped and will be playing at the next scene of the movie
  318. TotalMC.FrameActions.Stop;
  319. TotalMC.ShowFrame;
  320.  
  321. // star and ball at the ovals crossing
  322. RR2 := Movie.AddStar(0, 0 , 25, -15, 10);
  323. RR2.SetRadialGradient(SWFRGBA($FF, $80, $00, $FF), SWFRGBA($FA, $FA, $FA, $FA), 50, 50);
  324. with TotalMC.PlaceObject(RR2, 10) do
  325. begin
  326. SetTranslate(242, 53);
  327. SetScale(0.5, 0.7);
  328. end;
  329. TotalMC.ShowFrame;
  330.  
  331. with TotalMC.PlaceObject(RR2, 10) do
  332. begin
  333. SetTranslate(242, 53);
  334. SetScale(1.1, 0.8);
  335. RemoveDepth := true;
  336. end;
  337. TotalMC.ShowFrame;
  338.  
  339. with TotalMC.PlaceObject(RR2, 10) do
  340. begin
  341. SetTranslate(242, 53);
  342. SetScale(1.1, 1.2);
  343. ColorTransform.addA := - 60;
  344. RemoveDepth := true;
  345. end;
  346.  
  347. TotalMC.ShowFrame;
  348.  
  349. with TotalMC.PlaceObject(RR2, 10) do
  350. begin
  351. SetTranslate(242, 53);
  352. SetScale(1.1, 1.2);
  353. ColorTransform.addA := - 180;
  354. RemoveDepth := true;
  355. end;
  356.  
  357. TotalMC.RemoveObject(10);
  358.  
  359. TotalMC.ShowFrame(CalcFrame(0.5));
  360. with TotalMC.FrameActions do
  361. begin
  362. Stop;
  363. SetTarget('_root');
  364. Play;
  365. SetTarget('');
  366. end;
  367. TotalMC.ShowFrame;
  368.  
  369. // light is running over the oval
  370. SprStrel := Movie.AddSprite;
  371. For il := 1 to CalcFrame(1) do
  372. begin
  373. RR1 := Movie.AddArc(0, 0, 61, il/ CalcFrame(1) * 360, (il + 0.5) / CalcFrame(1) * 360, false);
  374. RR1.SetLineStyle(3, SWFRGBA(255, 196, 69, $EE));
  375. with SprStrel.PlaceObject(RR1, 1) do
  376. begin
  377. SetScale(1, 0.2);
  378. SetSkew(0, - 0.34);
  379. if il > 1 then RemoveDepth := true;
  380. end;
  381. SprStrel.ShowFrame;
  382. end;
  383. TotalMC.PlaceObject(SprStrel, 5).SetTranslate(275, 33);
  384.  
  385. With TotalMC.PlaceObject(SprStrel, 7) do
  386. begin
  387. SetTranslate(210, 33);
  388. SetScale(-1, 1);
  389. Name := 'd1';
  390. end;
  391. // the second oval lightening begins to play from the second part to get lights
  392. // to run in different phases
  393. With TotalMC.FrameActions do
  394. begin
  395. Stop;
  396. SetTarget('d1');
  397. GotoAndPlay(CalcFrame(0.5));
  398. end;
  399. TotalMC.ShowFrame;
  400.  
  401. // place TotalMC at the scene
  402. Movie.PlaceObject(TotalMC, 1).Name := 'total';
  403.  
  404. FadeIn;
  405. Movie.ShowFrame(CalcFrame(0.5));
  406.  
  407. with Movie.FrameActions do
  408. begin
  409. Stop;
  410. SetTarget('total');
  411. Play;
  412. end;
  413. Movie.ShowFrame;
  414.  
  415.  
  416. // ==================================== Button 'See source' ==================================
  417. RR1 := Movie.AddRoundRect(Rect(0, 0, 80, 20), 4);
  418. RR1.SetLineStyle(1, cswfGray70);
  419. RR1.SetSolidColor(cswfWhite);
  420.  
  421. RR2 := Movie.AddRoundRect(Rect(2, 2, 78, 18), 2);
  422. RR2.SetLineStyle(1, cswfGray30);
  423. RR2.SetSolidColor(SWFRGBA(240, 240, 240, 255));
  424.  
  425. Strel := Movie.AddShape;
  426. Strel.SetShapeBound(-4, -2, 4, 4);
  427. Strel.SetLineStyle(1, cswfGray80);
  428. With Strel.Edges do
  429. begin
  430. MoveTo(-3, -4);
  431. LineTo(0, 0);
  432. LineTo(-3, 4);
  433. MoveTo(0, -4);
  434. LineTo(3, 0);
  435. LineTo(0, 4)
  436. end;
  437.  
  438. SprStrel := Movie.AddSprite;
  439. for il := 1 to CalcFrame(0.5) do
  440. with SprStrel.PlaceObject(Strel, 1) do
  441. begin
  442. SetTranslate(70, 11);
  443. ColorTransform.addA := - il * 25;
  444. if il > 1 then RemoveDepth := true;
  445. SprStrel.ShowFrame;
  446. end;
  447. for il := CalcFrame(0.5) downto 1 do
  448. with SprStrel.PlaceObject(Strel, 1) do
  449. begin
  450. SetTranslate(70, 11);
  451. ColorTransform.addA := - il * 25;
  452. RemoveDepth := true;
  453. SprStrel.ShowFrame;
  454. end;
  455.  
  456. Txt1 := Movie.AddText('See source', cswfGray80, fntTahoma, Point(7, 3));
  457.  
  458. ButEdg := Movie.AddSprite;
  459. ButEdg.PlaceObject(RR1, 1);
  460. ButEdg.PlaceObject(RR2, 2);
  461.  
  462. SprButton1 := Movie.AddSprite;
  463. SprButton1.PlaceObject(ButEdg, 1);
  464. SprButton1.PlaceObject(Txt1, 3);
  465. SprButton1.PlaceObject(SprStrel, 4);
  466. SprButton1.ShowFrame;
  467.  
  468. SprButton2 := Movie.AddSprite;
  469. SprButton2.PlaceObject(ButEdg, 1);
  470. SprButton2.PlaceObject(Txt1, 3).SetTranslate(1, 1);
  471. SprButton2.PlaceObject(SprStrel, 4).SetTranslate(1, 1);
  472. SprButton2.ShowFrame;
  473.  
  474. ButSee := Movie.AddButton;
  475. ButSee.AddRecord(RR1, [bsHitTest]);
  476. with ButSee.AddRecord(SprButton1, [bsUp]).ColorTransform do
  477. begin
  478. addB := 70;
  479. addA := -50;
  480. end;
  481. with ButSee.AddRecord(SprButton1, [bsOver]).ColorTransform do
  482. begin
  483. addR := 90;
  484. addG := 30;
  485. addB := -20;
  486. end;
  487. ButSee.AddRecord(SprButton2, [bsDown]).ColorTransform.addB := 70;
  488.  
  489. // ButSee.OnClickActions.GetUrl('http://www.delphiflash.com/sdk_demo2.html', '_blank');
  490. ButSee.OnClickActions.GetUrl('http://www.torry.net/cgi-bin/banners.fpl?region=34&campaign=266&banner=245&mode=CLICK', '_blank');
  491.  
  492. // ==================================== Button 'Repeat' ==================================
  493. Txt1 := Movie.AddText('Play again', cswfGray80, fntTahoma, Point(7, 3));
  494.  
  495. SprButton1 := Movie.AddSprite;
  496. SprButton1.PlaceObject(ButEdg, 1);
  497. SprButton1.PlaceObject(Txt1, 3);
  498. RR2 := Movie.AddShape;
  499. // RR2.SetShapeBound(-7, -4, 1, 0);
  500. RR2.SetLineStyle(1, cswfGray80);
  501. With RR2.Edges do
  502. begin
  503. MakeArc(0, 0, 5, 190, 160, false);
  504. MoveTo( -6, -3);
  505. LineTo( -5, 0);
  506. LineTo( -3, -2);
  507. RR2.Bounds.Rect := GetBoundsRect;
  508. end;
  509.  
  510.  
  511. with SprButton1.PlaceObject(RR2, 4) do
  512. begin
  513. SetTranslate(68, 10);
  514. end;
  515. SprButton1.ShowFrame;
  516.  
  517. SprButton2 := Movie.AddSprite;
  518. SprButton2.PlaceObject(ButEdg, 1);
  519. SprButton2.PlaceObject(Txt1, 3).SetTranslate(1, 1);
  520. with SprButton2.PlaceObject(RR2, 4) do
  521. begin
  522. SetTranslate(69, 11);
  523. end;
  524.  
  525. SprButton2.ShowFrame;
  526.  
  527. ButReply := Movie.AddButton;
  528. ButReply.AddRecord(RR1, [bsHitTest]);
  529. with ButReply.AddRecord(SprButton1, [bsUp]).ColorTransform do
  530. begin
  531. addB := 70;
  532. addA := -50;
  533. end;
  534.  
  535. with ButReply.AddRecord(SprButton1, [bsOver]).ColorTransform do
  536. begin
  537. addR := 90;
  538. addG := 30;
  539. addB := -20;
  540. end;
  541. ButReply.AddRecord(SprButton2, [bsDown]).ColorTransform.addB := 70;
  542.  
  543. with ButReply.OnClickActions do
  544. begin
  545. SetTarget('_root');
  546. Play;
  547. end;
  548.  
  549. //================================ Rolled text =======================================
  550. RR2 := Movie.AddRectangle(200, 0, 468, 10);
  551. RR2.SetLinearGradient(SWFRGBA(255,255,255,0), cswfWhite, 90);
  552.  
  553. txt2 := Movie.AddText('- visual objects creating (shape, button, text);<br>'+
  554. '- advanced objects (morphing shape, sprite);<br>'+
  555. '- all types of filling (solid, gradient, image);<br>'+
  556. '- device and embedding fonts;<br>'+
  557. '- sound (events, streaming);<br>'+
  558. '- video;<br>'+
  559. '- action commands;<br>'+
  560. '- any transition and transformation;<br>'+
  561. 'etc.', SWFRGBA(clNavy), fntTahoma, Rect(220, 60, 468, 200));
  562. txt2.NoSelect := true;
  563. txt2.HTML := true;
  564. txt2.UseOutlines := true;
  565. txt2.AutoSize := true;
  566.  
  567. SprStrel := Movie.AddSprite;
  568. With SprStrel.PlaceObject(WhiteRect, 1) do
  569. begin
  570. SetScale(1, 4);
  571. SetTranslate(200, 0);
  572. end;
  573.  
  574. SprStrel.PlaceObject(txt2, 5).Name := 'roll';
  575. SprStrel.PlaceObject(RR2, 10);
  576. With SprStrel.PlaceObject(RR2, 11) do
  577. begin
  578. SetScale(1, -1);
  579. SetTranslate(0, 50);
  580. end;
  581. SprStrel.PlaceObject(WhiteRect, 12).SetTranslate(200, 50);
  582.  
  583. SprStrel.ShowFrame;
  584.  
  585. // ==================================== Last scene ==================================
  586. Movie.RemoveObject(200);
  587. MTime := 0.7;
  588. FrCount := CalcFrame(MTime);
  589.  
  590. With Movie.PlaceObject(WhiteRect, 45) do
  591. begin
  592. SetScale(1, 4);
  593. SetTranslate(200, 0);
  594. end;
  595.  
  596. for il := 0 to FrCount do
  597. begin
  598. with Movie.PlaceObject(45) do
  599. begin
  600. ColorTransform.addA := - Round( $FF * (FrCount - il)/ FrCount);
  601. RemoveDepth := true;
  602. end;
  603.  
  604. with Movie.PlaceObject(TotalMC, 1) do
  605. begin
  606. SetTranslate( - Round( 145 * (Ease(3, (FrCount - il)/ FrCount, true))), 0);
  607. RemoveDepth := true;
  608. end;
  609.  
  610. With Movie.PlaceObject(ButReply, 51) do
  611. begin
  612. SetTranslate(300, 60 - Round(23 * (il)/ FrCount));
  613. if il > 0 then RemoveDepth := true;
  614. end;
  615.  
  616. With Movie.PlaceObject(ButSee, 50) do
  617. begin
  618. SetTranslate(383, 60 - Round(23 * (il)/ FrCount));
  619. if il > 0 then RemoveDepth := true;
  620. end;
  621.  
  622. Movie.PlaceObject(1).SetTranslate(il * 10, 0);
  623. Movie.ShowFrame;
  624. end;
  625.  
  626. With Movie.PlaceObject(SprStrel, 46).OnEnterFrame do
  627. begin
  628. ConstantPool(['roll', 'il']);
  629. Push([0, fpPosY, 0, fpPosY], [vtConstant8, vtInteger, vtConstant8, vtInteger]);
  630. GetProperty;
  631. Push([0, fpHeight], [vtConstant8, vtInteger]);
  632. GetProperty;
  633. Add2; // roll._y + roll._height
  634. Push(0);
  635. Less;
  636. label1 := _If.BranchOffsetMarker;
  637. Push([0, fpPosY], [vtConstant8, vtInteger]);
  638. GetProperty;
  639. Push(-0.5);
  640. Add;
  641. SetProperty;
  642. label2 := Jump.BranchOffsetMarker;
  643. SetMarker(label1);
  644. Push(60);
  645. SetProperty;
  646. PushConstant([1, 1, 1]);
  647. GetVariable;
  648. Increment;
  649. SetVariable;
  650. GetVariable;
  651. Push(3);
  652. Equals2;
  653. _Not;
  654. label1 := _If.BranchOffsetMarker;
  655. Stop;
  656. SetTarget('_root');
  657. Play;
  658. SetMarker(label1);
  659. SetMarker(label2);
  660. end;
  661.  
  662. with Movie.FrameActions do
  663. begin
  664. Stop;
  665. SetTarget('total');
  666. Play;
  667. end;
  668. Movie.ShowFrame;
  669. FadeOut;
  670.  
  671. Movie.MakeStream;
  672. Movie.SaveToFile(SD.FileName);
  673. Movie.Free;
  674.  
  675. ShellExecute(handle, PChar('open'), PChar(SD.FileName), nil, nil, sw_Normal);
  676. end;
  677.  
  678.  
  679. // =====================================================================
  680. // |
  681. // 125 x 160 |
  682. // |
  683. // =====================================================================
  684.  
  685. procedure TForm1.Button2Click(Sender: TObject);
  686. var
  687. il, FrCount: word;
  688. Movie: TFlashMovie;
  689. fntTahoma, fntCourier, fntDinCond: TFlashFont;
  690. Txt1, Txt2: TFLashText;
  691. SprButton1, SprButton2, SprStrel, TotalMC, ButEdg: TFlashSprite;
  692. ButSee: TFlashButton;
  693. RR1, RR2, Strel, rImageD, rImageF, WhiteRect, Ballon: TFlashShape;
  694. imgD, imgF: TFlashImage;
  695. MTime: single;
  696. label1, label2: TSWFOffsetMarker;
  697.  
  698. Procedure FadeOut;
  699. var il: word;
  700. begin
  701. For il := 0 to CalcFrame(0.6) do
  702. with Movie.PlaceObject(WhiteRect, 103) do
  703. begin
  704. SetScale(1, 10);
  705. ColorTransform.addA := Round((il - CalcFrame(0.6)) / CalcFrame(0.6) * $FF);
  706. if il > 0 then RemoveDepth := true;
  707. Movie.ShowFrame;
  708. end;
  709. end;
  710.  
  711. Procedure FadeIn;
  712. var il: word;
  713. begin
  714. For il := 0 to CalcFrame(0.6) do
  715. with Movie.PlaceObject(WhiteRect, 103) do
  716. begin
  717. SetScale(1, 10);
  718. ColorTransform.addA := - Round(il / CalcFrame(0.6) * $FF);
  719. if il > 0 then RemoveDepth := true;
  720. Movie.ShowFrame;
  721. end;
  722. end;
  723.  
  724. begin
  725. if not SD.Execute then Exit;
  726. Movie := TFlashMovie.Create(0, 0, 125, 160, _FPS, scPix);
  727. Movie.Compressed := true;
  728. Movie.Protect := true;
  729.  
  730. Movie.BackgroundColor.RGB := SWFRGB(clWhite);
  731.  
  732. fntTahoma := Movie.AddFont(Font);
  733. fntTahoma.AntiAlias := true;
  734.  
  735. fntCourier := Movie.AddFont(Font);
  736. fntCourier.Name := 'Courier New';
  737. fntCourier.Bold := true;
  738. fntCourier.Size := 14 ;
  739.  
  740. fntDinCond := Movie.AddFont(Font);
  741. fntDinCond.Name := 'DinCond';
  742. fntDinCond.Size := 40;
  743.  
  744. //============================= SCENE 1 ============================================
  745.  
  746. Txt1 := Movie.AddText('This banner', SWFRGBA(clBlack), fntCourier, Point(16, 45));
  747. Movie.PlaceObject(Txt1, 99);
  748.  
  749. WhiteRect := Movie.AddRectangle(0, 0, 468, 22);
  750. WhiteRect.SetSolidColor(cswfWhite);
  751. Strel := Movie.AddLine(0, 0, 0, 15);
  752. Strel.SetLineStyle(2, cswfBlack);
  753. SprStrel := movie.AddSprite;
  754. SprStrel.PlaceObject(WhiteRect, 1);
  755. SprStrel.PlaceObject(Strel, 2);
  756. SprStrel.ShowFrame(CalcFrame(0.4));
  757. SprStrel.RemoveObject(2);
  758. SprStrel.ShowFrame(CalcFrame(0.4));
  759.  
  760. for il := 0 to length(Txt1.Text) do
  761. with Movie.PlaceObject(SprStrel, 103) do
  762. begin
  763. SetTranslate(16 + Round(il*8.4), 45);
  764. Movie.ShowFrame(CalcFrame(0.15));
  765. if il = 0 then Movie.ShowFrame(CalcFrame(1.45))
  766. else RemoveDepth := true;
  767. end;
  768.  
  769. Movie.ShowFrame(CalcFrame(0.5));
  770.  
  771. Txt1 := Movie.AddText('is created by', SWFRGBA(clBlack), fntCourier, Point(8, 65));
  772. Movie.PlaceObject(Txt1, 100);
  773. for il := 0 to length(Txt1.Text) do
  774. with Movie.PlaceObject(SprStrel, 103) do
  775. begin
  776. SetTranslate(8 + Round(il*8.4), 65);
  777. Movie.ShowFrame(CalcFrame(0.15));
  778. if il = 0 then Movie.ShowFrame(CalcFrame(1));
  779. RemoveDepth := true;
  780. end;
  781. Movie.ShowFrame(CalcFrame(0.5));
  782.  
  783.  
  784. Txt1 := Movie.AddText('Delphi SWF SDK', SWFRGBA(clRed), fntCourier, Point(3, 85));
  785. Movie.PlaceObject(Txt1, 101);
  786.  
  787. for il := 0 to length(Txt1.Text) do
  788. with Movie.PlaceObject(SprStrel, 103) do
  789. begin
  790. SetTranslate(3 + Round(il*8.4), 85);
  791. Movie.ShowFrame(CalcFrame(0.15));
  792. if il = 0 then Movie.ShowFrame(CalcFrame(1));
  793. RemoveDepth := true;
  794. end;
  795.  
  796. Movie.ShowFrame(CalcFrame(0.5));
  797. Movie.RemoveObject(103);
  798. Movie.ShowFrame(CalcFrame(0.5));
  799.  
  800. FadeOut;
  801.  
  802. Movie.RemoveObject(99);
  803. Movie.RemoveObject(100);
  804. Movie.RemoveObject(101);
  805.  
  806. // ========================= Scene 2 ======================================
  807.  
  808. imgD := Movie.AddImage;
  809. imgD.LoadDataFromHandle(vclD.Picture.Bitmap.Handle);
  810.  
  811. rImageD :=Movie.AddShapeImage(imgD);
  812. Movie.PlaceObject(rImageD, 1).SetTranslate(41, 20);
  813. Txt1 := Movie.AddText('Delphi', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(20, 90));
  814. Movie.PlaceObject(Txt1, 10);
  815.  
  816. FadeIn;
  817. Movie.ShowFrame(CalcFrame(0.5));
  818. FadeOut;
  819.  
  820. Movie.RemoveObject(1);
  821. Movie.RemoveObject(10);
  822. // ========================= Scene 3 ======================================
  823.  
  824. Txt1 := Movie.AddText('+', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(55, 50));
  825. Movie.PlaceObject(Txt1, 10);
  826. FadeIn;
  827. Movie.ShowFrame(CalcFrame(0.2));
  828. FadeOut;
  829. Movie.RemoveObject(10);
  830. // ========================= Scene 4 ======================================
  831.  
  832. imgF := Movie.AddImage;
  833. imgF.LoadDataFromHandle(vclF.Picture.Bitmap.Handle);
  834.  
  835. rImageF :=Movie.AddShapeImage(imgF);
  836. Movie.PlaceObject(rImageF, 1).SetTranslate(39, 30);
  837. Txt1 := Movie.AddText('Flash', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(28, 90));
  838. Movie.PlaceObject(Txt1, 10);
  839.  
  840. FadeIn;
  841. Movie.ShowFrame(CalcFrame(0.5));
  842. FadeOut;
  843.  
  844. Movie.RemoveObject(1);
  845. Movie.RemoveObject(10);
  846.  
  847. // ========================= Scene 5 ======================================
  848.  
  849. Txt1 := Movie.AddText('et crossroad', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(0, 0));
  850. With Movie.PlaceObject(Txt1, 1) do
  851. begin
  852. SetScale(0.5, 0.5);
  853. SetTranslate(20, 45);
  854. end;
  855. Txt1 := Movie.AddText('two technologies', SWFRGBA(51, 51, 153, 255), fntDinCond, Point(0, 0));
  856. With Movie.PlaceObject(Txt1, 10) do
  857. begin
  858. SetScale(0.5, 0.5);
  859. SetTranslate(5, 75);
  860. end;
  861. FadeIn;
  862. Movie.ShowFrame(CalcFram