How to load images from external JPEG image files and display them in flash movie using SWF Scout

Submitted by eLenka on 13 May, 2011 - 11:58

This example shows how to dynamically load and display images from external JPG files in the flash movie generated using the SWF Scout SDK.

Screenshot of flash movie that uses images from external .JPG files:

Source code:

' TO USE ACTIONSCRIPT COMPILER in registered version YOU HAVE TO HAVE ADDITIONAL "AS License"

W = 640
H = 480
FPS = 12
 
 
' // make a SWF library with images

 
Set Movie = CreateObject("SWFScout.FlashMovie")
Movie.InitLibrary "demo", "demo"
' Movie creating and setting parameters
Movie.BeginMovie 0,0,W,H,1,FPS,6
Movie.Compressed = true
 
 
For ImageIndex = 1 to 3
 
 
image = Movie.AddImageFromFilename("NewImage" & CStr(ImageIndex) & ".jpg")
sprite = Movie.AddSprite
currobj = Movie.CurrentObjectID
Movie.SPRITE_PlaceImage Image, Movie.SPRITE_CurrentMaxDepth
Movie.ExportAssets "image" & CStr(ImageIndex), currobj
 
 
Movie.PlaceSprite Sprite, Movie.CurrentMaxDepth
 
 
Next
 
Movie.EndMovie
Movie.SaveToFile "MakeImagesLibraryAndMakeSWFUsingThisLibraryFromExtFile_lib.swf"
 
 
Set Movie = nothing
 
 
'//////////////////////////
' now create movie that will use produced LIB from SWF
'/////////////////////////

 
Set Movie = CreateObject("SWFScout.FlashMovie")
Movie.InitLibrary "demo", "demo"
Movie.BeginMovie 0,0,W,H,1,FPS,6
Movie.Compressed = true
 
 
Movie.AddExternalSWF "MakeImagesLibraryAndMakeSWFUsingThisLibraryFromExtFile_lib.swf", 1, true ' // seimResource = 1

 
'// now addding actionscript to place images at given X and Y, using their names mcl_image1, mcl_image2 etc
For ImageIndex = 1 to 3
 
 
' create a movieclip and attach image from library
Movie.AddScript
Movie.SCRIPT_Compile "this.createEmptyMovieClip('mcl_image" & CStr(ImageIndex) & "', _root.getNextHighestDepth()+" & CStr(ImageIndex) & ");attachMovie('image" & CStr(ImageIndex) & "', 'mcl_image" & CStr(ImageIndex) & "', getNextHighestDepth());"
MsgBox Movie.ASCompilerLog
 
 
 
 
' place image to X, Y (x = ImageIndex*10, y = ImageIndex * 15)
X = ImageIndex *10
Y = ImageIndex *15
Movie.AddScript
Movie.SCRIPT_Compile "mcl_image"& CStr(ImageIndex) & "._x=" & CStr(X) & ";mcl_image"& CStr(ImageIndex) & "._y=" & CStr(Y) & ";"
Movie.ShowFrame FPS*1 ' show frames for 1 second
Next
 
 
Movie.EndMovie
 
 
Movie.SaveToFile "MakeImagesLibraryAndMakeSWFUsingThisLibraryFromExtFile.swf"

 

Download source code: