[Flashcoders] add string to a function
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 createSubNavHerscreateSubNavTheirs //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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] add string to a function
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/// -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] 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: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] 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 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
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: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] 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 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 > createSubNavHerscreateSubNavTheirs > > > > //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 > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
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 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 > createSubNavHerscreateSubNavTheirs > > > > //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 > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] add string to a function
Hi, you are looking for: this["createSubNav"+page](); HTH JC On Fri, Aug 28, 2009 at 11:20 AM, thomas horner 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 > createSubNavHerscreateSubNavTheirs > > > > //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 > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders