Problem using cc.LayerColor -> Uncaught Error: SYNTAX_ERR: DOM Exception 12

I would like to change a background color, so I use cc.LayerColor to do the job.
But I always get error saying that “Uncaught Error: SYNTAX_ERR: DOM Exception 12 /tkappshared/Cocos2d-html5-canvasmenu-min.js:271”.

I used the following code.
`init:function () {
var bRet = false;
if (this._super) {

        // preload sfx
        if(!util.isiOSDevice())
        {
            cc.AudioManager.sharedEngine().preloadEffect(res_game_bell_sfx);
            cc.AudioManager.sharedEngine().preloadEffect(res_game_pop_sfx);   
        }

        // -- Game Screen --
        this._yellowFrame = cc.Sprite.create(res_game_yellowFrame);
        this._yellowFrame.setPosition(centerPos);
        //this.addChild(this._yellowFrame);

        this._bgLayerColor = cc.LayerColor.create(cc.ccc3(0x66, 0xcc, 0x00), winSize.width, winSize.height);
        this._bgLayerColor.setPosition(centerPos);
        this._bgLayerColor.addChild(this._yellowFrame);
        this.addChild(this._bgLayerColor);

        bRet = true;
    }
    return bRet;
}`

I do think it’s the correct way to use LayerColor.

The arguments of cc.LayerColor.create type is cc.Color4B. the code in Tests/ClickAndMoveTest is:
var layer = cc.LayerColor.create(cc.c4(255, 255, 0, 100)); this.addChild(layer, -1);

1 Like

Thanks dingping, that solved my problem
The online reference said it needs Color3B. I would think it’s not updated yet.

Just a catch up, it should be “cc.ccc4”. :slight_smile:

You are welcome!

Yes, the online reference need change.

We’ll change the new API reference after new version release.