3 Replies Latest reply on Jun 27, 2007 11:31 AM by Spitz73

    Need to invoke my link bar from a component

    Spitz73
      How can I invoke my link bar on my application from a component?

      What I want to do is add a button on my Home.mxml page that goes to my Download.mxml page.

      I've tried adding an event listener but it ended up overlaying the Home page over my menu and the rest of the pages.

      Here is my application code(MSE.mxml) -

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute"
      width="600"
      height="650"
      xmlns:content="content.*" alpha="1.0" cornerRadius="15" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#ffffff, #ffffff]"
      themeColor="haloBlue">

      <mx:ApplicationControlBar horizontalAlign="center" dock="false" x="58.5" y="21">

      <mx:LinkBar id="myLinkBar"
      dataProvider="mseContent" />
      </mx:ApplicationControlBar>

      <mx:ViewStack id="mseContent"
      resizeToContent="false"
      paddingBottom="15"
      paddingLeft="15"
      paddingRight="15"
      paddingTop="15" height="560" left="0" top="80" right="0">

      <content:Home id="home"
      label="Home"
      width="600" height="421" />

      <content:Download id="download"
      label="Free Trial"
      width="900" height="650"/>

      <content:Purchase id="purchase"
      label="Purchase"
      width="900" height="650"/>

      <content:Screenshots id="screenShots"
      label="Screenshots"
      width="870" height="650"/>

      <content:AboutUs id="about"
      label="About Us"
      width="900" height="650"/>

      <content:ContactUs id="contact"
      label="Contact Us"
      width="900" height="650"/>
      </mx:ViewStack>
      </mx:Application>

      Thanks,
      Jack
        • 1. Need to invoke my link bar from a component
          Hugo_Core Level 1
          Hi Spitz73, how are you ?

          If i understood what you desire, acting in the component..Well, try this.
          Give a id to the component like :
          <content:AboutUs id="myComp"/>

          Then acess the component.mxml and add a new function on the
          <mx:Script part, that do whatever you wanna do.
          Make it public and Bindable!

          Then return to the main app, and on the button that interact with the component on the click event add this :
          click="myComp.myFunction"

          :) Hope it helps.
          Core
          • 2. Need to invoke my link bar from a component
            Hugo_Core Level 1
            Ohhhh... forget it, i get it wrong, i'm so dumb :P
            my mistake..

            You want the contraire from what i explained..

            I face that problem many times but i make a "wayarround", not resolve the question. I'm sorry i can't help you more.

            Ps: Suggestion , :P what about a button that's only visible when the user is seeing the "Home" component, and situated below the viewStack.. ?

            Maybe another user can help you..
            Core
            • 3. Re: Need to invoke my link bar from a component
              Spitz73 Level 1
              Hugo, thanks for the advice. That's what I ended up doing. I was hoping to find a better solution but this works.

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
              layout="absolute"
              width="600"
              height="650"
              xmlns:content="content.*" alpha="1.0" cornerRadius="15" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#ffffff, #ffffff]"
              themeColor="haloBlue">

              <mx:Script>
              <![CDATA[

              public function downloadSelected():void
              // Define variable to hold the Alert object.
              {
              if(myLinkBar.selectedIndex != 0){
              downloadButton.visible = false;
              } else {
              downloadButton.visible = true;
              }
              mseContent.selectedIndex= myLinkBar.selectedIndex;
              }

              public function downloadButtonSelect():void
              // Define variable to hold the Alert object.
              {

              downloadButton.visible = false;
              mseContent.selectedIndex=1;
              }
              ]]>
              </mx:Script>

              <mx:ApplicationControlBar horizontalAlign="center"
              dock="false" x="58.5" y="21">

              <mx:LinkBar id="myLinkBar"
              itemClick="this.downloadSelected()"
              dataProvider="mseContent" />
              </mx:ApplicationControlBar>

              <mx:ViewStack id="mseContent"
              resizeToContent="false"

              paddingBottom="15"
              paddingLeft="15"
              paddingRight="15"
              paddingTop="15" height="560" left="0" top="80" right="0">

              <content:Home id="home"
              label="Home"
              width="600" height="421" />

              <content:Download id="download"
              label="Free Trial"
              width="900" height="650"/>

              <content:Purchase id="purchase"
              label="Purchase"
              width="900" height="650"/>

              <content:Screenshots id="screenShots"
              label="Screenshots"
              width="870" height="650"/>

              <content:AboutUs id="about"
              label="About Us"
              width="900" height="650"/>

              <content:ContactUs id="contact"
              label="Contact Us"
              width="900" height="650"/>
              </mx:ViewStack>
              <mx:Button id="downloadButton" label="Test Button" click="this.downloadButtonSelect()" x="90" y="350"/>

              </mx:Application>