Hey there!
Suena como que podría tener un par de problemas.
#1 - Versión de ActionScript
Si usted está usando CS3, el valor por defecto es la versión de ActionScript 3.0. Si usted está usando AS3, entonces usted probablemente debería utilizar detectores de eventos para "escuchar" para obtener el botón pulsado. Véase el siguiente código:
// This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
// Also, frameNumber in each of these functions should be replaced with the correct frame
button1.addEventListener(MouseEvent.CLICK,btnClick1);
button1.buttonMode = true;
function btnClick1(e:Event)
{
gotoAndPlay(frameNumber);
}
button2.addEventListener(MouseEvent.CLICK,btnClick2);
button2.buttonMode = true;
function btnClick2(e:Event)
{
gotoAndPlay(frameNumber);
}
- // This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
- // Also, frameNumber in each of these functions should be replaced with the correct frame
- button1.addEventListener(MouseEvent.CLICK,btnClick1);
- button1.buttonMode = true;
- function btnClick1(e:Event)
- {
- gotoAndPlay(frameNumber);
- }
- button2.addEventListener(MouseEvent.CLICK,btnClick2);
- button2.buttonMode = true;
- function btnClick2(e:Event)
- {
- gotoAndPlay(frameNumber);
- }
Puede escribir funciones más eficaz para controlar los eventos (por ejemplo, podría escribir una función para manejar clics de botón ALL y cambiar el lugar donde se van sobre la base de una variable dentro del botón, etc), pero esto debe darle una idea de cómo para manejar la asignación de funciones de los botones en AS3.
#2 - Orientación
Otra cosa a tener en cuenta es el objetivo de la función. La imagen tiene un clip de película llamado "contenedor", sentado en su línea de tiempo principal y dentro de "contenedor", son los dos botones en el código anterior ( "Button1" y "button2"). En las funciones anteriores, "gotoAndPlay" se refiere al "contenedor" clip de película - por lo que el contenedor vaya a [frameNumber]. Si desea que los botones para cambiar el marco de la línea de tiempo raíz (no es "contenedor"), entonces usted necesita para contar la "gotoAndPlay" función de eso. En AS3, que el código se parecería a
function btnClick1(e:Event)
{
e.target.parent.parent.gotoAndPlay(10);
}
- function btnClick1(e:Event)
- {
- e.target.parent.parent.gotoAndPlay(10);
- }
¿Qué dice este código es: mirar lo que desencadenó el evento ( "e.target" o "Button1"), y consultar en su no pare ( "contenedor"), luego mira en la pare, no pare no tienen (la raíz) .
Lo mismo se aplicaría en ActionScript 2. 0:
// This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
// Also, frameNumber in each of these functions should be replaced with the correct frame
button1.onRelease = function() {
this._parent._parent.gotoAndPlay(10);
}
button2.onRelease = function() {
this._parent._parent.gotoAndPlay(20);
}
- // This code should be placed on the timeline of the button's parent (the movie clip that holds the button)
- // Also, frameNumber in each of these functions should be replaced with the correct frame
- button1.onRelease = function() {
- this._parent._parent.gotoAndPlay(10);
- }
- button2.onRelease = function() {
- this._parent._parent.gotoAndPlay(20);
- }
Rock en la codificación y feliz!