Spark ScrubBar bufferedArea bug

Actionscript, Flex Add comments

I discovered a bug in the Spark ScrubBar class that I thought I’d better document. It’s a real git!

Firstly I noticed that despite setting the bufferEnd property of the class I wasn’t seeing any results. So I watched the numbers and sure enough the bufferEnd property was being set as my media loaded and was significantly larger than the playhead value which made sense.

So then I figured the skin part wasn’t being rendered so I forced a width on it in the skin class and sure enough it was rendered. I soon realised that the bufferedArea was being drawn and was being adjusted over time. Unfortunately its width was being set to exactly the same size as the playedArea element so it was hidden underneath.

So then I did some digging and I traced the calculation of the size of the skin part down to a private method in the ScrubBar class called ‘calculateAreaSize’. Both the playedArea and the bufferedArea get their sizes from this method as the ‘value’ and ‘bufferEnd’ properties change.

The problem is that the argument passed into this method is called ‘value’ which is the same name as the class property ‘value’ that is used to determine the width of playedArea. So when this method was being used to also calculate the width of bufferedArea it was yielding the same results.

The solution is to sub-class ScrubBar and then add the following methods …

  1. override protected function updateSkinDisplayList():void
  2.      {
  3.          super.updateSkinDisplayList();
  4.          
  5.          sizeBufferedArea(newCalculateAreaSize(bufferedEnd));
  6.          sizePlayedArea(newCalculateAreaSize(value));
  7.      }
  8.      
  9.      protected function newCalculateAreaSize(v:Number):Number
  10.      {
  11.          var trackPos:Number = track.getLayoutBoundsX();
  12.          var trackSize:Number = track.getLayoutBoundsWidth();
  13.          var thumbSize:Number = thumb.getLayoutBoundsWidth();
  14.          var range:Number = maximum – minimum;
  15.          var thumbPos:Number = (range > 0) ? (v – minimum) * ((trackSize – thumbSize) / range) : 0;
  16.          
  17.          return thumbSize + thumbPos;
  18.      }

You need to create the newCalculateAreaSize method because the Super class method is private.

Hope this helps someone out.

Digg!

3 Responses to “Spark ScrubBar bufferedArea bug”

  1. Peter deHaan Says:

    Lee,

    Can you please file a bug at http://bugs.adobe.com/flex/ and somebody from the Flex SDK team can take a look.

    Thanks,
    Peter

  2. admin Says:

    you can watch the bug for this here : https://bugs.adobe.com/jira/browse/SDK-23418

  3. Peter deHaan Says:

    Thanks Lee!

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in