3 Replies Latest reply on Feb 22, 2012 12:19 PM by drkstr_1

    Flex mobile, create a URL link?



      In my mobile app I'd like to have a like to my website and email.

      How can I use a label for user to click on and open a browser and be directed to my website?




        • 1. Re: Flex mobile, create a URL link?
          drkstr_1 Level 4

          Here is my very simple "LinkButtonSkin". You may want to refine it a bit...


          <?xml version="1.0" encoding="utf-8"?>
          <s:SparkButtonSkin xmlns:fb="http://ns.adobe.com/flashbuilder/2009" xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                     xmlns:s="library://ns.adobe.com/flex/spark" minHeight="21" minWidth="21" alpha.disabled="0.5">
                   * @copy spark.skins.spark.ApplicationSkin#hostComponent
                    <!-- states -->
                              <s:State name="up" />
                              <s:State name="over" />
                              <s:State name="down" />
                              <s:State name="disabled" />
                    <!-- layer 2: fill -->
                    <!--- @private -->
                    <s:Rect id="fill" top="0" left="0" bottom="0" right="0" includeIn="down" radiusX="6">
                                        <s:SolidColor color="#A3A4AD" />
                    <!-- layer 8: text -->
                    <!--- @copy spark.components.supportClasses.ButtonBase#labelDisplay  -->
                    <s:Label id="labelDisplay" top="4" left="2" bottom="6" right="2" color="#2100C0" fontSize="18" fontWeight="bold"
                                         textAlign="center" textDecoration="underline" verticalAlign="middle" maxDisplayedLines="1">


          Just add a Button, assign the skinClass, and use navigateToURL in the click handler.

          • 2. Re: Flex mobile, create a URL link?
            tomexxus Level 1

            Thanks for the answer. I've never worked with skins...

            So it's the navigateToURL function. Couldn't I just have a blue underlined label and use the navigateToURL in the click handler?

            • 3. Re: Flex mobile, create a URL link?
              drkstr_1 Level 4

              I don't know if a Label is clickable by default. You may need to set mouseEnabled to true, but I imagine the hit area would be problematic for the user. You could also wrap the Label in a Group with the desired hit area, set mouseEnabledWhereTransparent to true on the Group, then register the click event on it rather than the Label.

              1 person found this helpful