Hello, Im having whta I think is a quite common problem. I recently started migrating form AS2 to AS3 and Im buidling a home made template for all AS3 projects…
I have just loaded portfolio.swf on top of main.sfw. The buttons on portfolio.swf share the same class as the buttons on main.swf
This is the button class:
package com{
import flash.display.*;
import flash.events.*;
public class Boton extends MovieClip{
public function Boton(){
addEventListener(Event.ADDED_TO_STAGE,init);
}
private function init(e:Event){
removeEventListener(Event.ADDED_TO_STAGE, init);
addEventListener(MouseEvent.CLICK,this.onClick);
addEventListener(MouseEvent.ROLL_OVER,this.onOver);
addEventListener(MouseEvent.ROLL_OUT,this.onOut);
activaBoton();
}
public function activaBoton():void{
enabled=true;
}
public function desactivaBoton():void{
enabled=false;
}
public function onClick(e:Event):void{
trace("BOTON PULSADO : "+ name);
//Main.singleton.cambiarSeccion(name); - opcion SINGLETON
trace(TopLevel.stage);
TopLevel.root.cambiarSeccion(name);
}
public function onOver(e:Event):void{
this.gotoAndPlay("rollOver");
}
public function onOut(e:Event):void{
this.gotoAndPlay("rollOut");
}
}
}
As you can see, when the button is clicked it calls **TopLevel.root.cambiarSeccion(name) , **which is a function in Main.as that handles the change of section …
It works perfectly fine in main.swf, but when I try to compile portfolio.swf (loads on top of main.swf) It throws an error 1061: Llamada a un método cambiarSeccion posiblemente no definido mediante una referencia con tipo estático flash.display:DisplayObject. - 1061: Call to method cambiarSeccion not defined usgin a static reference flash.display:DisplayObject
¿Any ideas on how could I fix this? :h:
Any help will be really really be appreciated, I have already spent many many hours trying to fix this thing …