Flash 8 User Interface

The sample shows how to use Flash User Interface components. It contains a checkbox, a button, radiobuttons and textinput with using the event listeners model.
Sample uses SWF-template made in Flash8. Here is how to make ui8.swf template:
1. Open Macromedia Flash8
2. Make new document: File > New... > Flash Document
3. Open Components tool: Window > Components (Ctrl+F7)
4. Drag a Button, CheckBox, RadioBox, TextInput or other needed components to the document stage.
5. Set the unique instance name for each component, for example, "but", "lbl" etc. It's needed only to analize SWF-template (as Flash8 sets component settings).
6. Make SWF file: File > Export > Export movie. Set settings Version: Flash Player 8, AS version: ActionScript 2.0
Source archive: ui8.zip (630 KB)
Sample works
var Movie: TFlashMovie; EM: TFlashExternalMovie; tmpSprite: TFlashSprite; label1, label2, label3: TSWFOffsetMarker; procedure MakeCheckBox; begin tmpSprite := TFlashSprite.Create(Movie); tmpSprite.CharacterId := EM.Reader.FindIDFromName('CheckBox'); with Movie.PlaceObject(tmpSprite, Movie.MaxDepth + 1) do begin SetTranslate(10, 10); SetScale(1.2, 1); Name := 'ch1'; with OnConstruct do begin SetVar('label', 'Enabled button'); SetVar('selected', false); end; end; tmpSprite.Free; end; procedure MakeButton; begin tmpSprite := TFlashSprite.Create(Movie); tmpSprite.CharacterId := EM.Reader.FindIDFromName('Button'); with Movie.PlaceObject(tmpSprite, Movie.MaxDepth + 1) do begin SetTranslate(10, 50); SetScale(1.2, 1); Name := 'but1'; with OnConstruct do begin SetVar('label', 'Set Variant 2'); SetVar('enabled', false); SetVar('icon', 'ico1'); end; end; tmpSprite.Free; end; procedure MakeRadioButton(x, y: integer; _name, caption: string; sel: boolean); begin tmpSprite := TFlashSprite.Create(Movie); tmpSprite.CharacterId := EM.Reader.FindIDFromName('RadioButton'); with Movie.PlaceObject(tmpSprite, Movie.MaxDepth + 1) do begin SetTranslate(X, Y); Name := _name; with OnConstruct do begin SetVar('label', caption); SetVar('groupName', 'rgr1'); if sel then SetVar('selected', true); end; end; tmpSprite.Free; end; procedure MakeInput(); begin tmpSprite := TFlashSprite.Create(Movie); tmpSprite.CharacterId := EM.Reader.FindIDFromName('TextInput'); with Movie.PlaceObject(tmpSprite, Movie.MaxDepth + 1) do begin SetTranslate(220, 70); Name := 'edt'; with OnConstruct do begin SetVar('text', 'init text'); end; end; tmpSprite.Free; end; begin Movie := TFlashMovie.Create(0, 0, 400, 200, 12, scPix); Movie.Version := SWFVer8; Movie.Compressed := true; Movie.AddStar(8, 8, 8, 2, 6, false).SetSolidColor(cswfRed); Movie.ExportAssets('ico1', Movie.AddSprite(Movie.Shapes[0])); EM := Movie.AddExternalMovie('ui8.swf', eimResource); MakeCheckBox; MakeButton; MakeRadioButton(200, 10, 'rb1', 'Variant 1', true); MakeRadioButton(200, 30, 'rb2', 'Variant 2', false); MakeRadioButton(200, 50, 'rb3', 'Variant 3', false); MakeInput; with Movie.AddDynamicTextW('e_lbl', '', cswfBlack, Movie.AddFont('_sans', true, false, 10), rect(10, 110, 400, 150)) do begin AutoSize := true; Border := true; ReadOnly := true; NoSelect := true; end; Movie.PlaceObject(Movie.Texts.Last, Movie.MaxDepth + 1); {$IFDEF _ASCompiler} Movie.FrameActions.Compile( 'function chClick() { but1.enabled = ch1.selected; } ' + 'ch1.addEventListener("click", chClick); '#13 + 'function butClick() {rb2.selected = true;} '+ 'but1.addEventListener("click", butClick); '#13+ 'function onChangeText(){e_lbl = edt.text; }'+ 'edt.addEventListener("change", onChangeText);' ); {$ELSE} With Movie.FrameActions do begin ConstantPool(['but1', 'enabled', 'ch1', 'selected', 'chClick', 'click', 'addEventListener', 'rb2', 'butClick', 'e_lbl', 'edt', 'text', 'onChangeText', 'change']); label1 := DefineFunction('butClick', nil).CodeSizeMarker; Push([7], [vtConstant8]); GetVariable; Push([3, true], [vtConstant8, vtBoolean]); SetMember; SetMarker(label1, false); label2 := DefineFunction('chClick', nil).CodeSizeMarker; Push([0], [vtConstant8]); GetVariable; Push([1, 2], [vtConstant8, vtConstant8]); GetVariable; Push([3], [vtConstant8]); GetMember; SetMember; SetMarker(label2, false); label3 := DefineFunction('onChangeText', nil).CodeSizeMarker; Push([9, 10], [vtConstant8, vtConstant8]); GetVariable; Push([11], [vtConstant8]); GetMember; SetVariable; SetMarker(label3, false); Push([4], [vtConstant8]); GetVariable; Push([5, 2, 2], [vtConstant8, vtInteger, vtConstant8]); GetVariable; Push([6], [vtConstant8]); CallMethod; Pop; Push([8], [vtConstant8]); GetVariable; Push([5, 2, 0], [vtConstant8, vtInteger, vtConstant8]); GetVariable; Push([6], [vtConstant8]); CallMethod; Pop; Push([12], [vtConstant8]); GetVariable; Push([13, 2, 10], [vtConstant8, vtInteger, vtConstant8]); GetVariable; Push([6], [vtConstant8]); CallMethod; Pop; end; {$ENDIF} Movie.ShowFrame; Movie.MakeStream; Movie.SaveToFile('testui8.swf'); Movie.Free;