Skip to main content
Inspiring
January 21, 2022
Answered

load bar for multiple preload

  • January 21, 2022
  • 1 reply
  • 281 views

Hello. I have 18 array variables and each one with 3 mp3 sounds to load. I want to put a loading bar where the loading progress of all the variables is shown. I don't know how to associate the loading bar with all the variables. the line...

controlCarga.source = this[soundR[i]];

this is my complete code:

package com.kglad {
	
	import flash.display.MovieClip;
	import flash.display.InteractiveObject;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.display.MovieClip;
	import flash.media.Sound;
	import flash.media.SoundMixer;
	import flash.media.SoundChannel;
	import flash.media.SoundTransform;
	import flash.geom.Rectangle;
	import fl.controls.ProgressBar;
	import flash.events.ProgressEvent
	import flash.events.StatusEvent;
	import flash.net.URLLoader;
	import flash.display.Loader;
	import flash.net.URLRequest;
	import flash.events.IOErrorEvent
	
	public class Standars_all_mc extends MovieClip {

		private var st:SoundTransform;
		private var sound0:Sound = new Sound();
		private var sound1:Sound = new Sound();
		private var sound2:Sound = new Sound();
		private var sound3:Sound = new Sound();
		private var sound4:Sound = new Sound();
		private var sound5:Sound = new Sound();
		private var sound6:Sound = new Sound();
		private var sound7:Sound = new Sound();
		private var sound8:Sound = new Sound();
		private var sound9:Sound = new Sound();
		private var sound10:Sound = new Sound();
		private var sound11:Sound = new Sound();
		private var sound12:Sound = new Sound();
		private var sound13:Sound = new Sound();
		private var sound14:Sound = new Sound();
		private var sound15:Sound = new Sound();
		private var sound16:Sound = new Sound();
		private var sound17:Sound = new Sound();
		private var sound18:Sound = new Sound();
		private var sound19:Sound = new Sound();
		private var sound20:Sound = new Sound();
		private var sound21:Sound = new Sound();
		private var sound22:Sound = new Sound();
		private var sound23:Sound = new Sound();
		private var sound24:Sound = new Sound();
		private var sound25:Sound = new Sound();
		private var sound26:Sound = new Sound();
		private var sound27:Sound = new Sound();
		private var sound28:Sound = new Sound();
		private var sound29:Sound = new Sound();
		private var sound30:Sound = new Sound();
		private var sound31:Sound = new Sound();
		private var sound32:Sound = new Sound();
		private var sound33:Sound = new Sound();
		private var sound34:Sound = new Sound();
		private var sound35:Sound = new Sound();
		private var sound36:Sound = new Sound();
		private var sound37:Sound = new Sound();
		private var sound38:Sound = new Sound();
		private var sound39:Sound = new Sound();
		private var sound40:Sound = new Sound();
		private var sound41:Sound = new Sound();
		private var sound42:Sound = new Sound();
		private var sound43:Sound = new Sound();
		private var sound44:Sound = new Sound();
		private var sound45:Sound = new Sound();
		private var sound46:Sound = new Sound();
		private var sound47:Sound = new Sound();
		private var sound48:Sound = new Sound();
		private var sound49:Sound = new Sound();
		private var sound50:Sound = new Sound();
		private var sound51:Sound = new Sound();
		private var sound52:Sound = new Sound();
		private var sound53:Sound = new Sound();
		
		private var soundA:Array = ["sound0","sound1","sound2"];
		private var soundB:Array = ["sound3","sound4","sound5"];
		private var soundC:Array = ["sound6","sound7","sound8"];
		private var soundD:Array = ["sound9","sound10","sound11"];
		private var soundE:Array = ["sound12","sound13","sound14"];
		private var soundF:Array = ["sound15","sound16","sound17"];
		private var soundG:Array = ["sound18","sound19","sound20"];
		private var soundH:Array = ["sound21","sound22","sound23"];
		private var soundI:Array = ["sound24","sound25","sound26"];
		private var soundJ:Array = ["sound27","sound28","sound29"];
		private var soundK:Array = ["sound30","sound31","sound32"];
		private var soundL:Array = ["sound33","sound34","sound35"];
		private var soundM:Array = ["sound36","sound37","sound38"];
		private var soundN:Array = ["sound39","sound40","sound41"];
		private var soundO:Array = ["sound42","sound43","sound44"];
		private var soundP:Array = ["sound45","sound46","sound47"];
		private var soundQ:Array = ["sound48","sound49","sound50"];
		private var soundR:Array = ["sound51","sound52","sound53"];

		private var i:int;		
//soundA
		var Bergamasca0000:String = "https://drive.google.com/uc?id=1Y36t7fLgRHqQ4XLZajC5VHSYuhLM1FKV&export=download";
		var Bergamasca0001:String = "https://drive.google.com/uc?id=1P4WDhtAm3XCnG1wcNObCKXFy00wE83Vz&export=download";
		var Bergamasca0002:String = "https://drive.google.com/uc?id=1ihNAVa82jGkr973tfpre1wf3zdT3kPR1&export=download";
		//soundB
		var Bergamasca0100:String = "https://drive.google.com/uc?id=1IDv5pTbh94GT_dqocQuSZqfQH1CtysNR&export=download";
		var Bergamasca0101:String = "https://drive.google.com/uc?id=1MKkj30XSC_Is-jWYKqnb2KVVIBZqa0Kg&export=download";
		var Bergamasca0102:String = "https://drive.google.com/uc?id=1eOzms1xf_Do0FSYmNciC1gSnG2I5Oh0A&export=download";
		//soundC
		var Bergamasca0200:String = "https://drive.google.com/uc?id=1r4z6r4dw0Yv3Ljuxm4Qomx6IsQHC2Flv&export=download";
		var Bergamasca0201:String = "https://drive.google.com/uc?id=145j8Vj8H7Z1fUuD5g03-KlwyAe7RN2Wy&export=download";
		var Bergamasca0202:String = "https://drive.google.com/uc?id=16zGvRdTK6fvzBM3PmYrKSXKtQFQC6saD&export=download";
		//soundD
		var Bergamasca1000:String = "https://drive.google.com/uc?id=1bJ_lBqsKgprDD6OoapTQBeyxpwOyeIKx&export=download";
		var Bergamasca1001:String = "https://drive.google.com/uc?id=1hgnYRdm_8Bq6kxIp-W-BAcr6F6cyzfM6&export=download";
		var Bergamasca1002:String = "https://drive.google.com/uc?id=1UfsWfz4j4QNA1_TVmFRBY0712smQ3I3P&export=download";
		//soundE
		var Bergamasca1100:String = "https://drive.google.com/uc?id=1xbfG65mUGC-fiefIo7JVkXD1OlVjKVAA&export=download";
		var Bergamasca1101:String = "https://drive.google.com/uc?id=135mghBGhjUJ6ynVddCgRbChaIjaBEJEi&export=download";
		var Bergamasca1102:String = "https://drive.google.com/uc?id=1bc308FIt9EYk_a7F5vRK0IlVl8G0ODD2&export=download";
		//soundF
		var Bergamasca1200:String = "https://drive.google.com/uc?id=14lLGUmU0Lm_Dbp5LdsjkSGa6di8Tg2rA&export=download";
		var Bergamasca1201:String = "https://drive.google.com/uc?id=1V_E8r-cg7veiZrfHoDguQ8gZM3kL5z5f&export=download";
		var Bergamasca1202:String = "https://drive.google.com/uc?id=1XRYsx_jR8t4_HCEl1nqrHe10iQxxCMK1&export=download";
		//soundG
		var Bergamasca0010:String = "https://drive.google.com/uc?id=1c9v58OFO6jlSAOlNALzPjO_B_Gp33zAL&export=download";
		var Bergamasca0011:String = "https://drive.google.com/uc?id=1Oo5QleCF5V_B3DqJfg9D2xfZuEeJb2x8&export=download";
		var Bergamasca0012:String = "https://drive.google.com/uc?id=1U_RC6Qnset5IkfJNld-Z9_X3VRdAZjZR&export=download";
		//soundH
		var Bergamasca0110:String = "https://drive.google.com/uc?id=14lWhLncOFsE6Pd65DTHFB7JD0r5_RPKB&export=download";
		var Bergamasca0111:String = "https://drive.google.com/uc?id=1otNyHMPVwRH85CIR2ZL34VNoCya7Adm_&export=download";
		var Bergamasca0112:String = "https://drive.google.com/uc?id=19WTuAUFrQ2nDAL5FoNpGw56_pzYekhNV&export=download";
		//soundI
		var Bergamasca0210:String = "https://drive.google.com/uc?id=1JhyGvoqLwtB43-ktXb_7T8KE5Sp-_8_h&export=download";
		var Bergamasca0211:String = "https://drive.google.com/uc?id=1qBOonCUdnH0dyJZLvAu2HqMw_JzX_lWC&export=download";
		var Bergamasca0212:String = "https://drive.google.com/uc?id=18MlfE8J8vhMbTrYA899KCBcI7FLTmZhp&export=download";		
		//sooundJ
		var Bergamasca1010:String = "https://drive.google.com/uc?id=1OgkDktk31sAvPQO2fb8RPgphB5r0Ikiv&export=download";
		var Bergamasca1011:String = "https://drive.google.com/uc?id=1eX8FqvlqomE6MZyE2e2iKiVdNKS0UvHi&export=download";
		var Bergamasca1012:String = "https://drive.google.com/uc?id=1eGBeGTZ1nv0Uoe9DXZP9AeaMEH_kvkbv&export=download";
		//soundK
		var Bergamasca1110:String = "https://drive.google.com/uc?id=1g_RM1yR66P9lJAuV42XpWfHE9zCnxyim&export=download";
		var Bergamasca1111:String = "https://drive.google.com/uc?id=14l-ZTENJVn650zwVsQWJq4K9NEnFlYJN&export=download";
		var Bergamasca1112:String = "https://drive.google.com/uc?id=14E2PWB3wUP72GSDeSNkXpseluh2amd27&export=download";
		//soundL
		var Bergamasca1210:String = "https://drive.google.com/uc?id=1EHJ1eqj-B2yeMrJnDymmzBMsoIlPVlGc&export=download";
		var Bergamasca1211:String = "https://drive.google.com/uc?id=1WobDJwdo8OG7m69n178fv8O2Dz-ekcSG&export=download";
		var Bergamasca1212:String = "https://drive.google.com/uc?id=1eW3gKfvsSzb9AJuahXM3k0xOWx_GyUmN&export=download";
		//soundM
		var Bergamasca0020:String = "https://drive.google.com/uc?id=1yUrYNPufcU9I5NoiXfxqsP0a1d-YZpTe&export=download";
		var Bergamasca0021:String = "https://drive.google.com/uc?id=1uoh-XCYhKA-QCK9ZxlIHlScOsu5W8BUJ&export=download";
		var Bergamasca0022:String = "https://drive.google.com/uc?id=1XRwHzYRoEINmAF3BI-EsLXW_GaoxASud&export=download";
		//soundN
		var Bergamasca0120:String = "https://drive.google.com/uc?id=11keSoBcmi5mtB0lSCTY_nQQYovWqRh77&export=download";
		var Bergamasca0121:String = "https://drive.google.com/uc?id=1eqxX02HKDZoug9ERA7BVoS96oQFetCpI&export=download";
		var Bergamasca0122:String = "https://drive.google.com/uc?id=1t2OL9q1nTq4TtHbjCkC7fawPbcF2anFM&export=download";
		//soundO
		var Bergamasca0220:String = "https://drive.google.com/uc?id=123BUYX47jyeOPp3g1ZE2YuPgQrWoi4Dh&export=download";
		var Bergamasca0221:String = "https://drive.google.com/uc?id=18ie3MJ6czIgwXgQNp9OtrRzS-_Bw0hN1&export=download";
		var Bergamasca0222:String = "https://drive.google.com/uc?id=1XHuR3jSTiGc4OUzsUmLCZXx5XSMacBG_&export=download";
		//soundP
		var Bergamasca1020:String = "https://drive.google.com/uc?id=1l-CvidTTe32W4_nmwU2Fup1vwvOAYFTh&export=download";
		var Bergamasca1021:String = "https://drive.google.com/uc?id=12vR62fzMR7xZeSwdfqc2NY1X-MHDPmE3&export=download";
		var Bergamasca1022:String = "https://drive.google.com/uc?id=1HCB_EIWqob3GQuLL9-3MwTEYvSHGcnPI&export=download";
		//soundQ
		var Bergamasca1120:String = "https://drive.google.com/uc?id=1vwcsUU1ldvQjlpovXf0Dk_CDlWrUo8SR&export=download";
		var Bergamasca1121:String = "https://drive.google.com/uc?id=1eyzFvMGCg1aphspqpfGyWDZdt-3CwveS&export=download";
		var Bergamasca1122:String = "https://drive.google.com/uc?id=1de1rtGg9fc36gKzYxX-PdTMGTPy94yT_&export=download";
		//soundR
		var Bergamasca1220:String = "https://drive.google.com/uc?id=1B_qGkLn7MafyPtZyC4ICVlgs4Y3ftsVK&export=download";
		var Bergamasca1221:String = "https://drive.google.com/uc?id=1U5ibOB303vcMNt46JZzVhztnmD2oK4ep&export=download";
		var Bergamasca1222:String = "https://drive.google.com/uc?id=17BpN6gnV9IcfFwKWteNI-IH3d7YXCYUO&export=download";		



		
		public function Standars_all_mc() {
			this.addEventListener(Event.ADDED_TO_STAGE,addedF);
		}
		
		private function addedF(e:Event):void{
				
			load_soundsF();
			}
//carga de sonidos
		
		private function load_soundsF():void {
			
			//bar
			controlCarga.width = 320;
			controlCarga.height = 7;
			controlCarga.move((width/2)-320,height/2);
			addChild (controlCarga);
			pantallaCarga.gotoAndStop(2);

			//sounds charge
			for (var i:uint=0; i<3; i++) {
				this[soundA[i]] = new Sound();
				this[soundB[i]] = new Sound();
				this[soundC[i]] = new Sound();
				this[soundD[i]] = new Sound();
				this[soundE[i]] = new Sound();
				this[soundF[i]] = new Sound();
				this[soundG[i]] = new Sound();
				this[soundH[i]] = new Sound();
				this[soundI[i]] = new Sound();
				this[soundJ[i]] = new Sound();
				this[soundK[i]] = new Sound();
				this[soundL[i]] = new Sound();
				this[soundM[i]] = new Sound();
				this[soundN[i]] = new Sound();
				this[soundO[i]] = new Sound();
				this[soundP[i]] = new Sound();
				this[soundQ[i]] = new Sound();
				this[soundR[i]] = new Sound();
				this[soundA[i]].load (new URLRequest(this[Data.so.data.sound+0+0+0+i]));
				this[soundB[i]].load (new URLRequest(this[Data.so.data.sound+0+1+0+i]));
				this[soundC[i]].load (new URLRequest(this[Data.so.data.sound+0+2+0+i]));
				this[soundD[i]].load (new URLRequest(this[Data.so.data.sound+1+0+0+i]));
				this[soundE[i]].load (new URLRequest(this[Data.so.data.sound+1+1+0+i]));
				this[soundF[i]].load (new URLRequest(this[Data.so.data.sound+1+2+0+i]));
				this[soundG[i]].load (new URLRequest(this[Data.so.data.sound+0+0+1+i]));
				this[soundH[i]].load (new URLRequest(this[Data.so.data.sound+0+1+1+i]));
				this[soundI[i]].load (new URLRequest(this[Data.so.data.sound+0+2+1+i]));
				this[soundJ[i]].load (new URLRequest(this[Data.so.data.sound+1+0+1+i]));
				this[soundK[i]].load (new URLRequest(this[Data.so.data.sound+1+1+1+i]));
				this[soundL[i]].load (new URLRequest(this[Data.so.data.sound+1+2+1+i]));
				this[soundM[i]].load (new URLRequest(this[Data.so.data.sound+0+0+2+i]));
				this[soundN[i]].load (new URLRequest(this[Data.so.data.sound+0+1+2+i]));
				this[soundO[i]].load (new URLRequest(this[Data.so.data.sound+0+2+2+i]));
				this[soundP[i]].load (new URLRequest(this[Data.so.data.sound+1+0+2+i]));
				this[soundQ[i]].load (new URLRequest(this[Data.so.data.sound+1+1+2+i]));
				this[soundR[i]].load (new URLRequest(this[Data.so.data.sound+1+2+2+i]));

				controlCarga.source = this[soundR[i]];
				controlCarga.addEventListener(ProgressEvent.PROGRESS, imagenProgreso);
				controlCarga.addEventListener(Event.COMPLETE, imagenCargada);
				//this[soundR[2]].addEventListener(Event.COMPLETE, imagenCargada);
				//this[soundR[2]].addEventListener(ProgressEvent.PROGRESS, imagenProgreso);
				this[soundR[2]].addEventListener(IOErrorEvent.IO_ERROR, onError);
			}

			function imagenProgreso(event:ProgressEvent):void {
				pantallaCarga.formato_1.text = "Cargando" + Data.so.data["sound"].split("_").join(" ")+".......";
				//"Load..." + Math.floor(event.bytesLoaded / 1024) + "/" + Math.floor(event.bytesTotal / 1024) + "KB";
				//trace("progressHandler: bytesLoaded=" + e.bytesLoaded + " bytesTotal=" + e.bytesTotal);
			}

			function imagenCargada(event:Event):void {
				pantallaCarga.formato_1.text = Data.so.data["sound"].split("_").join(" ")+" cargado con exito";
				//pantallaCarga.gotoAndStop(1);
				pantallaCarga.gotoAndPlay(2);

				if (contains (controlCarga)){
					removeChild (controlCarga);
					}	
			}

			function onError(event:IOErrorEvent):void {
				trace("ioErrorHandler");
				//pantallaCarga.play();
				dispatchEvent(backE);
			}
		}
    This topic has been closed for replies.
    Correct answer kglad

    why do you have 18 3 file arrays instead of one when you're loading all 54 files at about the same time?

    1 reply

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    January 21, 2022

    why do you have 18 3 file arrays instead of one when you're loading all 54 files at about the same time?

    Inspiring
    January 21, 2022

    Hello!! it's important to load the sounds like this to play them in groups of 3 later... anyway I've thought about using 18 loading bars and trying to put them in a row so that it looks like one... I'll tell you if it works. Thanks a lot.

    Inspiring
    January 22, 2022

    I have solved it by doing what you told me. Thanks again