Changing backgroundImage From Script

I'm trying to change the backgroundImage of a button from script, if I do this fom markup it works but when I try it from script the iHDsim crashes.

Code:

document.getElementById("mybutton").style.backgroundImage="url('images.aca/audioDefault.png') url('images.aca/audioSelected.png')";



Answer this question

Changing backgroundImage From Script

  • Mutola

    Thanks, selecting frames works good from script but my goal is to change the backgroundImage/url of the first and second frame in script. When I try this the iHDsim crashes but if its not possible I'll try someway to work around this.
  • Angry Coder

    Thanks Clinic.

    I have no checkd disc, and I find it's a TP bug now.


  • Shihan

    If you follow everything said in this thread, the following code example will describe:

    document.MainMenu_Play.style.setProperty("backgroundImage", "url('file:///dvddisc/ADV_OBJ/menu.aca/MM_pause0.png') url('file:///dvddisc/ADV_OBJ/menu.aca/MM_pause1.png') url('file:///dvddisc/ADV_OBJ/menu.aca/MM_pause2.png')");

    note that whitespace, apostrophes, parenthesis must be followed to spec. If you mistype anything in the new URL string, then this line of code will do nothing in the Emulator.



  • Drew Marsh

    Most likely the issue is that you need to specify the full path to the image when changing from script (ie, file:///dvddisc/ADV_OBJ/foo.png).

    When you use URLs in markup, they are resolved relative to xml:base (or wherever the markup file is located if you don't set xml:base). From script, no such information exists so you need the full path.



  • Aaron Sulwer

    Hi, Peter

    If I listing all the possible images as the backgroundImage property, with no AACS enable, Can I set the backgroundFrame with script since palyer won't let me set the backgroundImage property from script Or the only way to switch background image is to do so in Markup file if I don't use AACS thanks!


  • Mark Pitman

    The files are included in the Manifest and the Playlist, the images are very small so it can't be a pixel buffer issue. My best guess is that it's simply not possible to change the backgroundImages from script, that is using backgroundImage="url(audio.png')
  • Jeroen Alblas

    I would make sure you have the images loaded into the filecache (by including them in the manifest and playlist resource lines).

    Another option would be to load the files using the FileIO APIs into the filecache.

    If the files are loaded into the filecache, make sure you are not exceeding the pixel buffer.


  • Neeva

    so, are you seeing this fail on a check disc

    What is the firmware version of your TP and TE



  • Thibaud

    I have tried to change backgroundImage from script, but failed on Toshiba Player.

    Who can give a hand Many thanks in advance.


  • SoopahMan

    Also note that due to some issues on the current player, you cannot set the backgroundImage through script if you do NOT use AACS. The emulator, the simulator, and the Xbox will all work fine (and I assume other software players will, too) but the Toshiba player will not play the disc. This should be rectified in a future update.

    As a work-around, I suggest listing all the possible images as the backgroundImage property (possibly inside a style declaration, to avoid further typing) and then animating the backgroundFrame.



  • Toshipenguin

    Yes, changing backgroundFrame is a functioning workaround for this issue.



  • James Saull

    Problem already solved (post was from december'06) but thanks for the replies!
  • AndrewBadera

    To get it to work, set your markup like this:

    <div id="mybuttonDIV"
    style:position="absolute"
    style:x="100px"
    style:y="100px"
    style:width="200px"
    style:height="200px"
    style:displayAlign="center"
    style:opacity="1.0"
    style:display="auto">
    <button id="mybutton"
    style:navUp="mybutton1"
    style:navDown="mybutton2"
    style:navRight="mybutton3"
    style:navLeft="mybutton4"
    style:width="200px"
    style:height="200px"
    style:backgroundImage="url( 'audioDefault.png' )
    url( 'audioSelected.png' )"
    style:opacity="1.0"
    />
    </div>

    And then change it by script with this code depending on what state you want to be shown:

    document.mybutton.style.backgroundFrame="0";

    or

    document.mybutton.style.backgroundFrame="1";

    Obviously change the names and positions as needed.


  • Changing backgroundImage From Script