4 Replies Latest reply on Oct 10, 2007 10:13 PM by Gregory Lafrance

    link bar additional link open new window

    dajj123 Level 1
      I am new to flex and trying to learn. I am working on a small site. the site will have a few navigation items. However one links to another site. The rest are on the site I am using the bellow code. What I need is between the customer info adn account info is to add another link that opens a new browser window and goes to a url. I am a bit lost and not sure how to do that or if its possible with this. Any help would be great.

      <?xml version="1.0"?>
      <!-- containers\navigators\VSLinkEffects.mxml -->
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

      <mx:WipeUp id="myWU" duration="300"/>
      <mx:WipeDown id="myWD" duration="300"/>

      <mx:WipeRight id="myWR" duration="300"/>

      <mx:VBox height="188">
      <mx:LinkBar dataProvider="{myViewStack}"
      borderStyle="solid"
      backgroundColor="#EEEEFF"/>

      <mx:ViewStack id="myViewStack"
      borderStyle="solid"
      width="273"
      creationCompleteEffect="{myWR}" height="137">

      <mx:Canvas id="search"
      label="Search"
      hideEffect="{myWD}"
      showEffect="{myWU}" backgroundColor="#E81414">
      <mx:Label text="Search Screen"/>
      </mx:Canvas>

      <mx:Canvas id="custInfo"
      label="Customer Info"
      hideEffect="{myWD}"
      showEffect="{myWU}">
      <mx:Label text="Customer Info"/>
      </mx:Canvas>

      <mx:Canvas id="accountInfo"
      label="Account Info"
      hideEffect="{myWD}"
      showEffect="{myWU}">
      <mx:Label text="Account Info"/>
      </mx:Canvas>
      </mx:ViewStack>
      </mx:VBox>
      </mx:Application>
        • 1. Re: link bar additional link open new window
          Gregory Lafrance Level 6
          I think you want the navigateToURL method, Here is the code for the LinkBar control, which is frequently used to switch between ViewStacks:

          <?xml version="1.0"?>
          <!-- controls\bar\LBarSimple.mxml -->
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

          <mx:LinkBar borderStyle="solid"
          itemClick="navigateToURL(new URLRequest(' http://www.adobe.com/' +
          String(event.label).toLowerCase()), '_blank');">
          <mx:dataProvider>
          <mx:String>Flash</mx:String>
          <mx:String>Director</mx:String>
          <mx:String>Dreamweaver</mx:String>
          <mx:String>ColdFusion</mx:String>
          </mx:dataProvider>
          </mx:LinkBar>
          </mx:Application>

          • 2. Re: link bar additional link open new window
            Gregory Lafrance Level 6
            The code I posted comes from the Flex 2.0.1 help docs.
            • 3. Re: link bar additional link open new window
              dajj123 Level 1
              I actually read that before but what I need is to mix the two. This code all the links open a new window. I just need one link to open a new window and the rest to change the views on a viewStack.

              thanx dave
              • 4. Re: link bar additional link open new window
                Gregory Lafrance Level 6
                This does what you want, kind of:

                <?xml version="1.0"?>
                <!-- containers\navigators\VSLinkEffects.mxml -->
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
                <mx:Script>
                <![CDATA[
                import mx.events.ItemClickEvent;

                private function itemClickHandler(event:ItemClickEvent):void {
                if(event.label == "Open URL"){
                navigateToURL(new URLRequest(" http://www.google.com"), "_blank");
                }
                }
                ]]>
                </mx:Script>
                <mx:WipeUp id="myWU" duration="300"/>
                <mx:WipeDown id="myWD" duration="300"/>
                <mx:WipeLeft id="myWL" duration="300"/>
                <mx:WipeRight id="myWR" duration="300"/>

                <mx:VBox height="188">
                <mx:LinkBar dataProvider="{myViewStack}"
                borderStyle="solid"
                backgroundColor="#EEEEFF" itemClick="itemClickHandler(event)"/>

                <mx:ViewStack id="myViewStack"
                borderStyle="solid"
                width="273"
                creationCompleteEffect="{myWR}" height="137">

                <mx:Canvas id="search"
                label="Search"
                hideEffect="{myWD}"
                showEffect="{myWU}" backgroundColor="#E81414">
                <mx:Label text="Search Screen"/>
                </mx:Canvas>

                <mx:Canvas id="custInfo"
                label="Customer Info"
                hideEffect="{myWD}"
                showEffect="{myWU}">
                <mx:Label text="Customer Info"/>
                </mx:Canvas>

                <mx:Canvas id="openURL"
                label="Open URL"
                hideEffect="{myWL}"
                showEffect="{myWR}">
                <mx:Label text="URL Opened"/>
                </mx:Canvas>

                <mx:Canvas id="accountInfo"
                label="Account Info"
                hideEffect="{myWD}"
                showEffect="{myWU}">
                <mx:Label text="Account Info"/>
                </mx:Canvas>
                </mx:ViewStack>
                </mx:VBox>
                </mx:Application>