Search code examples
javascriptcross-platformsmartface.io

Create image object programmatically


I would like to create an image object programmatically and stretch image to view's size, not image size. Here is my code. what is missing ?

var createButton = new SMF.UI.Image();
createButton.image = "answer.png";
createButton.top = 5;
createButton.width = 38;
createButton.height = 38;
createButton.left = 5;
createButton.onShow = function(e) {
alert("object created");
};

Solution

  • You can create a strecth type image with the codelines below;

    var createButton = new SMF.UI.Image();

    createButton.image = "answer.png";
    createButton.top = 5;
    createButton.width = 38;
    createButton.height = 38;
    createButton.left = 5;
    createButton.imageFillType = SMF.UI.ImageFillType.stretch;
    createButton.onShow = function(e) {
    alert("object created");
    };
    

    You can check more info from : http://docs.smartface.io/?topic=html/M_SMF_UI_Image__ctor.htm

    Smartface.io Team