子菜单没有显示......任何想法?

时间:2010-12-21 23:25:41

标签: flash actionscript-3

我正在为我的一个客户设计一个基于动作脚本的网站。所以,我遇到了这个问题......我之前提出了一个问题并得到了一个回应,这让我想到了这个......

我有一个数组:

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}
            );

通过此功能内置到菜单中:


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();

        }

但'childOf'永远不会被渲染。知道发生了什么事吗?任何帮助是极大的赞赏。谢谢!

1 个答案:

答案 0 :(得分:1)

我已在本地修改并测试了您的代码。按钮已正确创建,但仍保持隐藏状态。在创建新的SubButton之后,您需要调整SubMask的大小,否则它的高度将始终保持为0,并且不会显示任何按钮。此外,y定位似乎已经关闭。