[object MovieClip] <-- 1
[object MovieClip] <-- 2
[object MainTimeline] <-- 3
----------------------
y al precionar el boton
[object MovieClip] <-- 1
[object MainTimeline] <-- 2
[object Stage] <-- 3
----------------------
TypeError: Error #1034: Error de conversión forzada: no se puede convertir flash.display::Stage@1e81ab51 en flash.display.MovieClip.
at Prueba_01_fla::MainTimeline/frame100()
estos es lo que hago para llamar a la funcion desde en hijo el el fotograma 100
Código ActionScript :
stop();
trace(parent + " <-- 1" );
trace(parent.parent + " <-- 2" );
trace(parent.parent.parent + " <-- 3" );
trace("----------------------");
var contenedor:MovieClip = MovieClip(parent.parent.parent);
contenedor.picDisplay();y esto esta en el swf principal
Código ActionScript :
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.external.ExternalInterface;
////////////////////////////////////////////////////////////////////////
// Variables iniciales y declaracion
////////////////////////////////////////////////////////////////////////
var pic_mc:MovieClip=new MovieClip();
var picInitial_mc:MovieClip=new MovieClip();
var xmlLoader:URLLoader = new URLLoader();
var vpause:Boolean=false;
var xmlData:XML;
var thumbLoader:Loader = new Loader();
var index:int=0;
var picArray:Array=new Array();
var idArray:Array=new Array();
var linkArray:Array=new Array();
var timer :Timer=new Timer(1000,4);
var curr:int=1;
var currAnt:int=0;
var totalPictures:int;
var flag:int=0;
var bitmap:DisplayObject;
var effect:Object=Photo;
var formato:TextFormat;
var cargador_txt:TextField = new TextField();
var porcentaje:int;
var url:URLRequest = new URLRequest();
nav_mc.addEventListener(MouseEvent.ROLL_OVER,faumentar_alfa);
nav_mc.addEventListener(MouseEvent.ROLL_OUT,fdisminuir_alfa);
rep_mc.mouseChildren=false;
rep_mc.buttonMode=true;
rep_mc.addEventListener(MouseEvent.ROLL_OVER,frecaumentar_alfa);
rep_mc.addEventListener(MouseEvent.ROLL_OUT,frecdisminuir_alfa);
rep_mc.addEventListener(MouseEvent.CLICK,freproducir);
function freproducir(event:MouseEvent) : void{
if(vpause==false){
rep_mc.gotoAndPlay(1);
vpause=true;
}else{
vpause=false;
picDisplay();
rep_mc.gotoAndPlay(2);
}
}
////////////////////////////////////////////////////////////////////////
// Funcion XML Loading
////////////////////////////////////////////////////////////////////////
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
var param:Object = LoaderInfo(this.root.loaderInfo).parameters;
var httpHeader : URLRequestHeader = new URLRequestHeader("pragma","no-cache");
var variables : URLVariables = new URLVariables();
variables.SeccionID = param["SeccionID"];
//trace(variables.SeccionID);
//var path : String="http://localhost/albedriototal/xml_BannersTop_Sec.php";
var path : String="http://localhost/albedriototal/xml_BannersTop_Sec.xml";
url=new URLRequest(path);
url.requestHeaders.push(httpHeader);
url.data = variables;
url.method = URLRequestMethod.POST;
xmlLoader.load(url);
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
stage.scaleMode = StageScaleMode.EXACT_FIT;
stage.stageWidth= xmlData.Width;
stage.stageHeight=xmlData.Height;
var xmlCategoryList:XMLList = xmlData.children();
totalPictures=xmlData.children().length();
var item:XML;
for each (item in xmlCategoryList) {
loadThumbs();
}
for(var i:int=0;i<totalPictures;i++){
var num_view:Num_mc = new Num_mc();
var num:int = i+1;
num_view.mouseChildren=false;
num_view.buttonMode=true;
num_view.cuadrado_mc.gotoAndPlay(1);
num_view.num=i;
num_view.addEventListener(MouseEvent.CLICK,fnum_view);
num_view.num_txt.text=num.toString();
num_view.num_txt.autoSize=TextFieldAutoSize.CENTER;
num_view.width=25;
num_view.y=4;
num_view.x=i * 30;
nav_mc.Grupo_mc.addChild(num_view);
}
contenedor_mc.mouseChildren=false;
contenedor_mc.buttonMode=true;
contenedor_mc.addEventListener(MouseEvent.CLICK,fclick_banner);
nav_mc.Grupo_mc.x= (nav_mc.width - nav_mc.Grupo_mc.width) - 15;
nav_mc.Grupo_mc.getChildAt(index).buttonMode=false;
nav_mc.Grupo_mc.getChildAt(index).cuadrado_mc.gotoAndPlay(2);
nav_mc.Grupo_mc.getChildAt(index).num_txt.textColor=0xFFFFFF;
nav_mc.Grupo_mc.getChildAt(index).removeEventListener(MouseEvent.CLICK,fnum_view);
}// Fin de carga XML
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,funcError);
function funcError(event:IOErrorEvent){
trace("Error al cargar XML");
}
function fclick_banner(event:MouseEvent){
ExternalInterface.call("EnviarClick",idArray[curr]);
navigateToURL(new URLRequest(linkArray[curr]), "_blank");
}
////////////////////////////////////////////////////////////////////////
// Funcion loadThumbs
////////////////////////////////////////////////////////////////////////
function loadThumbs():void {
// thumbLoader = new Loader();
thumbLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadThumbProgress);
thumbLoader.contentLoaderInfo.addEventListener(Event.INIT, thumbLoaded);
thumbLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,xmlLoadFail);
thumbLoader.load(new URLRequest(String(xmlData.path[index])));//access the thumbnails
////////////////////////////////////////////////////////////////////////
// Funcion loadThumbProgress
////////////////////////////////////////////////////////////////////////
function loadThumbProgress(event:ProgressEvent):void {
}
////////////////////////////////////////////////////////////////////////
// Funcion thumbloaded
////////////////////////////////////////////////////////////////////////
function thumbLoaded(event:Event):void {
for(var i:int=0;i<totalPictures;i++)
{
picArray[i]=xmlData.path[i];
idArray[i]=xmlData.path[i].@idban;
linkArray[i]=xmlData.path[i].@linkban;
}
contenedor_mc.addChild(picInitial_mc);
picInitial_mc.addChild(thumbLoader.content);
bitmap=thumbLoader.content;
}
////////////////////////////////////////////////////////////////////////
// Funcion xmlLoadFail
////////////////////////////////////////////////////////////////////////
function xmlLoadFail(event:IOErrorEvent):void {
trace("Error al cargar SWF Externo");
}
}
////////////////////////////////////////////////////////////////////////
// Funcion Siguiente Carga Pic
////////////////////////////////////////////////////////////////////////
function nextPicLoad(string:String) {
thumbLoader = new Loader();
thumbLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadThumbProgress);
thumbLoader.contentLoaderInfo.addEventListener(Event.INIT, thumbLoaded);
//thumbLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,xmlLoadFail);
thumbLoader.load(new URLRequest(String(string)));
function thumbLoaded(event:Event):void
{
//stage.addChild(thumbLoader.content);
contenedor_mc.addChild(pic_mc);
//contenedor_mc.addChild(thumbLoader.content);
pic_mc.addChild(thumbLoader.content);
bitmap=thumbLoader.content;
//Blinds, Fade, Iris, Photo, PixelDissolve, Rotate, Squeeze, Wipe, or Zoom.
//TransitionManager.start(pic_mc, {type:Fade, direction:Transition.IN, duration:1, easing:Regular.easeInOut});
//TransitionManager.start(pic_mc, {type:Wipe, direction:Transition.IN, duration:1, easing:Regular.easeIn});
}
function loadThumbProgress(event:ProgressEvent):void {
}
/*function xmlLoadFail(event:IOErrorEvent):void {
trace("Error al cargar XML - 3");
}*/
}
////////////////////////////////////////////////////////////////////////
// Funcion Mostrar Pic
////////////////////////////////////////////////////////////////////////
function picDisplay(){
if(vpause==false){
for(var k:int=0;k<pic_mc.numChildren;k++){
pic_mc.removeChildAt(k);
}
if (flag==0) {
flag=1;
contenedor_mc.removeChild(picInitial_mc);
} else {
contenedor_mc.removeChild(pic_mc);
}
contenedor_mc.addChild(bitmap);
nextPicLoad(picArray[curr]);
nav_mc.Grupo_mc.getChildAt(currAnt).buttonMode=true;
nav_mc.Grupo_mc.getChildAt(currAnt).cuadrado_mc.gotoAndPlay(1);
nav_mc.Grupo_mc.getChildAt(currAnt).num_txt.textColor=0x000000;
nav_mc.Grupo_mc.getChildAt(currAnt).addEventListener(MouseEvent.CLICK,fnum_view);
nav_mc.Grupo_mc.getChildAt(curr).buttonMode=false;
nav_mc.Grupo_mc.getChildAt(curr).cuadrado_mc.gotoAndPlay(2);
nav_mc.Grupo_mc.getChildAt(curr).num_txt.textColor=0xFFFFFF;
nav_mc.Grupo_mc.getChildAt(curr).removeEventListener(MouseEvent.CLICK,fnum_view);
currAnt=curr;
curr++;
if (curr==totalPictures) {
curr=0;
}
}
}
function faumentar_alfa(event:MouseEvent):void{
nav_mc.alpha=0.75;
}
function fdisminuir_alfa(event:MouseEvent):void{
nav_mc.alpha=0.35;
}
function frecaumentar_alfa(event:MouseEvent):void{
rep_mc.alpha=0.75;
}
function frecdisminuir_alfa(event:MouseEvent):void{
rep_mc.alpha=0.35;
}
function fnum_view(event:MouseEvent){
curr=event.currentTarget.num;
for(var k:int=0;k<pic_mc.numChildren;k++){
pic_mc.removeChildAt(k);
}
if (flag==0) {
flag=1;
contenedor_mc.removeChild(picInitial_mc);
} else {
contenedor_mc.removeChild(pic_mc);
}
contenedor_mc.addChild(bitmap);
trace(nextPicLoad(picArray[curr]));
//nextPicLoad(picArray[curr]);
nav_mc.Grupo_mc.getChildAt(curr).buttonMode=false;
nav_mc.Grupo_mc.getChildAt(curr).cuadrado_mc.gotoAndPlay(2);
nav_mc.Grupo_mc.getChildAt(curr).num_txt.textColor=0xFFFFFF;
nav_mc.Grupo_mc.getChildAt(curr).removeEventListener(MouseEvent.CLICK,fnum_view);
nav_mc.Grupo_mc.getChildAt(currAnt).buttonMode=true;
nav_mc.Grupo_mc.getChildAt(currAnt).cuadrado_mc.gotoAndPlay(1);
nav_mc.Grupo_mc.getChildAt(currAnt).num_txt.textColor=0x000000;
nav_mc.Grupo_mc.getChildAt(currAnt).addEventListener(MouseEvent.CLICK,fnum_view);
currAnt=curr;
if(vpause==true){
vpause=false;
rep_mc.gotoAndPlay(2);
}
}
////////////////////////////////////////////////////////////////////////
// Ejecución Pic Display
////////////////////////////////////////////////////////////////////////
//picDisplay();
stop(); 