Sample: Shapes.vbs - shapes and filling types
Submitted by eLenka on 19 April, 2011 - 13:13
Generating shapes (circle, rectangle, star, ellipse, shaped image and other simple shapes) using the SWF Scout
Below you will find the source code of Shapes example (Shapes.vbs) that demonstrates supported shape objects and supported filling types (including image fill type) in SWF Scout SDK.
Generated Flash Movie:
VB Source Code:
' Shapes.vbs W = 640 ' width H = 480 ' height Set Movie = CreateObject("SWFScout.FlashMovie") Movie.InitLibrary "demo","demo" Movie.BeginMovie 0,0,W,H,1,12,6 Movie.Compressed = true Movie.SetBackgroundColor 255,255,255 Font = Movie.AddFont( "Arial",12,true,false,false,false,0) FontBig = Movie.AddFont("Arial",40,true,false,false,false,DEFAULT_CHARSET) ' SHAPES Text = Movie.AddText2("SHAPES",0,0,0,255,FontBig, W / 2, H / 2,2) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Movie.ShowFrame 10 Movie.PLACE_FadeIn 0.5 ' fade in ' shapes ' all kinds of shapes ' rectangle Text = Movie.AddText("Rectangle",0,0,0,255,Font, 0, 10, 150, 160) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Rectangle 0, 40, 150, 165 Movie.SHAPE_SetSolidColor 145,245,245,true,255 Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' circle Text = Movie.AddText("Circle",0,0,0,255,Font, 160, 10, 310, 165) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Circle 220, 105, 60 Movie.SHAPE_SetSolidColor 145,145,100,true,255 Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' pie Text = Movie.AddText("Pie",0,0,0,255,Font, 320, 10, 470, 165) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Pie 375, 105, 60, 60, 0, 270 Movie.SHAPE_SetSolidColor 245,145,145,true,155 Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' star Text = Movie.AddText("Star",0,0,0,255,Font, 470, 10, 640, 165) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Star 525,105,60,15,8,True Movie.SHAPE_SetSolidColor 135,135,200,true,215 Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' polygon Text = Movie.AddText("Polygon",0,0,0,255,Font, 0, 170, 160, 230) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape= Movie.AddShape Movie.SHAPE_BeginPolygon Movie.SHAPE_AddPolygonPoint 10,210 Movie.SHAPE_AddPolygonPoint 0,230 Movie.SHAPE_AddPolygonPoint 40,290 Movie.SHAPE_AddPolygonPoint 50,250 Movie.SHAPE_AddPolygonPoint 60,245 Movie.SHAPE_AddPolygonPoint 65,240 Movie.SHAPE_EndPolygon Movie.SHAPE_SetSolidColor 135,135,200,true,215 Movie.PlaceShape Shape,Movie.CurrentMaxDepth 'Arc (closed) Text = Movie.AddText("Arc",0,0,0,255,Font, 170, 170, 320, 230) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Arc 240, 290,60,50, 15,275,TRUE Movie.SHAPE_SetSolidColor 135,135,200,true,215 Movie.PlaceShape Shape,Movie.CurrentMaxDepth 'Ellipse Text = Movie.AddText("Ellipse",0,0,0,255,Font, 340, 170, 470, 230) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Ellipse 340, 230,420,390 Movie.SHAPE_SetSolidColor 115,165,200,true,215 Movie.PlaceShape Shape,Movie.CurrentMaxDepth 'Ring Text = Movie.AddText("Ring",0,0,0,255,Font, 510, 170, 600, 230) Movie.PlaceText Text,Movie.CurrentMaxDepth' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Ring 540, 290,50,60 Movie.SHAPE_SetSolidColor 95,125,90,true,215 Movie.PlaceShape Shape,Movie.CurrentMaxDepth 'Diamond Text = Movie.AddText("Diamond",0,0,0,255,Font, 0, 320, 170, 400) Movie.PlaceText Text,Movie.CurrentMaxDepth' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Diamond 0, 360,170,480 Movie.SHAPE_SetSolidColor 155,105,200,true,215 Movie.PlaceShape Shape,Movie.CurrentMaxDepth Movie.ShowFrame 30 ' global fadeout ' place solid rectangle to make fadout on whole screen Shape = Movie.AddShape Movie.SHAPE_Rectangle 0, 0, W, H Movie.SHAPE_SetSolidColor 255,255,255,true,255 Movie.PlaceShape Shape,Movie.CurrentMaxDepth Movie.PLACE_FadeOut 1 ' Gradient and filling types Text = Movie.AddText2("Filling Types",0,0,0,255,FontBig, W / 2 - 200, H / 2,staCenter) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Movie.ShowFrame 10 Movie.PLACE_FadeIn 0.5 ' fade in ' Rectangles ' empty rectangle Text = Movie.AddText("Empty",0,0,0,255,Font, 0, 10, 150, 160) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Rectangle 0, 40, 150, 165 i= Movie.SHAPE_AddLineStyle(55,65,75,true,105,12) Movie.SHAPE_LineStyleNum=i Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' solid color rectangle Text = Movie.AddText ("Solid Color",0,0,0,255,Font, 160, 10, 310, 165) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Rectangle 160, 40, 310, 165 Movie.SHAPE_SetSolidColor 86,90,75,true,105 Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' image fill rectangle Text = Movie.AddText("Image",0,0,0,255,Font, 320, 10, 470, 165) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Rectangle 320, 40, 470, 165 Img= Movie.AddImageFromFilename("FillImage.jpg") Movie.SHAPE_SetImageFill Img,sfimFit Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' image fill rectangle (with Alpha) Text = Movie.AddText ("Image with Alpha",0,0,0,255,Font, 470, 10, 640, 165) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Rectangle 480, 40, 630, 165 Img= Movie.AddImageFromFilename ("FillImage2.jpg") Movie.IMAGE_MakeAlphaLayer 140 Movie.SHAPE_SetImageFill Img,sfimFit Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' ------------- ' gradients ' ------------- ' linear gradient Text = Movie.AddText ("Linear Gradient",0,0,0,255,Font, 0, 170, 160, 230) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Rectangle 0, 210, 140, 375 Movie.SHAPE_BeginLinearGradient false Movie.SHAPE_AddLinearGradientColor 86,90,75,105,1 Movie.SHAPE_AddLinearGradientColor 255,255,255,255,233 Movie.SHAPE_AddLinearGradientColor 185,100,25,50,1 Movie.SHAPE_AddLinearGradientColor 255,255,255,255,233 Movie.SHAPE_EndLinearGradient 45 Movie.PlaceShape Shape,Movie.CurrentMaxDepth ' radial gradient Text = Movie.AddText ("Radial Gradient",0,0,0,255,Font, 170, 170, 320, 230) Movie.PlaceText Text,Movie.CurrentMaxDepth ' place text Movie.PLACE_FadeOut 0.5 ' fade out text Shape = Movie.AddShape Movie.SHAPE_Rectangle 160, 210, 300, 375 Movie.SHAPE_BeginRadialGradient Movie.SHAPE_AddRadialGradientColor 214,125,45,200 Movie.SHAPE_AddRadialGradientColor 135,80,245,200 Movie.SHAPE_EndRadialGradient 35,35 Movie.PlaceShape Shape,Movie.CurrentMaxDepth Movie.ShowFrame 20 ' place solid rectangle to make fadout on whole screen Shape = Movie.AddShape Movie.SHAPE_Rectangle 0, 0, W, H Movie.SHAPE_SetSolidColor 255,255,255,true,255 Movie.PlaceShape Shape,Movie.CurrentMaxDepth Movie.PLACE_FadeOut 1 Movie.EndMovie Movie.SaveToFile "Shapes.swf"