submenu not displaying... any ideas?
i'm reverse engineering an actionscript based site for one of my clients. so, i've got this problem... i asked a question earlier and got a response that has led me to this one...
i have an array:
subnavData = new Array( {"title":"OVERVIEW", "func":this.changeSlide, "param":this.showServices, "hasChild":true}, {"title":"CREATIVE DIRECTION", "func":this.changeSlide, "param":this.showBranding, "childOf":0}, {"title":"SOCIAL INTERACTIVE", "func":this.changeSlide, "param":this.showOnline, "childOf":0}, {"title":"LIVE EVENTS", "func":this.changeSlide, "param":this.showLiveEvents, "childOf":0}, {"title":"CONTENT STRATEGY", "func":this.changeSlide, "param":this.showPerformance, "childOf":0}, {"title":"PROCESS", "func":this.changeSlide, "param":this.showProcess}, {"title":"CASE STUDIES", "func":this.changeSlide, "param":this.showCaseStudies开发者_开发百科}, {"title":"CLIENTS", "func":this.changeSlide, "param":this.showClients} );
that gets built into a menu by this function:
private function makeNewSubNav($data:Array):void { group = new Array(); for(var i:Number = 0; i < $data.length; i++){ var obj:Object = new Object(); obj.active = false; obj.mc = new MovieClip(); if($data[i].childOf != undefined) { obj.childOf = $data[i].childOf; obj.mcB = new SubMenuTopButton(); obj.mcB.arrow.x = -obj.mcB.arrow.width; obj.mcB.txtmask.x += 10; obj.mcB.y = group[obj.childOf].subMasked.height; var childbg:Sprite = new Sprite(); childbg.graphics.beginFill(0xfdddf0, 1); childbg.graphics.lineStyle(); childbg.graphics.drawRect(0,0,167, 21); childbg.graphics.endFill(); obj.mcB.addChildAt(childbg, 0); group[obj.childOf].subMasked.addChild(obj.mc); } else { obj.childOf = false; obj.mcB = new SubMenuTopButton(); navContainer.addChild(obj.mc); } obj.mc.addChild(obj.mcB); obj.mcB.txtmask.tf_name.text = $data[i].title; obj.mcB.buttonMode = true; obj.mcB.mouseChildren = false; obj.mcB.num = i; obj.callback = $data[i].func; obj.param = $data[i].param; obj.mcB.addEventListener(MouseEvent.CLICK, navPress); obj.mcB.addEventListener(MouseEvent.MOUSE_OVER, navOver); obj.mcB.addEventListener(MouseEvent.MOUSE_OUT, navOut); if($data[i].hasChild != undefined){ obj.hasChild = true; obj.subContainer = new MovieClip(); obj.subMasked = new MovieClip(); obj.subMask = new MovieClip(); obj.subMask.graphics.beginFill(0x0000FF,1); obj.subMask.graphics.lineStyle(); obj.subMask.graphics.drawRect(0,0,width,1); obj.subMask.graphics.endFill(); obj.subMask.height = 0; obj.subContainer.addChild(obj.subMasked); obj.subContainer.addChild(obj.subMask); obj.subMasked.mask = obj.subMask; obj.subContainer.y = obj.mc.height; obj.mc.addChild(obj.subContainer); } group.push(obj); } adjustHeight(); }
but the 'childOf' never gets rendered. know what's going on? any help is greatly appreciated. thanks!
I have modified and tested your code locally. The buttons were created correctly, but remained hidden. You need to resize your SubMask after you have created a new SubButton, otherwise its height will always stay 0, and none of your buttons will be displayed. Also, the y-positioning seems to be off.
精彩评论