Friday, January 1, 2010

Error #2007: Parameter blendMode must be non-null

So you got this error while developing a Flex 3 app.

And you have already consulted this post: http://www.newviewnetworks.com/nvnhome/blog/client/?p=168 who in turn had consulted this post for guidance.

Hmm, even the post by The Agile Tdog refers to another post by Agile UI and this still points to a use case where there is a mismatch between the Flex 3 SDK version you are developing (your project) on and an/some external Flex lib which may have been compiled with a newer or older Flex 3 SDK version.

But that is not my case -- I get this error purely due to my (mis-)use of components in the Flex framework.

Short answer: simply set the blendMode attribute to a valid value on the component that caused the error a la:
blendMode="{BlendMode.NORMAL}"

Synopsis
I was trying to implement reordering of the elements of a control via drag and drop within the same control.

Basically, this is what I did:
<mx:List
 dragEnabled="true"
 dropEnabled="true"
 dragMoveEnabled="true" 
 width="100%"
/>

and then I got the blendMode must not be non-null error.

So my fix was to set the blendMode attribute, which by the way, is inherited from flash.display.DisplayObject.

<mx:List
 dragEnabled="true"
 dropEnabled="true"
 dragMoveEnabled="true" 
        blendMode="{BlendMode.NORMAL}"
 width="100%"
/>

Possible values are listed in the docs here: http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html#blendMode

[I'm developing using Flex Builder 3 for the Mac which shipped with the Flex 3.2 SDK.]

5 comments:

  1. Hi!

    I wonder, that this works. Because you must use {}-Brackets to set the value in mxml.

    King regards,
    Dennis

    ReplyDelete
  2. Hi Dennis,

    How about a comparison?

    (1)
    <mx:List
    dragEnabled="true"
    dropEnabled="true"
    dragMoveEnabled="true"
    blendMode="BlendMode.NORMAL"
    width="100%"
    />
    (2)
    <mx:Script>
    <![CDATA[
    import flash.display.BlendMode;
    ]]>
    </mx:Script>

    <mx:List
    dragEnabled="true"
    dropEnabled="true"
    dragMoveEnabled="true"
    blendMode="{BlendMode.NORMAL}"
    width="100%"
    />

    The truth is both actually work but I chose (1) because it is less verbose.

    ReplyDelete
  3. Hi!

    its very strongly, that this works... The value of the BlendMode.NORMAL static var is "normal". The blendMode property in the UIComponent is String, so you initialize the blendMode with the value "BlendMode.NORMAL". To me its wrong. But blendMode="normal" is true.

    I have tested these cases with sdk 3.3. The case (1) thrown an ArgumentError #2008

    King regards,
    Dennis

    ReplyDelete
  4. Dennis,

    I use Flex Builder 3 on a Mac that uses a 3.2 SDK but I've updated the post to eliminate any confusion. Thanks for pointing that out.

    And thanks for stopping by :)!!!

    ReplyDelete
  5. You are welcome :)

    King regards,
    Dennis

    ReplyDelete