Here is NTD's code from the other thread. I rewrote some variable and function names to improve clarity:
Code:
//arrays are extremely useful so lets get used to using them to store data...
//in this case, the names of the movies we want to load...
var moviesToBeLoaded:Array = new Array( [ "movie1.swf", "movie2.swf", "movie3.swf", "movie4.swf", "movie5.swf" ] );
var listenerObject:Object = new Object();
listenerObject.change = function( eachObject )
{
comboBox1Value = comboBox1.getSelectedItem().label;
comboBox2Value = comboBox2.getSelectedItem().label;
checkValue();
}
function comboBox1Init()
{
comboBox1.addItem( { data: 0, label: "Home" } );
comboBox1.addItem( { data: 1, label: "Info" } );
comboBox1.addItem( { data: 2, label: "Contact" } );
comboBox1Value = comboBox1.getSelectedItem().label;
comboBox2.addItem( { data: 0, label: "Make a Selection" } );
comboBox2.addItem( { data: 1, label: "Home Label2" } );
comboBox2.addItem( { data: 2, label: "Home Label3" } );
}
comboBox1Init();
checkValue();
//standard function using a switch statement to
//check the value of useSelection1 variable and
//power the project...replace trace statements with
//whatever functionality you want
function checkValue()
{
var useSelection1 = comboBox1Value;
var useSelection2 = comboBox2Value;
//clear comboBox2
comboBox2.removeAll();
switch ( useSelection1 )
{
case "Home":
//set home labels for comboBox2
comboBox2.addItem( { data: 0, label: "Make a Selection" } );
comboBox2.addItem( { data: 1, label: "Home Label2" } );
comboBox2.addItem( { data: 2, label: "Home Label3" } );
break;
case "Info":
//set info labels for comboBox2
comboBox2.addItem( { data: 0, label: "Make a Selection" } );
comboBox2.addItem( { data: 1, label: "Info Label2" } );
comboBox2.addItem( { data: 2, label: "Info Label3" } );
break;
case "Contact":
//set contact labels for comboBox2
comboBox2.addItem( { data: 0, label: "Make a Selection" } );
comboBox2.addItem( { data: 1, label: "Contact Label2" } );
comboBox2.addItem( { data: 2, label: "Contact Label3" } );
break;
default:
break;
}
switch ( useSelection2 )
{
case "Home Label2":
trace( "Load movie A" );
myMovieClip.loadMovie( moviesToBeLoaded[ 0 ] );
break;
case "Home Label3":
trace( "Load movie B" );
myMovieClip.loadMovie( moviesToBeLoaded[ 1 ] );
break;
case "Info Label2":
trace( "Load movie C" );
myMovieClip.loadMovie( moviesToBeLoaded[ 2 ] );
break;
case "Info Label3":
trace( "Load movie D" );
myMovieClip.loadMovie( moviesToBeLoaded[ 3 ] );
break;
case "Contact Label2":
trace( "Load movie E" );
myMovieClip.loadMovie( moviesToBeLoaded[ 4 ] );
break;
case "Contact Label3":
trace( "Load movie F" );
myMovieClip.loadMovie( moviesToBeLoaded[ 5 ] );
break;
default:
break;
}
}
//using a simple for loop to assign the listener object to both combobox's
//you can write a listener for each component but it's not really necessary
//for this situation...
for ( index = 1; index < 3; index++ )
{
_root[ "c" + index ].addEventListener( "change", listenerObject );
}
This code is old. It looks likes AS2, and most definitely won't work in an AS3 project without errors. It seems to require two combo box components and a movie clip to be onstage.
First, a few questions: Which version of Flash Pro are you using, and which version of ActionScript do you wish to use? Also, do you want to use the combo box components or a custom made combo box? Will your finished project be placed on a website, or will you be using it offline?
Second, some information that can be found in Adobe's Help Documentation, here:
When you use the Loader class, consider the Flash Player and Adobe AIR security model:
- You can load content from any accessible source.
- Loading is not allowed if the calling SWF file is in a network sandbox and the file to be loaded is local.
- If the loaded content is a SWF file written with ActionScript 3.0, it cannot be cross-scripted by a SWF file in another security sandbox unless that cross-scripting arrangement was approved through a call to the System.allowDomain() or the System.allowInsecureDomain() method in the loaded content file.
- If the loaded content is an AVM1 SWF file (written using ActionScript 1.0 or 2.0), it cannot be cross-scripted by an AVM2 SWF file (written using ActionScript 3.0). However, you can communicate between the two SWF files by using the LocalConnection class.
- If the loaded content is an image, its data cannot be accessed by a SWF file outside of the security sandbox, unless the domain of that SWF file was included in a URL policy file at the origin domain of the image.
- Movie clips in the local-with-file-system sandbox cannot script movie clips in the local-with-networking sandbox, and the reverse is also prevented.
- You cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
Third, think about what you want exactly, then post a reply; I'll answer any questions you have and try to help you with your project.
Bookmarks