flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Miko <marrtinm...@gmail.com>
Subject Re: Can I Bind a SolidColor Fill Value?
Date Fri, 07 Feb 2014 10:31:27 GMT
Hi Chris,

yeah, sorry my mistake, I wrote it hastily and forgot kinda important line
there:

*super.partAdded(partName, instance);*

so the correct function should look like this:

override protected function partAdded(partName:String,
instance:Object):void {
    super. partAdded(partName, instance);
    if (partName == "thumb") {
        thumbInst = instance;
    }
}

Explanation:
You are overriding inherited function, so you need to call the inherited
one as well.
That's the one used in the parent class, because it adds all click events
and lots
more. If you just override it and don't call super.partAdded() all this
"magic behind the scenes" is not done and the slider is not clickable or
movable.

Hope it'll work now, if you have any other question, feel free to ask.

BR,
Martin


On Fri, Feb 7, 2014 at 10:20 AM, Tintin <1955.mille.miglia@googlemail.com>wrote:

> Hello Martin
>
> I'm inching closer! I looked carefully at my code again last night,
> particularly at the passing of the presenter class to the Thumb Skin. I saw
> that your example code in the customSlider_creationCompleteHandler you
> assigned a new instance of SliderView_Presenter to variable 'p' and then
> passed this to the 'presenter' property of the customSlider. What I needed
> was to assign 'this' to 'p' in my SliderView_Presenter and pass it to the
> customSlider. That done, as my buttonColour property changes in
> SliderView_Presenter the Skin Rect fill colour, bound to the buttonColour
> property, now changes. Yippee!
>
> However (and it was going so well!) the following function prevents the
> HSlider button from moving:
>
>     override protected function partAdded(partName:String,
> instance:Object):void {
>         if (partName == "thumb") {
>             _thumbInst = instance;
>         }
>
> Can you suggest why the Thumb button is no longer draggable?
>
> Thank you.
>
> Chris
>
>
> On 6 Feb 2014, at 17:12, Martin Miko [via Apache Flex Users] wrote:
>
> > Hi Chris,
> >
> > yes, basically the presenter variable defined in the thumb skin is done
> > like this:
> >
> >     <fx:Declarations>
> >         <presenters:SliderView_Presenter id="presenter" />
> >     </fx:Declarations>
> >
> > you add these 3 lines, and then use the presenter.buttonColour in the
> > component where you want to use it.
> >
> > BR,
> > Martin Miko
> >
> >
> > On Thu, Feb 6, 2014 at 10:28 AM, Tintin <[hidden email]>wrote:
> >
> > > Hi Martin
> > >
> > > Would you please explain one last point which I can't quite see. You
> use
> > > the following code in the custom HSlider:
> > >
> > > // injecting the presenter
> > >         public function set presenter(p:SliderView_Presenter):void {
> > >             _presenter = p;
> > >
> > >             if (thumbInst)
> > >                 thumbInst.skin.presenter = _presenter;
> > >         }
> > >
> > > Did you create a property named 'presenter' within the Thumb's skin
> mxml
> > > file to pass it the HSlider's presenter class?
> > >
> > > I can see that I need to pass the presenter to the Thumb's skin so
> that I
> > > can bind my Thumb Rect Fill Color property back to the uint property
> > > defined in my SliderView_Presenter class, but I can't see quite how.
> > >
> > > Thanks
> > >
> > > Chris
> > >
> > > On 4 Feb 2014, at 18:49, Martin Miko [via Apache Flex Users] wrote:
> > >
> > > > Hi Chris,
> > > >
> > > > I guess you almost have it working now! :) As you wrote in your
> previous
> > > > message, you need to pass the SliderView_Presenter instance all the
> way
> > > > from the place where you created it, to the place where you want to
> use
> > > it
> > > > (skin). If you pass that instance all the way to the thumb button's
> skin,
> > > > then you can use the data binding exactly in the way you wanted.
> > > >
> > > >
> > > > BR,
> > > > Martin Miko
> > > >
> > > >
> > > > On Tue, Feb 4, 2014 at 5:49 PM, Tintin <[hidden email]>wrote:
> > > >
> > > > > Thank you for your considered replies. I'm starting to get it now.
> > > > >
> > > > > It looks as if you are creating a custom HSlider with additional
> > > properties
> > > > > named 'presenter' and 'thumbInst'. When the creationComplete event
> is
> > > > > called
> > > > > you pass in the SliderView_Presenter class. When you Set the
> presenter
> > > > > property you check to ensure you have an instance of the 'thumb'
> part
> > > and
> > > > > if
> > > > > you do then you assign thumbInst.skin.presenter the instance of
> > > > > SliderView_Presenter (this must have to be the same instance and
> not
> > > > > instantiate a new instance otherwise when a property in the
> original
> > > > > SliderView_Presenter class changes the skin will not see this
> change?).
> > > > >
> > > > > This looks to me as if I first need to create a property within the
> > > thumb
> > > > > skin named 'presenter' so that I can set it with the
> > > SliderView_Property
> > > > > instance I'm passing in?
> > > > >
> > > > > In my SliderView_Presenter class I assign a property named
> > > buttonColour a
> > > > > uint value by default and when a parameter is passed in from the
> host
> > > web
> > > > > page a simple switch function assigns the correct colour depending
> on
> > > the
> > > > > parameter value passed in. How can I use this to update, say a
> > > rectangle,
> > > > > in
> > > > > my skin please?
> > > > >
> > > > > Chris
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > View this message in context:
> > > > >
> > >
> http://apache-flex-users.2333346.n4.nabble.com/Can-I-Bind-a-SolidColor-Fill-Value-tp4615p4811.html
> > > > > Sent from the Apache Flex Users mailing list archive at Nabble.com.
> > > > >
> > > >
> > > >
> > > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > > >
> > >
> http://apache-flex-users.2333346.n4.nabble.com/Can-I-Bind-a-SolidColor-Fill-Value-tp4615p4819.html
> > > > To unsubscribe from Can I Bind a SolidColor Fill Value?, click here.
> > > > NAML
> > >
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> http://apache-flex-users.2333346.n4.nabble.com/Can-I-Bind-a-SolidColor-Fill-Value-tp4615p4848.html
> > > Sent from the Apache Flex Users mailing list archive at Nabble.com.
> > >
> >
> >
> > If you reply to this email, your message will be added to the discussion
> below:
> >
> http://apache-flex-users.2333346.n4.nabble.com/Can-I-Bind-a-SolidColor-Fill-Value-tp4615p4854.html
> > To unsubscribe from Can I Bind a SolidColor Fill Value?, click here.
> > NAML
>
>
>
>
>
> --
> View this message in context:
> http://apache-flex-users.2333346.n4.nabble.com/Can-I-Bind-a-SolidColor-Fill-Value-tp4615p4880.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message