# 1 - Loading a sprite

- Let's start ! this demo explain how to create a TIGLView and load a sprite.
  # myView.xml

      1
      2
      3
      4
      5
      <Alloy>
        <Window>
          <TIGLView module="fr.dzzd.tigl" onInit="init" onResize="resize" />
        </Window>
      </Alloy>

  # myView.js

       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      /*
       * Init must be declared as an attribute of the Alloy tag TIGLView (eg: onInit="init")
       */
      var spriteId;
      function init()
      {
      	/*
      	* For Alloy project, at runtime "assets" folder become "Resources" folder
      	*/
      	spriteId = this.addSprite({url: "Resources/sprite.png"});
      }

      function resize(e)
      {
      	/*
      	 * Center sprite
      	 */
      	this.setEntityPositionById(spriteId, e.width * 0.5 - 100, e.height * 0.5 - 125);
      }