Q. How to use delphi make actionscript to swf file????
t is my delphi program code
Shapes[9] := Movie.AddRectangle(0,0,50,50); Shapes[9].SetLineStyle(1,cswfblack); shapes[9].SetSolidColor($CC,$CC,$CC,255); Sprite:=movie.AddSprite; Sprite.PlaceObject(Shapes[9],0); Txt := Movie.AddDynamicText('','test', cswfBlack, Fnt, Rect(125, 5, 225, 30)); txt.NoSelect:=true; Sprite.PlaceObject(txt,100); with Movie.PlaceObject(Sprite, 102) do begin SetTranslate(350, 45); name:='rightside'; //actionscript is add in here //ActionScript Event {rightside._visible=0;} end;
and i have other question
Txt := movie.AddDynamicText('','show the message', cswfBlack, Fnt, Rect(0, 0, 85, 20)); txt.NoSelect :=true; Shapes[11] := Movie.AddRectangle(0, 0, 85,20); shapes[11].SetSolidColor(cswfWhite); Shapes[11].SetLineStyle(1,cswfblack); Sprite:=movie.AddSprite; Sprite.PlaceObject(txt,2); Sprite.PlaceObject(Shapes[11],1); with Movie.PlaceObject(Sprite, 21) do begin SetTranslate(230, 630); with OnRelease do begin //ActionScript Event {rightside._visible=1;} end; end;
A. ActionScript for SWF can be added with several methods:
1. In the movie frame
with Movie.FrameActions do {some actions}
2. In the sprite (MovieClip) frame
Sprite := Movie.AddSprite; with Sprite.FrameActions do {some actions}
3. As events of the sprite
Sprite := Movie.AddSprite; with Movie.PlaceObject(Sprite, 1) do begin with OnMouseDown do {some actions} with OnMouseMove do {some actions} ... end;
Available events: OnKeyUp, OnKeyDown, OnMouseUp, OnMouseDown, OnMouseMove, OnUnload, OnEnterFrame, OnLoad, OnDragOver, OnRollOut, OnRollOver, OnReleaseOutside, OnRelease, OnPress, OnInitialize, OnData, OnConstruct, OnKeyPress, OnDragOut.
4. As events of the button
Button := Movie.AddButton(false, true); with Button.OnClickActions do {some actions}
Available events: OnClickActions, OnDragOutActions, OnDragOverActions, OnMenuDragOutActions, OnMenuDragOverActions, OnPressActions, OnReleaseActions, OnReleaseOutsideActions, OnRollOutActions, OnRollOverActions
The class TFlashActionScript contains all action instructions. To use ActionScript for programming you should use the Compile(...) method available only with ASC or Expert editions of the SDK. Main Demo contains a sample of ActionScript and similar action instructions using.
Q.
Shapes[9] := Movie.AddRectangle(0,0,320,580); //make a AddRectangle Shapes[9].SetLineStyle(1,cswfblack); shapes[9].SetSolidColor($CC,$CC,$CC,255); Sprite.PlaceObject(Shapes[9],0); with Movie.PlaceObject(Sprite, 102) do begin name:='rightside'; //default instance name SetTranslate(350, 45); with Movie.FrameActions do begin //added acript to control a AddRectangle the visible true or false Push([' _root.rightside','_visible',false]); //default rightside's visible is false //but make in swf can't be find the rightside name //so can't control the AddRectangle Movie.FrameActions.SetMember; end; end; Txt := Movie.AddDynamicTextw('','show the AddRectangle', cswfBlack, Fnt, Rect(0, 0, 85, 20)); txt.NoSelect :=true; Shapes[12] := Movie.AddRectangle(0, 0, 85,20); shapes[12].SetSolidColor(cswfWhite); Shapes[12].SetLineStyle(1,cswfblack); But := Movie.AddButton(false, true); But.AddRecord(Shapes[12], SWFButtonStateAll, 1); But.AddRecord(Txt, [bsUp, bsOver, bsHitTest], 2); with But.AddRecord(Txt, [bsDown], 2) do but.OnReleaseActions.Push(['_root.rightside','_visible',true]); but.OnReleaseActions.SetMember; //make a button to control the AddRectangle's visible true or false //but effect is nothing.
i think the question is ascript can't do before make swf file or my add ascript is wrong! what can i do ?
ActionScript code
on (release) { _root.rightside._visible = true; }
Q. These question have been resolved!
thank you very much!
how to add similar to what rightside._visible =! Rightside._visible the ActionScript????
ActionScript code
on (release) { leftside._visible =! leftside._visible; }
delphi code
Shapes[12] := Movie.AddRectangle(0, 0, 85,20); shapes[12].SetSolidColor(cswfblack); But.AddRecord(Shapes[12], [bsUp, bsOver,bsDown, bsHitTest], 1); with but.OnReleaseActions do begin //actions leftside._visible =! leftside._visible; end;
A. I use Parser tool from Free Stock
in main menu: Tools > Copy Pascal Actions to clipboard.
ConstantPool(['leftside', '_visible']); Push([0], [vtConstant8]); GetVariable; Push([1, 0], [vtConstant8, vtConstant8]); GetVariable; Push([1], [vtConstant8]); GetMember; _Not; SetMember;
Q. How to use Flash 8 blur filter in ActionScript ?
One of my old actionscript has line "import flash.filters.BlurFilter;" and it occurs EActionCompileError:
Class flash.filters.BlurFilter not found.
This actionscript makes blur effect on the movieclip and its fla can publish swf on Adobe Flash 8 Pro.
I use SWFSDK ASC Edition 2.1. How to solve this problem?
A. Use Movie.ASCompiler.LoadClassTable(...);
Declaration
procedure LoadClassTable(ClassPath: string);
Description
Loads the standard classes which are required for compiling but not included to swf.
Use this method to load the standard classes of Macromedia, for example
Movie.ASCompiler.LoadClassTable(‘C:\Program Files\Macromedia\Flash 8\en\First Run\Classes\Fp8\’);
Q. How to add ActionScript to the instance of MovieClip?
Dear author,
could you give me some example to add actionscript to the instance of movieClip (Sprite) placed on the scene ?
Say:
on(press) { startDrag(this,false); updateAfterEvent(); } on(release) { stopDrag(); }
In your main demo, I can find the example code for button and frame as but.CompileEvent(src) and Movie.FrameAction.Compile(src).
But I cannot call CompileEvent nor FrameAction.Compile for the movieClip instance. I use 2.1 ASC edition.
A. You can use onClipEvent() for sprite and on() for button.
var Movie: TFlashMovie; SP: TFlashSprite; Sh: TFlashShape; begin Movie := TFlashMovie.Create(0, 0, 300, 200, 30, scPix); Movie.Compressed := true; Sh := Movie.AddCircle(0, 0, 20); Sh.SetRadialGradient( cswfWhite, cswfNavy, 30, 30); SP := Movie.AddSprite(Sh); with Movie.PlaceObject(Sp, 1) do begin CompileEvent('onClipEvent(mouseDown) { startDrag(this,false); }' + 'onClipEvent(mouseUp) { stopDrag(); }'); SetTranslate(50, 50); end; Movie.MakeStream; Movie.SaveToFile('drag.SWF'); Movie.Free; end;
Q. How to define linkage identifier of movieclip?
I often use linkage identifier in my actionscript.
mc = _root.mama_mc.attachMovie(linkagename,"child"+i, Depth);
TFlashPlaceObject.Name property must be the instance name of the object not the linkage.
How to define linkage name to the movieclip of TFlashSprite in Delphi coding?
I am trying to translate some of my flash actionscripts into your DelphiSDK. And I always feel very awkward with the lack of information. Is there any site to find more practical sample of DelphiSDK?
A. The PlaceObject.Name value setting is equal to an instance name setting in Flash IDE.
If the linkage name should be set without setting the object to a stage then use ExportAssets.
Sprite := Movie.AddSprite(); Movie.ExportAssets("child1", Sprite.CharacterID);
We tried to show some main samples of the Delphi SWF SDK using and you can find them at our site. Also, you can describe what sample you would like to see.
Q. Nested function occurs compile error.
The following description occurs ActionScript Error at the function definition FadeOnEnterFrame().
No error occurs in Flash original IDE (Ver 7 and Ver 8 ) as always. Is there any help ?
function McFadeImage(mc:MovieClip) { with (mc) { _alpha = 0; .... } function FadeOnEnterFrame() { with (mc) { _alpha += (100-_alpha)/10; if (_alpha>995/10 ) { _alpha = 100; delete pict_mc.onEnterFrame; } } } pict_mc.onEnterFrame = FadeOnEnterFrame; }
A. Sorry, the compiler doesnt support nested functions in other functions.
// not support: function func1() { var a: Number; function func2() { a = 10; } func2(); } // use function func1() { var a: Number; func2(a); } function func2(a: Number) { a = 10; }
It wil be added to folowing releases.
Q. ExportAssets might be not enough to use linkage? I tried to use ExportAssets call to use linkage in ActionScript.
But ExportAssets does not lead me to the final goal.
All I want to do is to make a simple thumbnail viewer with Flash (both in Flash IDE and SWFSDK for my prerequisition).
http://chacha.gotdns.com/flashex/linkage/viewer.swf
In Flash IDE(Flash MX 2004 or Flash 8 ) , things are very easy.
I only add one MovieClip to the library: 1. MC consists of one shape rectangle (say 180x140dot for example.) 2. MC has Linkage property: Identifier = thumb Export to actionscript Export to the first frame.
Then I add the following actionscript to the 1st frame.
//"MyDir" folder contains pict0_.jpg .... pict8_.jpg (160x120dot). MyDir = "../chaimg/thumb/"; cellwd = 180; cellht = 140; for (var i = 0; i<=8; i++) { var thumb_mc = _root.attachMovie("thumb", "thumb"+i, _root.getNextHighestDepth()); thumb_mc.loadMovie(MyDir+"pict"+i+"_.jpg"); thumb_mc._x = cellwd * (i%3); thumb_mc._y = cellht * Math.floor(i/3);
The resulting swf shows thumbnail images in 3x3 table as shown in the URL above.
In Delphi, I followed the IDE operation above as:
procedure TForm1.Button1Click(Sender: TObject); var Movie:TFlashMovie; McThumb:TFlashSprite; Shape:TFlashShape; begin try Movie := TFlashMovie.Create(0, 0, 640,480, 30, scPix); Movie.Compressed := true; //MC for thumbnail image. McThumb := Movie.AddSprite; Shape := Movie.AddRectangle(0,0,180,140); Shape.SetSolidColor(20,20,20,$1F); McThumb.PlaceObject(Shape, 1).SetTranslate(0,0); Movie.ExportAssets('thumb',McThumb.CharacterId); // Export it to actionscript --- how to describe it ? // Export it to the first frame. --- how to describe it ? Movie.FrameActions.Compile(Memo1.Lines); //TMemo:Memo1.Lines contains the same script above. Movie.ShowFrame(1); Movie.MakeStream; Movie.SaveToFile('viewer.swf'); finally Movie.Free; end; end;
But resulting swf shows nothing on the screen.
I think it might be due to no lines corresponding to the linkage setting "export to action script and to the frame".
Could you give me some advice?
A. Hi,
I modified your Delphi code a little:
procedure TForm1.Button1Click(Sender: TObject); var Movie:TFlashMovie; McThumb:TFlashSprite; Shape:TFlashShape; begin try Movie := TFlashMovie.Create(0, 0, 640, 480, 30, scPix); Movie.Compressed := true; Movie.Version := SWFVer7; //MC for thumbnail image. Shape := Movie.AddRectangle(0, 0, 180, 140); Shape.SetSolidColor(20, 20, 20, $1F); McThumb := Movie.AddSprite(Shape); Movie.ExportAssets('thumb', McThumb.CharacterId); Movie.FrameActions.Compile(Memo1.Lines); Movie.ShowFrame; Movie.MakeStream; Movie.SaveToFile('viewer.swf'); finally Movie.Free; end; end;
Please pay attention to my adding an swf version value, because getNextHighestDepth is supported beginning from Flash Player 7.