3 Replies Latest reply on Jan 5, 2010 5:10 PM by jerryhamby

    ImageElement Event Inconsistencies

    jerryhamby Level 1

      This is a followup from a post I made 2 weeks ago titled:

      "perfect time to capture image size"     Filed bug: FM-301

       

      All I'm trying to do is find the ONE event that will give me a consistent

      width and height for the current imageElement, so I can run some resizing code.

       

      I'm testing against 3 events, but under one condition or another, all of them fail:

      1- MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE

      2- LoadEvent.LOAD_STATE_CHANGE

      3- ViewEvent.DIMENSION_CHANGE

       

      My test is built using MediaPlayer placed inside a Sprite.

      I'm NOT using MediaPlayerSprite nor MediaPlayerElement .

       

      Test 1: (one image)

      var vImageElement=new ImageElement(new ImageLoader  ,new URLResource(new URL("./images/image4.jpg")));

      pPlayer.element=vImageElement;

       

      Test 2: (2 images using TemporalProxyElement)

      pImageSerialElement.addChild(new TemporalProxyElement(3,new ImageElement(new ImageLoader  ,new URLResource(new URL("./images/image4.jpg")))));

      pImageSerialElement.addChild(new TemporalProxyElement(3,new ImageElement(new ImageLoader  ,new URLResource(new URL("./images/image2.png")))));

      pPlayer.element=pImageSerialElement;

       

       

      ======  MEDIA_PLAYER_STATE_CHANGE  ======

      Test 1: this works fine

      Test 2: evt.currentTarget.width =  0     and   evt.currentTarget.height =  0

       

      ======  LOAD_STATE_CHANGE  evt.state = ready  ======

      Test 1: this works fine

      Test 2: evt.currentTarget.width =  0     and   evt.currentTarget.height =  0

       

      ======  DIMENSION_CHANGE ======

      Test 1: this event does not fire

      Test 2: this works with the except that it fires twice  (Bug Filed:  FM-300)

       

       

      My conclusion is that either:

       

      1- I have to use 2 different set of events if I'm displaying one image as opposed

      to displaying a slide show with multiple images. This is not my preferred choice.

       

      2- The OSMF API  has a bug.

       

      The code Ryan supplied in "perfect time to capture image size" was for a MediaPlayerSprite.

      I haven't had time to test MediaPlayerSprite, but shouldn't both methods be consistent?

       

      Sorry to keep beating this thing to death

        • 1. Re: ImageElement Event Inconsistencies
          jerryhamby Level 1

          I just added one more event for testing:

           

          ======  VIEWABLE_CHANGE  (MediaPlayerCapabilityChangeEvent) ======

           

          Test 1: works fine

          Test 2: evt.currentTarget.width =  0     and   evt.currentTarget.height =  0

          • 2. Re: ImageElement Event Inconsistencies
            bringrags Level 4

            These are bugs, you should get the same event in both cases.  The first (DIMENSION_CHANGE, Test 1, no event fires) is now fixed in the public trunk.  The second (DIMENSION_CHANGE, Test 2, multiple events fire) is a layout bug, can you file it?  Please reference this thread.

             

            Additional detail:  The second bug is a result of LayoutContextSprite.updateIntrinsicDimensions updating the height and the width separately.  Ideally this would be done atomically, so that a single event would be dispatched.

            • 3. Re: ImageElement Event Inconsistencies
              jerryhamby Level 1

              From your reply it looks like, once the bugs are fixed that DIMENSION_CHANGE will be the perfect place to capture the width and height.

              Thanks, I think I can let this one go until Sprint 9.

               

              I have already filed a bug on the multiple events firing, a couple of weeks ago:

              Bug:  FM-300

              Title:  "DimensionChangeEvent firing twice (TemporalProxyElement)"

              I just posted your forum answer, as a comment to the bug base.