crmdea 0 Denunciar post Postado Dezembro 9, 2009 Tento importar um swf(secundario) para o palco de um swf(primário), ai estou usando o código que vem no final do tópico. O problema é que quando importa o swf(secundário) vem sem os seus botões, tentei usar o this._lockroot = true; mas li que ele não funciona no as3 mesmo assim testei e ele dava um erro já ao publicar o swf(secundario) obs.: o swf(secundario) importa um package, não sei se complica tambem por isso a arvore seria +- assim 1º swf(primario) <- 2º swf(secundário) <- 3º Main.as(que seria carregado pelo swf(secundário) apenas) // cria uma instância do Loader var carregador:Loader = new Loader(); // armazena na variável “arquivo” o nome do swf externo a ser carregado var arquivo:String = "slideshow.swf"; // cria uma instância do URLRequest, que carregará o swf armazenado na variável “arquivo” var requisicao:URLRequest = new URLRequest(arquivo); // define onde o swf exteno será carregado carregador.x = -430.0; carregador.y = -227; // Carrega o swf solicitado carregador.load(requisicao); this.addChild(carregador); Agradeço desde já qualquer ajuda! (Y) Compartilhar este post Link para o post Compartilhar em outros sites
Matheus Brito 12 Denunciar post Postado Dezembro 10, 2009 Como esta o script no swf secundario que faz carregar alguma coisa? Abs Compartilhar este post Link para o post Compartilhar em outros sites
crmdea 0 Denunciar post Postado Dezembro 10, 2009 o fla do secundario ele tem uma layer com um keyframe em branco, somente carregando o Main.as , e na library os botoes( sendo eles inicializados todos pelo Main.as) o codigo vai ir à seguir, na verdade ele se chama Slideshow.as ja tentei trocar os private's por public mas nao adiantou package { import flash.display.*; import flash.events.* import flash.net.*; import flash.text.*; import flash.utils.Timer; import fl.transitions.*; import fl.transitions.easing.*; import Container; import buttonNext; import buttonPrev; import buttonFin; import buttonStart; import buttonSlideshowStop; import Charger; public class Slideshow extends MovieClip { private var _imageLoader:Loader; private var _xml:XML; private var _xmlList:XMLList = new XMLList(); private var _xmlLoader:URLLoader = new URLLoader(); private var _slideTween:Tween; private var _alphaTween:Tween; private var _stageWidth:Number; private var _stageHeight:Number; private var _container:Container = new Container(); private var _nextbtn:buttonNext; private var _prevbtn:buttonPrev; private var _finbtn:buttonFin; private var _startbtn:buttonStart; private var _slideshowbtn:buttonSlideshow; private var _slideshowstopbtn:buttonSlideshowStop; private var _infoText:infoText; private var _imageCount:Number = 0; private var _buttonsDistX:Number = 7; private var _buttonsDistY:Number = 5; private var _charger:Charger = new Charger(); private var _mitiempo:Timer; private var tTiempo:String = "on"; public function Slideshow() { _xmlLoader.load(new URLRequest("images.xml")); _xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); } // El archivo XML ha sido cargado exitosamente private function xmlLoaded(event:Event):void { _xml = XML(event.target.data); _xmlList = _xml.children(); trace(_xmlList[0].attribute("source")); _stageWidth = stage.stageWidth; _stageHeight = stage.stageHeight; _mitiempo = new Timer(4000); _mitiempo.addEventListener(TimerEvent.TIMER, tiempoCorriendo); _mitiempo.start(); _imageLoader = new Loader; _imageLoader.load(new URLRequest(_xmlList[0].attribute("source"))); _imageLoader.x = _stageWidth; addChild(_container); _container.addChild(_imageLoader); _imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadedRight); //Listener for the image to load complete _imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoadProgress); _finbtn = new buttonFin; _finbtn.x = _stageWidth - (_finbtn.width + _buttonsDistX); _finbtn.y = _stageHeight - (_finbtn.height + _buttonsDistY); addChild(_finbtn); _finbtn.addEventListener(MouseEvent.CLICK, clickFin); _finbtn.visible = false; _nextbtn = new buttonNext; _nextbtn.x = _finbtn.x - (_finbtn.width + _buttonsDistX); _nextbtn.y = _stageHeight - (_nextbtn.height + _buttonsDistY); addChild(_nextbtn); _nextbtn.addEventListener(MouseEvent.CLICK, clickNext); _nextbtn.visible = false; _slideshowbtn = new buttonSlideshow; _slideshowbtn.x = _nextbtn.x - (_nextbtn.width); _slideshowbtn.y = _stageHeight - (_slideshowbtn.height + _buttonsDistY); //addChild(_slideshowbtn); _slideshowbtn.addEventListener(MouseEvent.CLICK, clickSlideshowPlay); _slideshowstopbtn = new buttonSlideshowStop; _slideshowstopbtn.x = _nextbtn.x - (_nextbtn.width); _slideshowstopbtn.y = _stageHeight - (_slideshowstopbtn.height + _buttonsDistY); addChild(_slideshowstopbtn); _slideshowstopbtn.addEventListener(MouseEvent.CLICK, clickSlideshowStop); _slideshowstopbtn.visible = false; _prevbtn = new buttonPrev; _prevbtn.x = _slideshowstopbtn.x - (_slideshowstopbtn.width - (_buttonsDistX/4)); _prevbtn.y = _stageHeight - (_prevbtn.height + _buttonsDistY); addChild(_prevbtn); _prevbtn.addEventListener(MouseEvent.CLICK, clickPrev); _prevbtn.visible = false; _startbtn = new buttonStart; _startbtn.x = _prevbtn.x - (_finbtn.width + _buttonsDistX); _startbtn.y = _stageHeight - (_startbtn.height + _buttonsDistY); addChild(_startbtn); _startbtn.addEventListener(MouseEvent.CLICK, clickStart); _startbtn.visible = false; _infoText = new infoText(); _infoText.x = 10; _infoText.y = _stageHeight - 30; _infoText.infotbg.width = _infoText.infot.width; _infoText.visible = false; addChild(_infoText); } // Al dar click en el botón "FINAL" // When you click on "FINAL" button private function clickFin (event:MouseEvent) { if (_imageCount != _xmlList.length()-1) { if(tTiempo == "on") { removeChild(_slideshowstopbtn); addChild(_slideshowbtn); _mitiempo.stop(); tTiempo = "off"; } _imageCount = _xmlList.length()-1; _alphaTween = new Tween(_imageLoader,"alpha",Regular.easeOut,1,0,0,true); _imageLoader = new Loader; _imageLoader.load(new URLRequest(_xmlList[_imageCount].attribute("source"))); _imageLoader.x = _stageWidth; _container.addChild(_imageLoader); _imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoadProgress); _imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadedRight); //Listener for the image to load complete _finbtn.removeEventListener(MouseEvent.CLICK, clickFin); _startbtn.addEventListener(MouseEvent.CLICK, clickStart); _nextbtn.addEventListener(MouseEvent.CLICK, clickNext); _prevbtn.addEventListener(MouseEvent.CLICK, clickPrev); } else { _finbtn.removeEventListener(MouseEvent.CLICK, clickFin); } } // Al dar click en el botón "SIGUIENTE" // When you click on "NEXT" button private function clickNext (event:MouseEvent) { _imageCount++; _prevbtn.addEventListener(MouseEvent.CLICK, clickPrev); _finbtn.addEventListener(MouseEvent.CLICK, clickFin); _startbtn.addEventListener(MouseEvent.CLICK, clickStart); //Condición que se ejecuta siempre y cuando el if (_imageCount != _xmlList.length()) { if(tTiempo == "on") { removeChild(_slideshowstopbtn); addChild(_slideshowbtn); _mitiempo.stop(); tTiempo = "off"; } _mitiempo.stop(); _alphaTween = new Tween(_imageLoader,"alpha",Regular.easeOut,1,0,0,true); _imageLoader = new Loader; _imageLoader.load(new URLRequest(_xmlList[_imageCount].attribute("source"))); _imageLoader.x = _stageWidth; _container.addChild(_imageLoader); _imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoadProgress); _imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadedRight); //Listener for the image to load complete trace("_imageCount = " + String(_imageCount)); } else { _nextbtn.removeEventListener(MouseEvent.CLICK, clickNext); _imageCount--; } } private function clickSlideshowStop(event:MouseEvent):void { removeChild(_slideshowstopbtn); addChild(_slideshowbtn); _mitiempo.stop(); tTiempo = "off"; } private function clickSlideshowPlay(event:MouseEvent):void { removeChild(_slideshowbtn); addChild(_slideshowstopbtn); _mitiempo.start(); tTiempo = "on" } // Al dar click en el botón "PREVIO" // When you click on "PREV" button private function clickPrev (event:MouseEvent) { _imageCount--; _nextbtn.addEventListener(MouseEvent.CLICK, clickNext); _finbtn.addEventListener(MouseEvent.CLICK, clickFin); _startbtn.addEventListener(MouseEvent.CLICK, clickStart); if (_imageCount >= 0) { if(tTiempo == "on") { removeChild(_slideshowstopbtn); addChild(_slideshowbtn); _mitiempo.stop(); tTiempo = "off"; } _alphaTween = new Tween(_imageLoader,"alpha",Regular.easeOut,1,0,0,true); _imageLoader = new Loader; _imageLoader.load(new URLRequest(_xmlList[_imageCount].attribute("source"))); _imageLoader.x = -_stageWidth; _container.addChild(_imageLoader); _imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoadProgress); _imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadedLeft); //Listener for the image to load complete trace("_imageCount = " + String(_imageCount)); } else { _prevbtn.removeEventListener(MouseEvent.CLICK, clickPrev); _imageCount++; } } // Al dar click en el botón "INICIO" // When you click on "START" button private function clickStart (event:MouseEvent) { if (_imageCount != 0) { if(tTiempo == "on") { removeChild(_slideshowstopbtn); addChild(_slideshowbtn); _mitiempo.stop(); tTiempo = "off"; } _imageCount = 0; _alphaTween = new Tween(_imageLoader,"alpha",Regular.easeOut,1,0,0,true); _imageLoader = new Loader; _imageLoader.load(new URLRequest(_xmlList[_imageCount].attribute("source"))); _imageLoader.x = -_stageWidth; _container.addChild(_imageLoader); _imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoadProgress); _imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadedLeft); //Listener for the image to load complete _startbtn.removeEventListener(MouseEvent.CLICK, clickStart); _finbtn.addEventListener(MouseEvent.CLICK, clickFin); _nextbtn.addEventListener(MouseEvent.CLICK, clickNext); _prevbtn.addEventListener(MouseEvent.CLICK, clickPrev); } else { _startbtn.removeEventListener(MouseEvent.CLICK, clickStart); } } private function imageLoadProgress(event:Event):void { _charger.alpha = 1; _charger.circulo.rotation += 35; _charger.x = _stageWidth/2; _charger.y = _stageHeight/2; addChild(_charger); } private function imageLoadedRight(event:Event):void { _slideTween = new Tween(_imageLoader,"x",Regular.easeOut,_stageWidth,0,0.5,true); _alphaTween = new Tween(_imageLoader,"alpha",Regular.easeOut,0,1,1,true); _alphaTween = new Tween(_charger,"alpha",Regular.easeOut,1,0,0.5,true); addText(); _finbtn.visible = true; _nextbtn.visible = true; _prevbtn.visible = true; _startbtn.visible = true; _slideshowstopbtn.visible = true; trace("imagen cargada"); } private function imageLoadedLeft(event:Event):void { _slideTween = new Tween(_imageLoader,"x",Regular.easeOut,-_stageWidth,0,0.5,true); _alphaTween = new Tween(_imageLoader,"alpha",Regular.easeOut,0,1,1,true); _alphaTween = new Tween(_charger,"alpha",Regular.easeOut,1,0,0.5,true); addText(); trace("imagen cargada"); } private function addText():void { _infoText.infot.text = _xmlList[_imageCount]; _infoText.infot.autoSize = TextFieldAutoSize.LEFT; trace(_infoText.infot.width); _infoText.visible = true; /*_text.autoSize = TextFieldAutoSize.LEFT; _text.x = 10; _text.y = _stageHeight - 25; _text.background = true; _text.alpha = .7; _text.backgroundColor = 0xFFFFFF; _text.border = true; _text.borderColor = 0xFFFFFF; _text.textColor = 0x000000; _text.text = _xmlList[_imageCount]; addChild(_text);*/ } private function tiempoCorriendo(event:TimerEvent):void { trace("mitiempo"); _imageCount++; if (_imageCount != _xmlList.length()) { _alphaTween = new Tween(_imageLoader,"alpha",Regular.easeOut,1,0,0,true); _imageLoader = new Loader; _imageLoader.load(new URLRequest(_xmlList[_imageCount].attribute("source"))); _imageLoader.x = _stageWidth; _container.addChild(_imageLoader); _imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoadProgress); _imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadedRight); //Listener for the image to load complete } else if (_imageCount == _xmlList.length()) { _imageCount = -1; } } } } Compartilhar este post Link para o post Compartilhar em outros sites
linoart 0 Denunciar post Postado Dezembro 10, 2009 Não sei se é bem isso, mas tenta dar stage.addEventListener(Event.ADDED_TO_STAGE, iniciaClasse) só pra confirmar que o swf chegou certinho no stage. Se você tá tentando usar o esses botões que não vieram e o flash não acusou erro deles não existirm então eles devem ter vindo. Confirma isso dando um trace(nomeObjetoPerdido). Abraços, Compartilhar este post Link para o post Compartilhar em outros sites
crmdea 0 Denunciar post Postado Dezembro 10, 2009 Não sei se é bem isso, mas tenta dar stage.addEventListener(Event.ADDED_TO_STAGE, iniciaClasse) só pra confirmar que o swf chegou certinho no stage. Se você tá tentando usar o esses botões que não vieram e o flash não acusou erro deles não existirm então eles devem ter vindo. Confirma isso dando um trace(nomeObjetoPerdido). Abraços, nao entendi absolutamente nada =/ Compartilhar este post Link para o post Compartilhar em outros sites
linoart 0 Denunciar post Postado Dezembro 10, 2009 Seguinte, na função construtora SlideShow você coloca stage.addEventListener(Event.ADDED_TO_STAGE, iniciarClasse), e retira o restante do script que está nessa função e joga na função iniciarClasse ( que é chamado nesse listener). O script fica assim: public function Slideshow() { stage.addEventListener(Event.ADDED_TO_STAGE, iniciarClasse) } isso faz com que o swf seja reconhecido no stage. Não sei se isso trará os seus botões, mas tenta isso, de repente funciona. Agora, ness _xmlLoader.load(new URLRequest("images.xml")); _xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); Compartilhar este post Link para o post Compartilhar em outros sites
linoart 0 Denunciar post Postado Dezembro 10, 2009 Seguinte, na função construtora SlideShow você coloca stage.addEventListener(Event.ADDED_TO_STAGE, iniciarClasse), e retira o restante do script que está nessa função e joga na função iniciarClasse ( que é chamado nesse listener). O script fica assim: public function Slideshow() { stage.addEventListener(Event.ADDED_TO_STAGE, iniciarClasse) } public function iniciarClasse(evt:Event):void { _xmlLoader.load(new URLRequest("images.xml")); _xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); } public function xmlLoaded... Isso faz com que o swf seja reconhecido no stage. Não sei se isso trará os seus botões, mas tenta isso, de repente funciona. Agora, nesses botões que você disse que não vieram, se você está usando eles num listener como MouseEvent.CLICK e o flash não acusou erro é pq ele reconhece que os botões existem. Então, pra ter certeza disso depois que você adiciona eles no palco faz trace(nomedoobjetoquenaoveio) - aqui você coloca um nome de um objeto que você disse que não veio - e deve aparecer no painel Output "[object MovieClip]" ou "[object Sprite]". Se aparecer isso é pq o botão veio. Abraços, Compartilhar este post Link para o post Compartilhar em outros sites
crmdea 0 Denunciar post Postado Dezembro 11, 2009 Funcionou linoart vlws!!! nao tinha entendio de primeira, porque tinha visto codigo dia tod ai acho que tava meio embaraçoso tudo mas ai dei uma olhada hoje e conseguir entender direito \o/ agora tipo tu sabe dizer por que os botões vieram tao distante das imagens? e porque as imagens sairam do mc que criei, pensei que eles teria como limites o mc que tinha criado. MAS, isso ai eu desenrolo procurando vlwS!!!! obs.: como edita topico para por 'resolvido'? Compartilhar este post Link para o post Compartilhar em outros sites
Mário Monteiro 179 Denunciar post Postado Dezembro 11, 2009 Só os moderadores marcam como resolvido Apenas avise sempre que seus problemas resolverem Abraços Mário Monteiro Compartilhar este post Link para o post Compartilhar em outros sites