Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-22157

Skins should expose bindable parts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Later
    • Adobe Flex SDK Previous
    • None
    • Skinning
    • None
    • Affected OS(s): All OS Platforms
      Language Found: English

    Description

      This isn't a bug as much as a "can't do that" issue with skins. Basically, the parts of skins (like the 'scroller' part on TextArea) are not bindable, so you can't refer to those parts in MXML code. This makes it difficult to, for example, set up effects that animate based on the values of these properties.

      There doesn't seem to be a performance problem with making these parts [Bindable]; the only performance issue comes in using the binding (so it's pay-as-you-go).

      Here's an example app that should work if the scroller part of TextArea were bindable. As it is, the animations do nothing because it isn't bindable. (Note the alternate commented-out buttons that call a script function to make the animations work, but the idea is to make it possible for declarative animations to do the job instead). There are plenty of other parts that should be [Bindable] as well - this example only covers the TextArea.scroller case). To see the problem, click the two buttons and notice ... nothing. The animations don't run. To see what the effect should be, uncomment the Button declarations that call scrollTo() and run it again.

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768">
      <fx:Script>
      <![CDATA[
      import spark.effects.Animate;
      import spark.effects.animation.Keyframe;
      import spark.effects.animation.MotionPath;
      private function scrollTo(endPosition:Number):void

      { var anim:Animate = new Animate(textArea.scroller.viewport); anim.motionPaths = new <MotionPath>[ new MotionPath("verticalScrollPosition")]; anim.motionPaths[0].keyframes = new <Keyframe>[ new Keyframe(0), new Keyframe(500, endPosition)]; anim.play(); }

      ]]
      >
      </fx:Script>

      <fx:Declarations>
      <s:Animate id="animateScrollEnd" target="

      {textArea.scroller.viewport}">
      <s:SimpleMotionPath property="verticalScrollPosition" valueTo="{textArea.scroller.viewport.contentHeight}"/>
      </s:Animate>
      <s:Animate id="animateScrollHome" target="{textArea.scroller.viewport}

      ">
      <s:SimpleMotionPath property="verticalScrollPosition" valueTo="0"/>
      </s:Animate>
      </fx:Declarations>

      <s:VGroup>
      <!--<s:Button label="Scroll To Top" click="scrollTo(0)"/>
      <s:Button label="Scroll To End"
      click="scrollTo(textArea.scroller.viewport.contentHeight)"/>-->
      <s:Button label="Scroll To Top" click="animateScrollHome.play()"/>
      <s:Button label="Scroll To End"
      click="animateScrollEnd.play()"/>
      </s:VGroup>
      <s:TextArea id="textArea" x="50" y="60" width="160" height="200"
      text=
      "This is the first day of the rest of my life, which
      makes yesterday the end of the previous part of my life
      and tomorrow the second day of the rest of my life.
      Of course, if every day is the first day of the rest of
      my life, that could be my ticket to immortality;
      all I have to do is survive the night and I still have the
      rest of my life to go.
      Then again, today could be the end of the previous part
      of my life. It's like I've just completed the prequel and
      am now ready for the main event. Or maybe I concluded the
      successful first movie, and am now about to start the
      doomed sequel, forced on the viewing public by production
      studios that care not about art, only about squeezing
      every penny from the franchise before I kick off into
      the cosmos.
      Perhaps since I'm getting older, they should
      get someone else to play the part of me. Or maybe my part
      will be played by a mannequin.
      What if the rest of my life is really short? Wouldn't it
      be a rip-off to be told that I have the rest of it to live
      and then I just kick off? Like maybe they could have said
      'By the way, by THE REST we mean 5 minutes. Make the most
      of it.'
      I should go eat some ice cream while there's still time.
      This is the first day of the rest of my life, which
      makes yesterday the end of the previous part of my life
      and tomorrow the second day of the rest of my life.
      Of course, if every day is the first day of the rest of
      my life, that could be my ticket to immortality;
      all I have to do is survive the night and I still have the
      rest of my life to go.
      Then again, today could be the end of the previous part
      of my life. It's like I've just completed the prequel and
      am now ready for the main event. Or maybe I concluded the
      successful first movie, and am now about to start the
      doomed sequel, forced on the viewing public by production
      studios that care not about art, only about squeezing
      every penny from the franchise before I kick off into
      the cosmos.
      Perhaps since I'm getting older, they should
      get someone else to play the part of me. Or maybe my part
      will be played by a mannequin.
      What if the rest of my life is really short? Wouldn't it
      be a rip-off to be told that I have the rest of it to live
      and then I just kick off? Like maybe they could have said
      'By the way, by THE REST we mean 5 minutes. Make the most
      of it.'
      I should go eat some ice cream while there's still time.
      This is the first day of the rest of my life, which
      makes yesterday the end of the previous part of my life
      and tomorrow the second day of the rest of my life.
      Of course, if every day is the first day of the rest of
      my life, that could be my ticket to immortality;
      all I have to do is survive the night and I still have the
      rest of my life to go.
      Then again, today could be the end of the previous part
      of my life. It's like I've just completed the prequel and
      am now ready for the main event. Or maybe I concluded the
      successful first movie, and am now about to start the
      doomed sequel, forced on the viewing public by production
      studios that care not about art, only about squeezing
      every penny from the franchise before I kick off into
      the cosmos.
      Perhaps since I'm getting older, they should
      get someone else to play the part of me. Or maybe my part
      will be played by a mannequin.
      What if the rest of my life is really short? Wouldn't it
      be a rip-off to be told that I have the rest of it to live
      and then I just kick off? Like maybe they could have said
      'By the way, by THE REST we mean 5 minutes. Make the most
      of it.'
      I should go eat some ice cream while there's still time."/>
      </s:Application>

      Attachments

        Activity

          People

            adobejira Adobe JIRA
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: