ActionScript - Ayud!!!! con escenas En Flash CC AS3

 
Vista:
Imágen de perfil de Carlos

Ayud!!!! con escenas En Flash CC AS3

Publicado por Carlos (1 intervención) el 28/10/2016 22:29:42
Saludos a todos en el foro espero que se encuentren bien, bueno mi situación es la siguiente estoy trabajando con 3 escenas en Flash CC Una que se llama Inicio, otra que se llama Explicación, Cuestionario, Conclusión.

Y tengo una evaluación en la de cuestionario, cuando doy probar en Flash CC me envía directamente a iniciar el cuestionario no se si dentro de el script principal del cuestionario en alguna parte tenga que poner stop();

Este es el script que estoy usando en los botones de navegación

1
2
3
4
5
6
7
8
9
10
import flash.events.MouseEvent;
 
stop();
 
 
btn_uno.addEventListener(MouseEvent.CLICK, pasar1);
function pasar1 (event:MouseEvent):void
{
     gotoAndPlay(1, "Explicacion");
}




Les muestro el código que estoy usando en el script principal de el cuestionario

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package {
 
	import flash.display.MovieClip;
	import flash.net.URLLoader;
	import flash.events.ProgressEvent;
	import flash.events.Event;
	import flash.net.URLRequest;
	import fl.motion.MotionEvent;
	import flash.events.MouseEvent;
 
	import Carlos.Utiles.*;
	import gs.TweenLite;
	import gs.easing.*;
	import Carlos.Test.Pregunta;
 
 
	public class Test extends MovieClip {
		private var loader:URLLoader;
		private var datos:XML;
		private var fases:XMLList;
		private var literales:XMLList;
		private var textoHelp:MovieClip = null;
		private var listadoFases:Array;
		private var pregunta:Pregunta = null;
		private var indice:uint = 0;
 
		private var oks:uint = 0;
		private var kos:uint = 0;
 
 
		//parámetros de la aplicación
		private var urlXML:String = "xml/test.xml";
 
		public function Test() {
 
                               stop();
			onInicio();
		}
 
		/************** apartado precarga  ******************/
		private function onInicio():void{
			Globales.__root = this;
 
			loader = new URLLoader();
			loader.addEventListener(ProgressEvent.PROGRESS, onProgress);
			loader.addEventListener(Event.COMPLETE, onCompleteLoader);
			loader.load(new URLRequest(urlXML));
		}
 
		private function onProgress(evento:ProgressEvent):void{
			trace(evento.bytesLoaded + " de " + evento.bytesTotal);
		}
 
		private function onCompleteLoader(evento:Event):void{
			datos = new XML(loader.data);
			fases = datos..fase;
 
			Globales.literales = datos..literal;
 
			this.alpha = 0;
			gotoAndStop("intro");
		}
 
 
		/***************************************************/
 
		/************** apartado intro  ******************/
 
		public function cargaIntro():void{
			onDibujaIntro();
		}
 
		private function onDibujaIntro():void{
			enunciado.htmlText = Globales.literales.(@id == "texto_enunciado")[0].toString();
 
			TweenLite.to(this, 1, {alpha:1});
 
			onListenersIntro();
		}
 
		private function onListenersIntro():void{
			b_play.funcion = lanzaJuego;
 
		}
 
		public function lanzaJuego(evento:MouseEvent):void{
			alpha = 0;
			gotoAndStop("play");
		}
		/***************************************************/
 
 
 
		/************** apartado play  ******************/
		public function cargaPlay():void{
			listadoFases = new Array();
			for each(var item:XML in fases){
				listadoFases.push(item);
			}
			listadoFases = Tools.randomiza(listadoFases);
 
			oks = 0;
			kos = 0;
			indice = 0;
			pregunta = null;
 
			onDibujaPlay();
		}
 
		private function onDibujaPlay():void{
			TweenLite.to(this, 1, {alpha:1});
 
			creaPregunta();
 
			onListenersPlay();
		}
 
		private function onListenersPlay():void{
			b_siguiente.funcion = avanzaFase;
 
 
		}
 
		private function avanzaFase(evento:MouseEvent):void{
			if(pregunta.resultado){
				oks ++;
			}else{
				kos ++;
			}
			if(indice < listadoFases.length - 1){
				indice ++;
				creaPregunta();
			}else{
				pregunta.destroy();
				removeChild(pregunta);
				alpha = 0;
				gotoAndStop("gameOver");
			}
		}
 
		private function creaPregunta():void{
			if(pregunta != null){
				pregunta.destroy();
				removeChild(pregunta);
			}
			pregunta = new Pregunta(listadoFases[indice]);
			addChild(pregunta);
		}
 
		/***************************************************/
 
 
 
		/************** apartado gameOver  ******************/
		public function cargaGameOver():void{
			onDibujaGameOver();
		}
 
		private function onDibujaGameOver():void{
			ok.text = String(oks);
			ko.text = String(kos);
 
			TweenLite.to(this, 1, {alpha:1});
 
			onListenersGameOver();
		}
 
		private function onListenersGameOver():void{
			b_volver.funcion = lanzaJuego;
		}
		/***************************************************/
 
 
		/************** apartado AYUDA  ******************/
		private function _creaHelp(evento:MouseEvent):void{
			if(textoHelp == null){
				textoHelp = new TextoHelp();
				textoHelp.texto.htmlText = Globales.literales.(id="texto_descripcion")[0].toString();
				textoHelp.addEventListener(MouseEvent.CLICK, _borrahelp);
				textoHelp.alpha = 0;
				TweenLite.to(textoHelp, 1, {alpha:1});
				addChild(textoHelp);
			}
		}
 
		private function _borrahelp(evento:MouseEvent):void{
			textoHelp.removeEventListener(MouseEvent.CLICK, _borrahelp);
			removeChild(textoHelp);
			textoHelp = null;
		}
		/***************************************************/
	}
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Alejandro

Detener navegación en el cuestionario

Publicado por Alejandro (369 intervenciones) el 28/06/2023 23:07:00
Para detener la navegación directa al cuestionario al hacer clic en el botón "btn_uno" en la escena "Inicio", puedes agregar la instrucción `stop();` en el código del evento `pasar1` en el primer script que proporcionaste. Aquí está el código modificado:

1
2
3
4
5
6
7
8
9
import flash.events.MouseEvent;
 
stop();
 
btn_uno.addEventListener(MouseEvent.CLICK, pasar1);
function pasar1(event:MouseEvent):void {
     stop(); // Detiene la reproducción y evita la navegación directa
     gotoAndPlay(1, "Explicacion");
}

Al agregar `stop();` en la función `pasar1`, se detendrá la reproducción en la escena actual y se reproducirá la escena "Explicacion" desde el primer fotograma.

Esta solución evitará la navegación directa al cuestionario al hacer clic en el botón correspondiente en la escena "Inicio".
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar