Jump to content
Search Community

jemnon

Members
  • Posts

    8
  • Joined

  • Last visited

jemnon's Achievements

0

Reputation

  1. Hello everyone, I wanted to build a simple UI using XMLLoader. I wasn't familiar with it, so I wanted to use it for a project i'm working on, and I've run into a bit of an issue. Basically, I have some nav items that i'm loading in from XML, and when you click on them they load a window with a description in it that's stored in an XML attribute. My problem is when I click on my nav item it loads the description but it doesn't target the correct desc and instead loads all desc. attributes. How do I target the data correctly? Thanks, XML: <?xml version="1.0" encoding="iso-8859-1"?> AS3: package { import flash.display.*; import flash.events.MouseEvent; import flash.xml.*; import com.greensock.*; import com.greensock.easing.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.ImageLoader; import com.greensock.loading.LoaderMax; import com.greensock.loading.XMLLoader; public class Main extends MovieClip { public var itemWin:MovieClip; public var nbtns:MovieClip; //public var navItems:Number = 5; public var navCurrentY:Number; public var navArry:Array = []; public var navMc:MovieClip; private var xmlLoader:XMLLoader; private var xmlData:XML; //private var loader:URLLoader; private var navItems:Array = []; //private var topPos:uint; public function Main():void { init(); } public function init():void { xmlLoader = new XMLLoader("../deploy/xml/data.xml", {onComplete:xmlCompleteHandler, onProgress:xmlProgressHandler, onError:errorHandler}); xmlLoader.load(); } private function xmlCompleteHandler(evt:LoaderEvent):void { xmlData = evt.target.content; var imageData:XMLList = xmlData.image; for each (var image:XML in imageData) { trace("Image Name: " + image.@name); navItems.push(image.@name); nbtns = new navBtn(); nbtns.navTxt.text = image.@name; nbtns.x = 115*navItems.length - (nbtns.width); nbtns.alpha = 0; navHolder.addChild(nbtns); nbtns.desc = imageData.@desc; //nbtns.image = imageData.@url; //nbtns.name = imageData.@name; navArry.push(nbtns); nbtns.addEventListener(MouseEvent.CLICK, getItemWindow); nbtns.addEventListener(MouseEvent.MOUSE_OVER, navBtnOver); nbtns.addEventListener(MouseEvent.MOUSE_OUT, navBtnOut); nbtns.buttonMode = true; nbtns.mouseChildren = false; animateButtons(); } //trace("XML Content: " + evt.target.content); } private function xmlProgressHandler(evt:LoaderEvent):void { trace("XML Progress: " + evt.target.progress); } private function errorHandler(evt:LoaderEvent):void { trace("Error Handler: " + evt.target + ": " + evt.text); } public function animateButtons():void { TweenMax.allTo(navArry, 1, {alpha:1}, 0.3); } public function navBtnOver(evt:MouseEvent):void { navMc = MovieClip(evt.target); TweenLite.to(navMc, 0.5, {alpha:0.2}); } public function navBtnOut(evt:MouseEvent):void { navMc = MovieClip(evt.target); TweenLite.to(navMc, 0.5, {alpha:1}); } public function getItemWindow(evt:MouseEvent):void { navMc = MovieClip(evt.target); itemWin = new ItemWindow(); itemWin.y = 140; itemWin.x = stage.stageWidth/2 - (itemWin.width/2); itemWin.alpha = 0; itemWin.buttonMode = true; addChild(itemWin); TweenLite.to(itemWin, 1, {y:150, alpha:1}); //topPos = itemWin.numChildren - 1; //itemWin.setChildIndex(itemWin.closeBtn, topPos); itemWin.closeBtn.addEventListener(MouseEvent.CLICK, closeItemWin); itemWin.closeBtn.buttonMode = true; itemWin.closeBtn.mouseChildren = false; TweenMax.allTo(navArry, 0.5, {alpha:0.2}); trace(evt.currentTarget.desc); itemWin.thumbTxt.text = evt.currentTarget.desc; /*switch(navMc.name) { case "nbtns0": trace("Nav Item 1 Clicked "); //TweenLite.to(navMc, 0.5, {alpha:1}); itemWin.thumbTxt.text = windowDescs[0]; trace(itemWin.thumbTxt.text); break; case "nbtns1": trace("Nav Item 2 Clicked "); TweenLite.to(navMc, 0.5, {alpha:1}); break; case "nbtns2": trace("Nav Item 3 Clicked "); TweenLite.to(navMc, 0.5, {alpha:1}); break; case "nbtns3": trace("Nav Item 4 Clicked "); TweenLite.to(navMc, 0.5, {alpha:1}); break; case "nbtns4": trace("Nav Item 5 Clicked "); TweenLite.to(navMc, 0.5, {alpha:1}); break; }*/ //Disables all mouseEvents for nav items in navArry when itemWindow is added trace("Nav Items Disabled"); for(var n in navArry) { navArry[n].mouseEnabled = false; } } public function closeItemWin(evt:MouseEvent):void { TweenLite.to(itemWin, 1, {y:140, alpha:0, onComplete:removeItemWin}); TweenMax.allTo(navArry, 0.5, {alpha:1}); } public function removeItemWin():void { for(var p in navArry) { navArry[p].mouseEnabled = true; } removeChild(itemWin); itemWin = null; } } } thanks
  2. Hey Carl, That worked out perfectly, and thanks for the clarification on each aspect of it. Really helpful -dave
  3. also, getting this error after publish, TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.greensock::TweenMax$/allTo() at 1_fla::MainTimeline/animateChildren() at 1_fla::MainTimeline/init() at 1_fla::MainTimeline/frame1()
  4. I having an issue with tweening the movie clips individually after they've been added to the stage. essentially, i just want each movie clip to tween after they've been added to the stage. here is my code: import com.greensock.*; import com.greensock.easing.*; var mc:Number = 28; var topPos:uint; var arry:Array; var hc:Array; var tl:TimelineLite = new TimelineLite(); //trace(arry.length); init(); function init():void { for(var i:int = 0; i var b:MovieClip = new box_mc(); b.x = (i % 7) * 49; b.y = int(i / 7) * 49; holder_mc.alpha = 0; holder_mc.addChild(; animateChildren(holder_mc); b.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); b.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); b.buttonMode = true; b.mouseChildren = false; } } function animateChildren(holder_mc:MovieClip):void { var arry:Array = new Array(holder_mc.numChildren); trace(arry.length); for(var n:int = 0; n < arry.length; n ++) { TweenMax.allTo(arry[n], 1, {alpha:1}, 0.3); } } function onMouseOver(evt:MouseEvent):void { var m:MovieClip = MovieClip(evt.target); TweenLite.to(m, 1, {scaleX:1.5, scaleY:1.5}); topPos = holder_mc.numChildren - 1; holder_mc.setChildIndex(m, topPos); } function onMouseOut(evt:MouseEvent):void { var m:MovieClip = MovieClip(evt.target); TweenLite.to(m, 1, {scaleX:1, scaleY:1}); } thanks
  5. awesome thanks for answering me with, i'll def. keep that in mind when i throw it into an array
  6. Nevermind figured it out just need to use LoaderMax.getLoader("myName").load(true);
  7. I how would i access the individual swf files to reload one instead of reloading the entire queue _queue = new LoaderMax({name:"mainQueue", maxConnections:1}); _queue.append (new SWFLoader("swfs/swf1.swf", {name:"swf1", estimatedBytes:276480, container:holder_mc, autoPlay:false, onProgress:_progressHandler1, onComplete:_completeHandler1, onError:_errorHandler}) ); _queue.append (new SWFLoader("swfs/swf2.swf", {name:"swf2", estimatedBytes:540672, container:holder_mc, x:holder_mc.x + 800, autoPlay:false, onProgress:_progressHandler2, onComplete:_completeHandler2, onError:_errorHandler}) ); _queue.append (new SWFLoader("swfs/swf3.swf", {name:"swf3", estimatedBytes:726016, container:holder_mc, x:holder_mc.x + 1600, autoPlay:false, onProgress:_progressHandler3, onComplete:_completeHandler3, onError:_errorHandler}) ); _queue.append (new SWFLoader("swfs/swf4.swf", {name:"swf4", estimatedBytes:948224, container:holder_mc, x:holder_mc.x + 2400, autoPlay:false, onProgress:_progressHandler4, onComplete:_completeHandler4, onError:_errorHandler}) ); _queue.append (new SWFLoader("swfs/swf5.swf", {name:"swf5", estimatedBytes:544768, container:holder_mc, x:holder_mc.x + 3200, autoPlay:false, onProgress:_progressHandler5, onComplete:_completeHandler5, onError:_errorHandler}) ); _queue.load();
×
×
  • Create New...