ok my menu goes on almost there now... 

i have now launched the a function from my inital menu level to create the
sub nav for that page as per earlier help;

im basically using the same code for creating my inital menu, but i want to
only create buttons for the children of the button i've just clicked on,

i suppose i need the function 'createSubNavtheirs' to reference the
'mouseClickHandler' and only create menu items from the child node of the
button that has been clicked. 

//here is one of the functions for a subbutton///

function createSubNavtheirs():void {

                        siteNav=IXml(assets.siteNav).xml;

                        /*var xmlLabels:xmllist=sitenav.secti...@name;
                        var labelsArray:Array /* of String */
                        /* = new Array(xmlLabels.length);*/

                        var runningX:Number=0;

                        for each (var section:XML in
siteNav.section.subsection) {

                        var navbut:navItem = new navItem( );

                                navbut.label.text=secti...@name;
        
navbut.label.autoSize=TextFieldAutoSize.LEFT;
                                navbut.hit.width=navbut.label.width;
                                navbut.hit.height=30;
                                navbut.hit.alpha=0;

                                navbut.kiddies=section;

                                navbut.linkto=secti...@src;

                                //read instructions fomr nav xml
                                navbut.keepopen=sitenav.secti...@keep;
                                navbut.isclicked=sitenav.secti...@highlight;
                                //trace(section);
                                navbut.x=runningX;
                                runningX+=navbut.width+10;

                                trace(runningX);
                                navbut.buttonMode=true;
                                navbut.mouseChildren=false;
                                navbut.alpha=0;
                                navbut.name=sitenav.secti...@url;
                                TweenMax.to(navbut, 0.5, {alpha:1});



        
//navbut.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler2);
        
//navbut.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
                                //navbut.addEventListener(MouseEvent.CLICK,
mouseClickHandler);

                                nav2.addChild(navbut);

                }

                }


//here is the code on my initial subbutton//



                function mouseClickHandler(e:Event):void {

                        //var siteNav:XML = IXml(assets.siteNav).xml;
                        var page:String=e.target.label.text;
                        trace(page);
                        targetPage=e.target.linkTo;

                        //targetPage = e.target.linkTo;
                        
                        
                        
                        
                        if (e.target.kiddies.children().length()>0) {
                                hasChildren=true;
                                TweenMax.to(nav1, 0.25, {x:-200,
ease:Bounce.easeInOut});
                                trace(e.target.kiddies.children());
                                this["createSubNav"+page]();
                                //trace(page);
                                trace(targetPage);


                                trace(hasChildren);
                        } else {
                                hasChildren=false;
                                trace(hasChildren);
                                Gaia.api.goto("" + [targetPage] + "");

                        }
                }


///and here is my xml///

<site> 
        <section name="about" src="index/nav/about" keep="false"/>
        <section name="hers" src="index/nav/hers" keep="false" >
                <subsection name="small" src="index/nav/hers/smalltheirs"
keep="true" />
                <subsection name="medium" src="index/nav/hers/mediumtheirs"
keep="true" />          
                <subsection name="large" src="index/nav/hers/largetheirs"
keep="true" />
        </section>
        <section name="his" src="index/nav/his" keep="false" >  
        <subsection name="small" src="index/nav/his/smalltheirs" keep="true"
/>
        <subsection name="medium" src="index/nav/his/mediumtheirs"
keep="true" />
        <subsection name="large" src="index/nav/his/largetheirs" keep="true"
/>
        </section> 
        <section name="theirs" src="index/nav/theirs" keep="false" >
        <subsection name="small" src="index/nav/theirs/smalltheirs"
keep="true" />
        <subsection name="medium" src="index/nav/theirs/mediumtheirs"
keep="true" />
        <subsection name="large" src="index/nav/theirs/largetheirs"
keep="true" />
        </section>
        <section name="contact" src="index/nav/contact" keep="true" />
</site>
        

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of thomas
horner
Sent: 28 August 2009 10:49
To: 'Flash Coders List'
Subject: RE: [Flashcoders] add string to a function

thanks for the first answer, works a treat, i'm not really sure what other
stuff is though!

thanks, 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Hans Wichman
Sent: 28 August 2009 10:35
To: Flash Coders List
Subject: Re: [Flashcoders] add string to a function

ps a better option might be a parameter and a switchstatement

On Fri, Aug 28, 2009 at 11:20 AM, thomas horner
<[email protected]>wrote:

> this is possibly a very basic problem,   I'm still building my dynamic
> global sub nav, slooowly.
>
>
>
> what I want to know if can I add a string to a function,
>
>
>
> I have my initial first level navigation, I click a button and then if the
> button has children in that section it says true and then brings up the
> corresponding children to populate that subnav,
>
>
>
> I was going to have 3 separate functions for the subnavs
>
>
>
>
>
>
>
> ////what I'm unsure about is the line:  'createSubNav "+page"();
>
>
>
> ///I wanted to then have the following functions createSubNavHis
> createSubNavHers    createSubNavTheirs
>
>
>
> //is this possible?
>
>
>
> //here is my code on the first level buttons///
>
>
>
>
>
> function mouseClickHandler(e:Event):void {
>
>
>
>                                                //var siteNav:XML =
> IXml(assets.siteNav).xml;
>
>                                                var
> page:String=e.target.label.text;
>
>                                                trace(page);
>
>                                                targetPage=e.target.linkTo;
>
>
>
>                                                //targetPage =
> e.target.linkTo;
>
>
>
>
>
>
>
>
>
>                                                if
> (e.target.kiddies.children().length()>0) {
>
>
> hasChildren=true;
>
>
> TweenMax.to(nav1, 0.25, {x:-200, ease:Bounce.easeInOut});
>
>
> trace(e.target.kiddies.children());
>
>
createSubNav
> "+ page"() ;
>
>
>
>
>
>
>
>
> trace(hasChildren);
>
>                                                } else {
>
>
> hasChildren=false;
>
>
> trace(hasChildren);
>
>
> Gaia.api.goto("" + [targetPage] + "");
>
>
>
>                                                }
>
>                                }
>
>
>
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to