rd111072 1 Denunciar post Postado Julho 5, 2013 Olá. tenho uma action que acessa um xml. a action no frame 2 é essa: stop(); /* arrays to hold the info */ var anuncio_arr:Array = []; var tipo_arr:Array = []; var titulo_arr:Array = []; var texto_arr:Array = []; var foto_arr:Array = []; var credito_arr:Array = []; //var url_arr:Array = []; var imagesClips_arr:Array = []; /* load the xml */ var xml_url:String = "xml/xml01.xml"; var news_data:XML = new XML(); var news_url:URLRequest = new URLRequest(xml_url); var newsLoader:URLLoader = new URLLoader(news_url); newsLoader.addEventListener(Event.COMPLETE, newsLoaded); function newsLoaded(e:Event):void { news_data = XML(newsLoader.data); //recorrer el xml var allNews:XMLList = news_data.*; for each (var news:XML in allNews) { anuncio_arr.push(news.anuncio.toString()); tipo_arr.push(news.ticker.tipo.toString()); titulo_arr.push(news.ticker.titulo.toString()); texto_arr.push(news.ticker.texto.toString()); foto_arr.push(news.ticker.foto.toString()); credito_arr.push(news.ticker.credito.toString()); //url_arr.push(news.url.toString()); } // loadImages(); } /* preload the images and add it to empty movieclips */ var count:int = 0; function loadImages():void { var toLoad:int = foto_arr.length; if (count > toLoad-1) { gotoAndStop("display"); } else { preloader_txt.text = "preloading image "+(count+1); //here load the image var mc:MovieClip = new MovieClip; imagesClips_arr.push(mc); var img_url:String = "images/"+foto_arr[count]; var loader:Loader = new Loader(); var request_url:URLRequest = new URLRequest(img_url); loader.load(request_url); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener); function completeListener(e:Event):void { mc.addChild(loader.content); } count++; loadImages(); } } e no frame 3: stop(); /* ini variables */ var activeNews:int = 0; var isPlaying:Boolean = true; var totalNews:int = titulo_arr.length; /* timer */ var timer:Timer = new Timer(15000, 0); timer.addEventListener(TimerEvent.TIMER, timerListener); function timerListener(e:TimerEvent) { if (activeNews == totalNews-1) { loadNews(0); } else { loadNews(activeNews+1); } //trace("running!!"); } timer.start(); /* load the news */ function loadNews(num:int):void { activeNews = num; //hide the buttons IMGloader_mc.goto_btn.enabled = false; prev_btn.enabled = false; next_btn.enabled = false; IMGloader_mc.holder_mc.addChild(imagesClips_arr[num]); display_mc.title_txt.text = titulo_arr[num]; display_mc.desc_txt.text = texto_arr[num]; display_mc.tipo_txt.text = tipo_arr[num]; display_mc.credito_txt.text = credito_arr[num]; IMGloader_mc.goto_btn.enabled = true; prev_btn.enabled = true; next_btn.enabled = true; //IMGloader_mc.link = url_arr[num]; } /* next prev and pause */ prev_btn.addEventListener(MouseEvent.CLICK, prevListener); function prevListener(e:MouseEvent):void { if (activeNews == 0) { loadNews(totalNews-1); } else { loadNews(activeNews-1); } } next_btn.addEventListener(MouseEvent.CLICK, nextListener); function nextListener(e:MouseEvent):void { if (activeNews == totalNews-1) { loadNews(0); } else { loadNews(activeNews+1); } } pause_btn.addEventListener(MouseEvent.CLICK, pauseListener); function pauseListener(e:MouseEvent):void { if (isPlaying) { isPlaying = false; timer.stop(); // pause_btn.alpha = 0.8; } else { isPlaying = true; timer.start(); // pause_btn.alpha = 1; } } /* load the first news */ loadNews(0); Está dando o erro: SecurityError: Error #2000: Não há contexto de segurança ativo. Esqueci de postar a estrutura do xml: <?xml version="1.0" encoding="iso-8859-1"?> <ticker> <anuncio> t1 <ticker> <tipo>teste</tipo> <texto>fdasd</texto> <foto>test1.jpg</foto> <credito>c2</credito> <datainicio>4/7/2013</datainicio> <datafim>4/7/2013</datafim> </ticker> <ticker> <tipo>teste</tipo> <texto>sadsad</texto> <foto>test2.jpg</foto> <credito>asfdsad</credito> <datainicio>4/7/2013</datainicio> <datafim>4/7/2013</datafim> </ticker> </anuncio> </ticker> Compartilhar este post Link para o post Compartilhar em outros sites
rd111072 1 Denunciar post Postado Julho 5, 2013 Creio que o problema foi quando eu adicionei a tag <anuncio>. Antes era assim:<tickers><ticker> e funcionava normal. Agora é assim: <tickers><anuncio><ticker>. e dá esse erro acima... alguém pode me dar uma luz. Compartilhar este post Link para o post Compartilhar em outros sites
DesenvolvedorRoger 50 Denunciar post Postado Agosto 14, 2013 Usei apenas a parte que trata o XML e aqui não deu erro... Segue a forma como fiz o acesso aos dados: function newsLoaded(e:Event):void{ news_data = XML( newsLoader.data ); for each (var news:XML in news_data ){ trace( news.anuncio.ticker[0].tipo[0]+" == "+news.anuncio.ticker[0].texto[0] ); } } } BS, Compartilhar este post Link para o post Compartilhar em outros sites