Start the Flash program. Click "Flash File(ActionScript 3.0)" from the splash window to create a new file for an AS3 Flash animation project.
Select "Actions" from the "Window" menu on the main Flash menu bar to open the ActionScript 3 editor. Position your mouse cursor on the first line of the ActionScript 3 editor. Click your mouse button and type in the code below to load the SWF file named VideoGame.swf" at the location on the Flash stage specified by the variables x1 and y1 using the coded instructions in the loadSwf function.
var x1:int = 0;
var y1:int = 0;
var fileLocation: String = "VideoGame.swf"
loadSwf(fileLocation, x1, y1);
Type the code below starting at the next line in the ActionsScript 3 editor to load the SWF file named MasterIllustrationReferenceLibrary.swf" at the coordinates (300,0) on the Flash stage specified by using the coded instructions in the loadSwf function.
x1 = 300;
fileLocation = "MasterIllustrationReferenceLibrary.swf"
loadSwf(fileLocation, x1, y1);
Type the code below starting at the next line in the ActionsScript 3 editor to: create the loadSwf function; specify that the loadSwf lfunction load and place the SWF file onto the Flash stage that has been sent through the loadSwf file parameter at the x and y coordinates read in through the x_Position and y_Position parameters, and reduce the size of the SWF file by 50 percent with the scale properties.
function loadSwf(file:String, x_Position:Number, y_Position:Number):void
{
var connectToFile1Location:URLRequest = new URLRequest(fileLocation)
var fileContentsStorageVariable:Loader = new Loader();
fileContentsStorageVariable.load(connectToFile1Location);
addChild(fileContentsStorageVariable);
fileContentsStorageVariable.scaleX=0.5;
fileContentsStorageVariable.scaleY=0.5;
fileContentsStorageVariable.x = x_Position;
fileContentsStorageVariable.y = y_Position;
};
Copy and paste the code below into the ActionScript 3 editor to ensure there are no syntax errors and the external SWF controller program works correctly.
var x1:int = 0;
var y1:int = 0;
var fileLocation: String = "VideoGame.swf"
loadSwf(fileLocation, x1, y1);
x1 = 300;
fileLocation = "MasterIllustrationReferenceLibrary.swf"
loadSwf(fileLocation, x1, y1);
function loadSwf(file:String, x_Position:Number, y_Position:Number):void
{
var connectToFile1Location:URLRequest = new URLRequest(fileLocation)
var fileContentsStorageVariable:Loader = new Loader();
fileContentsStorageVariable.load(connectToFile1Location);
addChild(fileContentsStorageVariable);
fileContentsStorageVariable.scaleX=0.5;
fileContentsStorageVariable.scaleY=0.5;
fileContentsStorageVariable.x = x_Position;
fileContentsStorageVariable.y = y_Position;
};
Click "Test Movie" from the "Control" menu to play the external SWF controller program. Observe that the two SWF files specified have been loaded on the screen and that the second SWF file is half the size it was in the original SWF file.