12 Replies Latest reply on May 3, 2009 5:45 PM by webguy5612

    Make link to a url

    webguy5612

      Hello, I'm trying to make a link to a url and it's not working for me. I want to link the music store button to outside url. Can someone help me. Here is my code

       

      <mx:Script>

           <![CDATA[

                          private function musicStore():void {

                            var url:String = "http://www.google.com/";

                             var request:URLRequest = new URLRequest(url);

                               navigateToURL(request, "_self");

      }

       

         ]]>        

      </mx:Script>

       

       

      <mx:LinkBar color= "#FFFFFF" dataProvider= "{tabNav}" backgroundColor="#e489cd"  borderStyle="solid" width="867" borderColor="#FFFFFF" selectionColor="0xffffff" separatorColor="0xcccccc"  rollOverColor ="0xe489cd" textRollOverColor="0xcccccc"  textSelectedColor="0x000000"/> 

       

      <mx:ViewStack id="tabNav" borderStyle="solid" width="867" height="480" >

      <mx:VBox click="musicStore()"   label= "Music Store" >

       

                </mx:VBox>

       

       

          </mx:ViewStack>

               

        • 1. Re: Make link to a url
          Madhav Subedi Level 4

          whats the problem in your code? it is working fine.

          • 2. Re: Make link to a url
            Barna Biro Level 3

            Hi there,

             

            Your problem might be caused by the fact that the VBox that has a Click event and that should call your musicStore method has no width or height specified so it's essentially inexistent. Once you add something into it or change it to a Button ( since you said that you want a button ) or simply specify a width and height for it then it should work just fine.

             

            With best regards,

            Barna Biro

            • 3. Re: Make link to a url
              Gregory Lafrance Level 6

              Rather than having a click event on the VBox, use a LinkButton:

               

              <?xml version="1.0"?>

              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

                  <mx:LinkButton label="ADBE" width="100"
                      click="navigateToURL(new URLRequest('http://quote.yahoo.com/q?s=ADBE'), 'quote')"/>
              </mx:Application>

              • 4. Re: Make link to a url
                webguy5612 Level 1

                I made the linkbutton but how do I reposition it. I'm using a vertical layout. Here is my code.

                 

                <mx:LinkBar color= "#FFFFFF" dataProvider= "{tabNav}" backgroundColor="#e489cd"  borderStyle="solid" width="867" borderColor="#FFFFFF" selectionColor="0xffffff" separatorColor="0xcccccc"  rollOverColor ="0xe489cd" textRollOverColor="0xcccccc"  textSelectedColor="0x000000"/> 

                <mx:LinkButton click="musicStore()"  top="900" color = "0xffffff" rollOverColor ="0xe489cd" textSelectedColor="0xCCCCCC" textRollOverColor="0xCCCCCC"  

                label= "Music Store" >    

                </mx:LinkButton>

                <mx:ViewStack id="tabNav" borderStyle="solid" width="867" height="480" >

                • 5. Re: Make link to a url
                  Michael Borbor Level 4

                  By reposition you mean?

                  • 6. Re: Make link to a url
                    webguy5612 Level 1

                    right. I want to move it up on the application.

                    • 7. Re: Make link to a url
                      Michael Borbor Level 4

                      If you layout is vertical and you want to place the linkbars at the top you just need to manually place them below your main container, your application container, panel, or anyone.

                      • 8. Re: Make link to a url
                        webguy5612 Level 1

                        I want to put the linkbutton on the same position as the the linkbar. It that possible. Could x y positioning work?

                        • 9. Re: Make link to a url
                          Michael Borbor Level 4

                          I see what you want now, you're doing your stuff wrongly if you want to create links within a LinkBar and this link aren't tied to a ViewStack or any other container this is what you should be doing

                           

                          <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>
                          
                          • 10. Re: Make link to a url
                            webguy5612 Level 1

                            I also have the linkbar linked to some vbox. How do i incorporate what you just gave me into this. or is there a better way I can set this up?

                             

                            <mx:Move id="showeffect2" yFrom="300"/>

                            <mx:Move id="hideeffect2" yBy="600"/>

                             

                             

                            <mx:LinkBar color= "#FFFFFF" dataProvider= "{tabNav}" backgroundColor="#e489cd"  borderStyle="solid" width="867" borderColor="#FFFFFF" selectionColor="0xffffff" separatorColor="0xcccccc"  rollOverColor ="0xe489cd" textRollOverColor="0xcccccc"  textSelectedColor="0x000000"/> 

                            <mx:LinkButton click="musicStore()"   color = "0xffffff" rollOverColor ="0xe489cd" textSelectedColor="0xCCCCCC" textRollOverColor="0xCCCCCC"  

                            label= "Music Store" >    

                            </mx:LinkButton>

                            <mx:ViewStack id="tabNav" borderStyle="solid" width="867" height="480" >

                            <mx:VBox id="Home" backgroundImage="" showEffect="showeffect2" hideEffect="hideeffect2" horizontalAlign="center" verticalAlign="middle" label="Home"  width="100%" height="100%" borderStyle="solid"  borderColor="#FFFFFF" >

                                  

                                    <mx:TextArea width="424" height="300" paddingTop="130"  backgroundAlpha="5"  paddingBottom="40" backgroundImage=""   borderColor="#FFFFFF"  borderStyle="solid" borderThickness="2" color="#FFFFFF"  backgroundColor="#e489cd"   shadowDirection="" wordWrap="true"   horizontalScrollPolicy="off"   fontSize="18" textAlign="left" verticalScrollPolicy="on" editable="false">

                                   

                                    <mx:text> 

                            </mx:text>

                                    </mx:TextArea>

                                 

                            </mx:VBox>

                            <mx:VBox id="AboutMe" backgroundImage="" horizontalAlign="center" verticalAlign="middle" showEffect="showeffect2" hideEffect="hideeffect2" label="About Me"  width="100%" height="100%" borderColor="0xFFFFFF" borderThickness="5"  >

                            <mx:TextArea width="424" height="300" paddingTop="130" paddingBottom="40"   borderColor="#FFFFFF"  borderStyle="solid" borderThickness="2" color="#FFFFFF"  backgroundColor="#e489cd"   shadowDirection="" wordWrap="true"   horizontalScrollPolicy="off"   fontSize="18" textAlign="left" verticalScrollPolicy="on" editable="false" >

                                   

                                    <mx:text ></mx:text>

                                    </mx:TextArea>

                            </mx:VBox>

                            <mx:VBox backgroundImage=horizontalAlign="center" verticalAlign="middle" label="Guestbook"  width="100%" height="100%" showEffect="showeffect2" hideEffect="hideeffect2"  borderColor="#FFFFFF"  id="vbox1">

                            <mx:Panel width="368" height="290" layout="absolute" title="Guestbook"  label="Contact Form" id="panel1">

                            <mx:Label x="10" y="26" text="Name" id="name_label"/>

                            <mx:TextInput x="70" y="24" width="257"/>

                            <mx:Label x="10" y="64" text="Email" id="email"/>

                            <mx:TextInput x="70" y="62" id="username" width="257"/>

                             

                            <mx:Label x="10" y="115" text="Message" id="message_label"/>

                            <mx:TextArea x="70" y="136" id="msg" height="80" width="257"/>

                            <mx:Button x="70" y="224" label="Submit" id="send_btn"  click="sendInfo()"/>

                            <mx:Button x="171" y="224" label="Reset"/>

                             

                            </mx:Panel>

                            </mx:VBox>

                             

                            <mx:VBox  backgroundImage= horizontalAlign="center" verticalAlign="middle" showEffect="showeffect2" hideEffect="hideeffect2"  width="100%" height="100%" borderColor="0xFFFFFF" borderThickness="5"  label= "Contact Me" >

                            <mx:TextArea width="424" height="300" paddingTop="130" paddingBottom="40" backgroundImage=""   borderColor="#FFFFFF"  borderStyle="solid" borderThickness="2" color="#FFFFFF"  backgroundColor="#e489cd"   shadowDirection="" wordWrap="true"   horizontalScrollPolicy="off"   fontSize="18" textAlign="left" verticalScrollPolicy="on" editable="false" >

                                   

                                    <mx:text> </mx:text>

                                    </mx:TextArea>

                                      </mx:VBox>

                             

                             

                              </mx:ViewStack>

                                

                            • 11. Re: Make link to a url
                              Michael Borbor Level 4

                              As far as I know there's isn't a way to have a linkbar two different data providers, so I think in this case you're gonna need to have two linkbars.

                              • 12. Re: Make link to a url
                                webguy5612 Level 1

                                Is there a way to link my labels or link buttons to the vbox without losing the effects I've applied? I'll hate to make to linkbars.