Ultrashock Forums > Flash > ActionScript
AS2 - A script in this movie is causing Adobe Flash Player 10 to run slowly

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
AS2 - A script in this movie is causing Adobe Flash Player 10 to run slowly
Old 2008-10-22

Hi Everybody,

I have a main timeline with this code in frame 1:
Code:
//Function that shows or hides the caption bar
import mx.transitions.Tween;

//Make this timeline accessible from everywhere
_global.gMainInterface = this;

//Variable that holds the movieClip currently playing, This variable will be assigned the value "this" from any running movieclip
var movieCurrentlyPlaying:MovieClip;

//Variable that will be used by the button PROCEED, at the end of each of the general sections (Background, General..., etc)
var nextGeneralSection:String;




//TOP BAR BUTTONS

//Formating for the top bar buttons
//White color for  the top bar button text. This will change the color of the text when rollOver of the buttons at the top bar
var whiteText_fmt:TextFormat = new TextFormat();
whiteText_fmt.color = 0xFFFFFF;
blackText_fmt.size = 12;

//Black color for  the top bar button text. This will change the color of the text when roll out of the buttons at the top bar
var blackText_fmt:TextFormat = new TextFormat();
blackText_fmt.color = 0x000000;
blackText_fmt.size = 12;

//Array containing the labels for the buttons in the top bar of the main window. Length = 8
var topBarBtnsLabels:Array = Array("Section 1", "Section 2", "Section 3", "Section 4", "Section 5", "Section 6", "Section 7", "Section 8");

//This sets up the behaviour of the buttons at the top bar
for (i:Number = 1; i <= topBarBtnsLabels.length; i++) {
	//The boolean buttonAvailable marks the button as enabled, when the player first loads
	topBarBtns_mc["btn" + i + "_mc"].buttonAvailable = true;
	//Because Test Results should appear in two lines
	if (i == 4) {
		//Makes the textField narrower, so the label appears in two lines
		topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt._width = 50;
		//Centers the label horizontally
		topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt._x = ((topBarBtns_mc["btn" + i + "_mc"]._width) - (topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt._width)) / 2;
	}
	//
	//Adds the label to the buttons, according to the topBarBtnsLabels array
	topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt.text = topBarBtnsLabels[i - 1];
	//Centers the labels vertically
	topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt._y = (topBarBtns_mc["btn" + i + "_mc"]._height / 2) - (topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt._height / 2);
	//Formats the labels to the initial blackText_fmt
	topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt.setTextFormat(blackText_fmt);
	//
	topBarBtns_mc["btn" + i + "_mc"].onRollOver = function():Void  {
		this.gotoAndStop("_over");
		this.buttonLabel_txt.setTextFormat(whiteText_fmt);
	};
	topBarBtns_mc["btn" + i + "_mc"].onRollOut = topBarBtns_mc["btn" + i + "_mc"].onReleaseOutside =function():Void  {
		this.gotoAndStop("_up");
		this.buttonLabel_txt.setTextFormat(blackText_fmt);
	};
	//Variable that will store one button at the time
	var thisButton:MovieClip = topBarBtns_mc["btn" + i + "_mc"];
	// You must store the index value or it will be lost.
	thisButton.idx = i;
	// Redirect the on release method to a function
	thisButton.onRelease = function():Void{
		
		movieLoader.unloadClip(movieHolder_mc);
		
		
		//Makes the timeline move to another frame in the _root timeline, according to the topBarBtnsLabels array
		this._parent._parent.gotoAndStop(topBarBtnsLabels[this.idx - 1]);
		//
		//captionBarFunctionality();
		//Function that checks if the caption bar is open
		//If so, it keeps it open when changing section.
		//If not, it keeps it closed
		//captionBarCheck();
		//
		//Changes the value of the Boolean var to false, to indicate that the clicked button is not available
		this.buttonAvailable = false;
		//Moves this button's timeline
		this.gotoAndStop("_down");
		//Formats the label
		this.buttonLabel_txt.setTextFormat(whiteText_fmt);
		//Disables the button so the user can't click on them while the next section is loading
		/*for (i = 1; i <= topBarBtnsLabels.length; i++) {
		_root.topBarBtns_mc["btn" + i + "_mc"].enabled = false;
		}	*/
		
		/*for (i = 1; i <= topBarBtnsLabels.length; i++) {
			if (_root.topBarBtns_mc["btn" + i + "_mc"] != this) {
				topBarBtns_mc["btn" + i + "_mc"].buttonAvailable = true;
				topBarBtns_mc["btn" + i + "_mc"].enabled = true;
				topBarBtns_mc["btn" + i + "_mc"].gotoAndStop("_up");
				topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt.setTextFormat(blackText_fmt);
			}
		}*/
	};
}


//END OF TOP BAR BUTTONS


//CREDIT BUTTON

creditsBtn_mc.onRelease = function() {
	this._parent.gotoAndStop("Credits");
	//For all the top bar buttons
	for (i = 1; i <= topBarBtnsLabels.length; i++) {
		//Makes the Boolean variable true
		topBarBtns_mc["btn" + i + "_mc"].buttonAvailable = true;
		//Enables the buttons
		topBarBtns_mc["btn" + i + "_mc"].enabled = true;
		//Moves the buttons timelines to the up state
		topBarBtns_mc["btn" + i + "_mc"].gotoAndStop("_up");
		//Formats the text
		topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt.setTextFormat(blackText_fmt);
	}
};

//END OF CREDIT BUTTON





//CAPTION BAR AND TEXT BUTTON

//Function to center the text vertically in the caption area every time the text changes in the textField
function centerCaption():Void {
	caption_txt._y = textBar_mc._y + textBar_mc.backgroundGuide_mc._y + ((textBar_mc.backgroundGuide_mc._height - caption_txt._height) / 2);
}

//Background guide for the caption bar. Used by the centerCaption function
textBar_mc.createEmptyMovieClip("backgroundGuide_mc",2);
textBar_mc.backgroundGuide_mc._x = 20;
textBar_mc.backgroundGuide_mc._y = 10;
function drawRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, fillColor:Number, fillAlpha:Number):Void {
	with (target_mc) {
		beginFill(fillColor,fillAlpha);
		moveTo(0,0);
		lineTo(boxWidth,0);
		lineTo(boxWidth,boxHeight);
		lineTo(0,boxHeight);
		lineTo(0,0);
		endFill();
	}
}

drawRectangle(textBar_mc.backgroundGuide_mc,624,50,0x99FF00,0);
//End of //Background guide for the caption bar

//Styles for the captions
var styles:TextField.StyleSheet = new TextField.StyleSheet();
styles.setStyle("bodyText",{fontFamily:'Arial,Helvetica,sans-serif', fontSize:'14px', leading:'0px'});
styles.setStyle("boldText",{color:'#FF0000'});
styles.setStyle("small",{fontFamily:'Arial,Helvetica,sans-serif', fontSize:'9px', display:'inline'});
caption_txt.html = true;
caption_txt.multiline = true;
caption_txt.selectable = false;
caption_txt.wordWrap = true;
caption_txt.autoSize = true;
caption_txt.styleSheet = styles;
//End of //Styles for the captions

//Initialization of the text button and the caption bar
textButton_mc.swapDepths(2000);

//Shows the button as ON
textButton_mc.gotoAndStop("On");

//textBarY1 is the initial location of the captions, where it should be. textBarY2 is the location of the caption when is hidden
var textBarY1:Number = 503;
var textBarY2:Number = 442;

textBar_mc._y = textBarY1;

/*function captionBarCheck():Void {
//If the caption is open
if (captionOn == true) {
textBar_mc._y = 503;
//If the caption is open
} else if (captionOn == false) {
textBar_mc._y = 442;
}
}*/

//Boolean variable that will be used to show or hide the caption bar.
var captionOn:Boolean = true;

function captionBarFunctionality():Void {
	//If the caption is hiden
	if (captionOn == false) {
		//Opens the bar
		var textBarOut:Tween = new Tween(textBar_mc, "_y", mx.transitions.easing.Regular.easeOut, textBarY2, textBarY1, 12, false);
		//When the bar is Open
		textBarOut.onMotionFinished = function():Void {
			//Centers the caption before it shows it
			centerCaption();
			//Shows the textField
			caption_txt._visible = true;
			//makes the T button appears as ON
			textButton_mc.gotoAndStop("On");
			//Sets the boolean var to true
			captionOn = true;
		};
		//If the caption is showing
	} else {
		//Hides the textField
		caption_txt._visible = false;
		//Closes the bar
		var textBarIn:Tween = new Tween(textBar_mc, "_y", mx.transitions.easing.Regular.easeIn, textBarY1, textBarY2, 12, false);
		//When the bar is Closed
		textBarIn.onMotionFinished = function():Void {
		//makes the T button appears as OFF
		textButton_mc.gotoAndStop("Off");
		//Sets the boolean var to false
		captionOn = false;
		}
	}
}

textButton_mc.onRelease = captionBarFunctionality;
//END OF CAPTION BAR AND TEXT BUTTON


//FUNCTIONS FOR PLAY AND PAUSE BUTTONS

//Function to turn ON the Play button
function turnOnPlayBtn():Void {
	newPlayBtn_mc.gotoAndStop("On");
	newPlayBtn_mc.enabled = false;//Makes the button disabled until pause is pressed
	turnOffPauseBtn();
}
//Function to turn ON the Pause button
function turnOnPauseBtn():Void {
	newPauseBtn_mc.gotoAndStop("On");
	newPauseBtn_mc.enabled = false;//Makes the button disabled until play is pressed
	turnOffPlayBtn();
}
//Function to turn ON the Sound button
function turnOnSoundBtn():Void {
	soundButton_mc.gotoAndStop("On");
	soundButton_mc.enabled = true;
}
//Function to turn ON the Text button
function turnOnTextBtn():Void {
	textButton_mc.gotoAndStop("On");
	textButton_mc.enabled = true;
}
//Function to turn OFF the Play button
function turnOffPlayBtn():Void {
	newPlayBtn_mc.gotoAndStop("Off");
	newPlayBtn_mc.enabled = true;//Makes the button disabled until play is pressed
}
//Function to turn OFF the Pause button
function turnOffPauseBtn():Void {
	newPauseBtn_mc.gotoAndStop("Off");
	newPauseBtn_mc.enabled = true;//Makes the button disabled until play is pressed
}
//Function to turn OFF the Text button
function turnOffTextBtn():Void {
	textButton_mc.gotoAndStop("Off");
	textButton_mc.enabled = false;
}
//Function to turn OFF the Sound button
function turnOffSoundBtn():Void {
	soundButton_mc.gotoAndStop("Off");
	soundButton_mc.enabled = false;
}
//Function that actives the Play button and 
function activatePlayBtn():Void {
	turnOnPlayBtn();
	turnOffPauseBtn();
}

//END OF FUNCTIONS FOR PLAY AND PAUSE BUTTONS




//PLAY AND PAUSE FUNCTIONALITY

//Variable to register if the media is playing, and if so, then the pause buttons will work.
var mediaPlaying:Boolean = true;

newPauseBtn_mc.onRelease = function():Void {
	//Boolean variable that marks the player as Playing
	if (this._parent.mediaPlaying == true) {
		//Turns ON the Pause button
		this._parent.turnOnPauseBtn();
		//Stops the movie currenty marked as movieCurrrentlyPlaying
		this._parent.movieCurrentlyPlaying.stop();
		//Boolean variable that marks the player as Playing
		this._parent.mediaPlaying = false;
		//Music in Intro and Credits. pausePositionS marks the position where the music is paused
		pausePositionS = musicPlaying.position/1000;
		//Stops the music in the Intro and the Credits
		musicPlaying.stop();
	}
};

newPlayBtn_mc.onRelease = function():Void {
	//Boolean variable that marks the player as Playing
	this._parent.mediaPlaying = true;
	//Turns ON the Play button
	this._parent.turnOnPlayBtn();
	//Plays the movie currenty marked as movieCurrrentlyPlaying
	this._parent.movieCurrentlyPlaying.play();
	//Music in Intro and Credits. pausePositionS marks the position where the music was paused
	this._parent.musicPlaying.start(pausePositionS);
};

//END OF PLAY AND PAUSE FUNCTIONALITY





//AUDIO BUTTON

//Initially the sound is On
var soundActive:Boolean = true;

//Moves the button to a higher level
soundButton_mc.swapDepths(2001);

//Variable to control the volume of the sound
var global_sound:Sound = new Sound();

soundButton_mc.onRelease = function():Void  {
	if (soundActive == true) {
		this.gotoAndStop("Off");
		soundActive = false;
		global_sound.setVolume(0);
	} else {
		this.gotoAndStop("On");
		global_sound.setVolume(100);
		soundActive = true;
	}
};

//END OF AUDIO BUTTON


//LOADER

//Creates the holder for the external movies. One holder for all the movies
this.createEmptyMovieClip("movieHolder_mc",1000);
movieHolder_mc._x = 8;
movieHolder_mc._y = 68;

//This function should execute when the user trigers the load of a new section. It will be called in the frames that load section
function topBarToggle(button:MovieClip):Void{
	
	//Makes the button represented by the parameter passed to the function disabled
	button.buttonAvailable = false;
	//Makes the timeline of the button represented by the parameter passed to the function move
	button.gotoAndStop("_down");
	//Formats the label in the button represented by the parameter passed to the function
	button.buttonLabel_txt.setTextFormat(_root.whiteText_fmt);
	//For the other buttons in the top bar
	for (i = 1; i <= topBarBtnsLabels.length; i++) {
		//If it is not the button represented by the parameter passed to the function
		if (topBarBtns_mc["btn" + i + "_mc"] != button) {
			//Makes its Boolean var true, as enabled
			topBarBtns_mc["btn" + i + "_mc"].buttonAvailable = true;
			//Move the timeline to up state
			topBarBtns_mc["btn" + i + "_mc"].gotoAndStop("_up");
			//Format the label
			topBarBtns_mc["btn" + i + "_mc"].buttonLabel_txt.setTextFormat(_root.blackText_fmt);
		}
	}
}


//Listener to empty the captions when any new movie is loaded
var captionListener:Object = new Object();

//When the loading starts
captionListener.onLoadStart = function(){
	//Empties the captions
	caption_txt.htmlText="";
	//Centers the captions
	centerCaption();
}

//Listener to erase the music in Intro and Credits when loading any other movie
var musicListener:Object = new Object();
//When the loading starts
musicListener.onLoadStart = function(){
	//Load a non existing file, to erase the music in Intro or Credit
	musicPlaying.loadSound(null);
}

//Listener to the loading of the movies
var loaderListener:Object = new Object();

//When the loading starts
loaderListener.onLoadStart = function(target_mc:MovieClip) {
	//Prevent the loading movie from playing until it has been completely loaded
	target_mc.stop();
	//trace("target is: "+target_mc + " and it started loading");
	for (i = 1; i <= topBarBtnsLabels.length; i++) {
		topBarBtns_mc["btn" + i + "_mc"].enabled = false;
	}	
};
//When the loading ends
loaderListener.onLoadComplete = function(target_mc:MovieClip) {
	//trace("target is: "+target_mc + " and it finished loading");	
	for (i = 1; i <= topBarBtnsLabels.length; i++) {
		if (topBarBtns_mc["btn" + i + "_mc"].buttonAvailable == true) {
			topBarBtns_mc["btn" + i + "_mc"].enabled = true;
		}
	}
};

//When the loaded movie starts playing
loaderListener.onLoadInit = function(target_mc:MovieClip):Void  {
	//Sets the root inside the loaded movies
	target_mc._lockroot = true;
	//This is used by the play/pause buttons
	movieCurrentlyPlaying = target_mc;
	//Plays the loaded movie
	target_mc.play();
	//Turn ON the Play button
	turnOnPlayBtn();
	//If the sound is ON
	if (soundActive == true) {
		//Turn ON the sound button
		turnOnSoundBtn();
	} else {
		//Turn OFF the sound button
		turnOffSoundBtn();
	}
/*if (_root.captionOn == true) {
_root.textBar_mc._y = textBarY1;
_root.caption_txt._visible = true;
} else {
_root.textBar_mc._y = textBarY2;
_root.caption_txt._visible = false;
}*/
};

//Creates a movieClipLoader
var movieLoader:MovieClipLoader = new MovieClipLoader();
//Adds listeners to the movieClipLoader
movieLoader.addListener(loaderListener);
movieLoader.addListener(captionListener);
movieLoader.addListener(musicListener);
//END OF LOADER
Then, in different frames of the timeline (labeled Section 1, Section 2, etc), I have the following code to load the movies for the different sections:
Code:
stop();
//This function disables one button from the top bar, while enabling the others
topBarToggle(_root.topBarBtns_mc.btn7_mc);
movieLoader.loadClip ("section_1.swf", movieHolder_mc);
The loaded movies have this code in frame 1:
Code:
//This is necessary in case _root is used anywhere
//this._lockroot = true;

Stage.scaleMode = "noScale";

//Var that contains the number of cicle buttons in this movie.
var sectionAmount:Number = 16; 

//Array containing the frames that will be accessible trough the circle buttons.
var sectionFrames_array:Array = Array (2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18);

//Function to increase the size of the cicle buttons when the user advances to a new section 
function increaseSize(mc:MovieClip) {
	mc._xscale = mc._yscale = 200;
	//Loops trough all the circle buttons
	for (i = 0; i <= sectionAmount; i++) {
		//For all the other buttons, except the one clicked
		if (sectionnav_mc["section" + i + "_mc"] != mc) {
			//Boolean that will mark a circular button as activated and running its corresponding movie
			sectionnav_mc["section" + i + "_mc"].selectedButton = false;
			//Decreases the scale of the other circle buttons
			sectionnav_mc["section" + i + "_mc"]._xscale = sectionnav_mc["section" + i + "_mc"]._yscale = 100;
			//Enables the other circle buttons
			sectionnav_mc["section" + i + "_mc"].enabled = true;
			//Returns the other circle buttons to the Up state
			sectionnav_mc["section" + i + "_mc"].gotoAndStop("Up");
		}
	}
	mc.enabled = false;
	mc.gotoAndStop("On");	
	//Boolean that will mark a circular button as activated and running its corresponding movie
	mc.selectedButton = true;
}






//Function to decrease the size of the cicle buttons
function decreaseSize(mc:MovieClip) {
	mc._xscale = mc._yscale = 100;
	mc.selectedButton = false;
}





//Create the container for the circle buttons
this.createEmptyMovieClip("sectionnav_mc",this.getNextHighestDepth());

sectionnav_mc._x = 99;
sectionnav_mc._y = 425;

//First button inside the container. This button will be duplicated to create the button bar
sectionnav_mc.attachMovie("section_button","section_button_mc",2);
sectionnav_mc.section_button_mc._x = -200;
//sectionnav_mc.section_button_mc._visible = false;

//duplicates the first button to match the total in the variable sectionAmount
for (i = 0; i < sectionAmount; i++) {
	duplicateMovieClip(sectionnav_mc.section_button_mc, "section" + i + "_mc", sectionnav_mc.getNextHighestDepth());
	sectionnav_mc["section" + i + "_mc"]._x = 10 + 2 * (sectionnav_mc.section0_mc._width * i);
	var lastButton:MovieClip = sectionnav_mc["section" + i + "_mc"];
	//Assigns each button to a variable
	var thisButton = sectionnav_mc["section" + i + "_mc"];
	thisButton.selectedButton = false;
	// You must store the index value or it will be lost.
	thisButton.idx = i;
	// Redirect the on release method to a function
	thisButton.onRollOver = function() {
		this._xscale = this._yscale = 200;
	};
	thisButton.onRollOut = thisButton.onReleaseOutside = function () {
		this._xscale = this._yscale = 100;
	};
	thisButton.onRelease = function() {
		//Stops the movie currently been played
		gMainInterface.movieCurrentlyPlaying.stop();
		//Enables the pause button every time the user navigates to another module
		_root.newPlayBtn_mc.gotoAndStop("Selected");
		_root.newPlayBtn_mc.enabled = false;
		_root.newPauseBtn_mc.enabled = true;
		_root.newPauseBtn_mc.gotoAndStop("Up");
		_root.gotoAndStop(sectionFrames_array[this.idx]);		
		/*Clicking on any of the circular buttons
		The current movie is removed, before loading the new one*/
		//removeMovieClip(_root.currentMovie);	
	};
}





//LINE BEHIND THE CIRCLES
sectionnav_mc.createEmptyMovieClip("line_mc",1);
sectionnav_mc.line_mc.lineStyle(2,0x999999,100);
sectionnav_mc.line_mc.moveTo(sectionnav_mc.section0_mc._x,sectionnav_mc.section0_mc._y);
sectionnav_mc.line_mc.lineTo(lastButton._x,sectionnav_mc.section0_mc._y);
//END OF LINE BEHIND THE CIRCLES


//END OF SECTION NAVIGATION BAR



//NEXT AND BACK BUTTONS

//variable that contains the previous section
var prevSectionFrame:Number;
//variable that contains the next section
var nextSectionFrame:Number;

//function to navigate to previous sections
function gotoPreviousSection() {
	_root.gotoAndStop(prevSectionFrame);
	gMainInterface.activatePlayBtn();
		/*Clicking on any of the circular buttons
		The current movie is removed, before loading the new one*/
		//removeMovieClip(_root.currentMovie);	
}

//function to navigate to next section
function gotoNextSection() {
	_root.gotoAndStop(nextSectionFrame);
	gMainInterface.activatePlayBtn();
		/*Clicking on any of the circular buttons
		The current movie is removed, before loading the new one*/
		//removeMovieClip(_root.currentMovie);	
}

this.createEmptyMovieClip("backButton_mc",2000);
backButton_mc._x = 582;
backButton_mc._y = 377.5;
backButton_mc.attachMovie("sharedBackButton","backBtn",1);
var backBtn_btn:MovieClip = backButton_mc.backBtn;

//REPEAT BUTTON
this.createEmptyMovieClip("repeatHolder_mc",3000);
repeatHolder_mc._x = 490;
repeatHolder_mc._y = 367.1;
repeatHolder_mc.attachMovie("repeatButton","repeatBtn",1);
var repeatBtn_mc:MovieClip = repeatHolder_mc.repeatBtn;
repeatBtn_mc._visible = false;

//PROCEED BUTTON
this.createEmptyMovieClip("proceedHolder_mc",4000);
proceedHolder_mc._x = 482;//560;
proceedHolder_mc._y = 367.1;
proceedHolder_mc.attachMovie("proceed","proceedBtn",1);
var proceedBtn_mc:MovieClip = proceedHolder_mc.proceedBtn;

//This text will create the label for the PROCEED button, depending on what is the next section, according to the top bar of the player.
proceedBtn_mc.nextGeneralSection_txt.selectable = false;
proceedBtn_mc.nextGeneralSection_txt.autoSize = "right";
proceedBtn_mc.nextGeneralSection_txt.wordWrap = false;
proceedBtn_mc.nextGeneralSection_txt.text = "Proceed to " + gMainInterface.nextGeneralSection;
//proceedBtn_mc._width = proceedBtn_mc._x + proceedBtn_mc.nextGeneralSection_txt._x+proceedBtn_mc.nextGeneralSection_txt._width+_7;
var proceedBtnWidth:Number = proceedBtn_mc.nextGeneralSection_txt._width + 15;
proceedBtn_mc._visible = false;
proceedBtn_mc.proceedBtnBg_mc._width = proceedBtnWidth;
proceedBtn_mc.onRelease = function() {
	gMainInterface.gotoAndStop(gMainInterface.nextGeneralSection);
};
//END OF PROCEED BUTTON

this.createEmptyMovieClip("nextButtonHolder",1000);
nextButtonHolder._x = 603.9;
nextButtonHolder._y = 367.1;
nextButtonHolder.attachMovie("sharedNextButtonHolder","nextBtn_holder_mc",1);
var nextBtn_holder:MovieClip = nextButtonHolder.nextBtn_holder_mc;
nextBtn_holder.gotoAndStop(2);

backBtn_btn.onRelease = gotoPreviousSection;
nextBtn_holder.onRelease = gotoNextSection;

//NEXT AND BACK BUTTONS


//MASK FOR LOADED MOVIES
this.createEmptyMovieClip("maskHolder",900);
maskHolder.attachMovie("moduleMask","mask_mc",this.getNextHighestDepth());
maskHolder.mask_mc._alpha = 0;
//END OF MASK FOR LOADED MOVIES


//REPEAT BUTTON
var Root:Boolean;
var frameToRepeat:Number;


repeatBtn_mc.onRelease = function() {
	//If TRUE, it will play a previous frame in the root
	if (_root.Root == true) {
		_root.gotoAndStop(frameToRepeat);
		//Hides the proceed button
		_root.proceedBtn_mc._visible = false;
	} else {
		//If it is FALSE will play the same frame in the root
		gMainInterface.movieCurrentlyPlaying.gotoAndPlay(1);
		//Hides the proceed button
		_root.proceedBtn_mc._visible = false;
	}
};
//END OF REPEAT BUTTON



//MOVIE CLIP LOADER FOR EXTERNAL MOVIES
//Listener to empty the captions
var captionListener:Object = new Object();
captionListener.onLoadStart = function(){
	gMainInterface.caption_txt.htmlText="";
	gMainInterface.centerCaption();
}


var loadListener:Object = new Object();
//Variable that will hold the currrently playing movie, so the container_mcLoader removes it and assigns it to a new loaded movie
var currentMovie:MovieClip;
loadListener.onLoadStart = function(target_mc:MovieClip):Void  {
	//trace("target is: "+target_mc + " and it started loading");
	target_mc.stop();
	//gMainInterface.caption_txt.htmlText = "";
	//_root.proceedBtn_mc._visible = false;
	//for (i = 0; i < _root.sectionAmount; i++) {
		//_root.sectionnav_mc["section" + i + "_mc"].enabled=false;	
	//}
	//Disables the NEXT PREV buttons until the movie has been loaded
	//_root.backBtn_btn.enabled=false;	
	//_root.nextBtn_holder.enabled=false;
};
loadListener.onLoadComplete = function(target_mc:MovieClip):Void  {
	//trace("currentMovie is "+_root.currentMovie);
	removeMovieClip(_root.currentMovie);	
	//trace("currentMovie should not be "+_root.currentMovie);
	//trace("target is: "+target_mc + " and it finished loading");
	//for (var name in target_mc._parent) { 
		//if (typeof (target_mc._parent[name]) == "movieclip") { 
			//trace(target_mc._parent+" has a movie clip child named "+ name); 
		//} 
	//}
	target_mc.play();
	//for (i = 0; i < _root.sectionAmount; i++) {
		//if(_root.sectionnav_mc["section" + i + "_mc"].selectedButton == false){		
		//_root.sectionnav_mc["section" + i + "_mc"].enabled=true;	
		//}
	//}	
	//Disables the NEXT PREV buttons until the movie has been loaded
	//_root.backBtn_btn.enabled=true;	
	//_root.nextBtn_holder.enabled=true;	
};

loadListener.onLoadInit = function(target_mc:MovieClip):Void  {
	//gMainInterface.activatePlayBtn();
	//target_mc.setMask(_root.maskHolder.mask_mc);	
	//removeMovieClip(_root.currentMovie);
	/*Clicking on any of the circular buttons
	The current movie is removed, before loading the new one*/
	_root.currentMovie = target_mc;
	
	//gMainInterface.movieCurrentlyPlaying=target_mc; 
	
	//trace("new currentMovie is "+_root.currentMovie);
	//To activate the Back button after first movie
	//if (_root._currentframe >= _root.sectionFrames_array[1]) {
		//backBtn_btn.gotoAndStop("_up");
		//backBtn_btn.enabled = true;
	//} 
	//To disable the Next button in the last movie
	//if (_root._currentframe >= _root.sectionFrames_array[_root.sectionFrames_array.length - 1]) {
		//nextBtn_holder.gotoAndStop("_disabled");
		//nextBtn_holder.enabled = false;
	//} else {
		//nextBtn_holder.gotoAndStop(2);
		//nextBtn_holder.enabled = true;
	//}
};
var container_mcLoader:MovieClipLoader = new MovieClipLoader();
container_mcLoader.addListener(loadListener);
container_mcLoader.addListener(captionListener);
//END OF MOVIE CLIP LOADER FOR EXTERNAL MOVIES
The problem is that these movies, also load other movies inside of them. The actual loading happens in frames after frame 1, using this code:
Frame 2
Code:
this.createEmptyMovieClip ("mc1", 1);
container_mcLoader.loadClip ("background_1.swf", mc1);
Frame 3
Code:
Code:
this.createEmptyMovieClip ("mc2", 2);
container_mcLoader.loadClip ("background_2.swf", mc2);
Now, when I test the main movie, after a few clicks (loading Section 1, Section 2, etc), I get this message:
"A script in this movie is causing Adobe Flash Player 10 to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort the script?"
I have been looking for non ending loops, but not luck.

Could you please help me?
I apologize for the very long post, but I didn't know how to make it short without including all the details

It seems to me that there is some conflict between the loading of the movies, but I don't know what is causing the problem.

Thanks
peace,
Cayo Hueso
postbit arrow Be the first to comment! | 2295 views postbit arrow Reply: with Quote   
Registered User
cayohueso is offline
seperator
Posts: 103
2005-01-11
seperator
Thread Tools
Display Modes Rate This Thread
Rate This Thread: