2 Replies Latest reply on Dec 5, 2008 3:18 PM by Jed Schneider

    adding properties to my custom components

    Jed Schneider Level 1
      I am making a custom videoplayer container and want to be able to reference the source of the video from the mxml tag of my custom component such that the component "myvideoplayer" looks like this:
      <vbox>
      <videoDisplay source ="???how do i do this?"/>
      <hbox id="controls"/>
      </vobx>

      so the component is based on a vbox, not a videoplayer....
      and in my application
      <applicaton>
      <myns:myVideoPlayer videosource ="somemovie.mov" />
      </application>

      thanks...
        • 1. Re: adding properties to my custom components
          -Hob Level 1
          all you have to do is create a public property or getter/setter combo in your vbox-based component:

          <vbox>
          <script>
          [Bindable]
          public var videoSource:String;
          protected var _altSource:String;
          [Bindable]
          public function get altSource():String
          {
          return this._altSource;
          }
          public function set altSource(value:String):void
          {
          this._altSource = value;
          }
          </script>
          <videoDisplay source ="{this.videoSource}"/>
          <hbox id="controls"/>
          </vobx>

          I created "altSource" simply to demonstrate how to create a bindable getter/setter combo. The trick is to make sure you include the [Bindable] tag so that the source attribute of the video component gets updated whenever your public var gets set:

          <applicaton>
          <myns:myVideoPlayer videoSource ="somemovie.mov" />
          </application>
          • 2. Re: adding properties to my custom components
            Jed Schneider Level 1
            Exactly what I was looking for. Thanks for the quick reply.