Guippy

I've come up against another problem that seems to only affect the Toshiba player. I'm attempting to set the opacity of an object (a button), with code like this:

obj.style.opacity = Opacity() / 255;

and it fails. I've tried making it a string like this:

obj.style.opacity = Opacity() / 255 + "";

and it still fails. The Opacity() function returns a number between 0 and 255 that represents the desired opacity for the object I'm trying to change. Is there anything I'm doing wrong


Re: HD DVD Interactivity Authoring Style.Opacity

Amy Dullard - MSFT

I believe this has to do with the number of decimal places. try:

obj.style.opacity = (Opacity() / 255).toFixed(2);






Re: HD DVD Interactivity Authoring Style.Opacity

Guippy

It didn't work. The player is still throwing an invalid argument exception. Would it help if i stored the value in a variable and then set it to that Any other ideas




Re: HD DVD Interactivity Authoring Style.Opacity

Milo Winningham

It sounds like there's something wrong with your opacity function then. You could try setting the value of an input element to it so you can see what is really being outputted.




Re: HD DVD Interactivity Authoring Style.Opacity

Guippy

I'm still having trouble with this. I've so far tried several ways to set the opacity of various elements, and can't seem to get the element to change. The line changing the value is not throwing any exceptions but I do not see anything change. I know the initial value and the value I'm setting it to are different and it works fine in the simulator. Is there anything else I should to do make these elements display the changes My code looks like this:

obj.style.opacity = (Opacity() / 255).toFixed(2);




Re: HD DVD Interactivity Authoring Style.Opacity

Clinic

I had never set style in that manner, but coded something more like this:

document["obj"].style.setProperty("opacity", "0");






Re: HD DVD Interactivity Authoring Style.Opacity

Peter Torr - MSFT

Those two statements would be equivalent if you stuck "document." in front of the original.

In other words:

document.foo <==> document["foo"]

and

style.opacity = 0 <==> style.setProperty("opacity", "0")






Re: HD DVD Interactivity Authoring Style.Opacity

Amy Dullard - MSFT

Post your Opacity() function




Re: HD DVD Interactivity Authoring Style.Opacity

Guippy

I'm sorry, I should have said that obj contains the object I'm trying to set the values of. Basically I've got:

var obj = document.button;
obj.style.opacity = (Opacity()/255).toFixed(2);

Is there anything that would cause this to not throw an exception but also not change the opacity of the element




Re: HD DVD Interactivity Authoring Style.Opacity

Guippy

The opacity function simple gets a value from an object that stores several vales for various purposes. It look pretty much like this:

Code Snippet

function storage () {
// stuff
this.opacity = 135; // Number between 0 and 255
// more stuff
this.getOpacity() {
return this.opacity;
};
}

var main_storage = new storage ();

function Opacity() {
return main_storage.getOpacity();
}


I've checked the return value from Opacity by printing it to an <input> area just before attempting to change the value for the element and it is correct. My big problem is that it's not throwing an exception, but it's also not changing the opacity of the element on the screen. Has anybody seen any behavior like this or know what could cause it You guys have all been really helpful so far, and I'm really grateful, but I'm hoping I can squeeze one more answer out of you because I'm really stumped.




Re: HD DVD Interactivity Authoring Style.Opacity

Amy Dullard - MSFT

If it "pretty much" looks like what you put above, then you need to fix this.getOpacity()

Code Snippet

function storage () {
// stuff
this.opacity = 135; // Number between 0 and 255
// more stuff
this.getOpacity() = function() { //MODIFIED LINE
return this.opacity;
};
}

var main_storage = new storage ();

function Opacity() {
return main_storage.getOpacity();
}

And do you have anyway to set opacity in your storage object What object are you trying to change opacity on What does the markup look like




Re: HD DVD Interactivity Authoring Style.Opacity

Guippy

Thanks, the error with getOpacity was just a typo in the forum, it has always been correct in the code. Yes there is a way to set the value in the object, but like I said I've been printing the return value of Opacity and it is correct so I didn't think how it was getting set was relevant. The element I'm trying to change the opacity on is a button (at least in this script) but it does the same thing for any other element that opacity is relevant to. I've been able to set the initial opacity value in the markup and that will work, but can't change it dynamically at all it seems. The markup is as follows:

Code Snippet

<button id="button1" style:position="absolute" style:x="12%" style:y="83%" style:width="10%" style:height="46%" style:backgroundColor="rgba(0, 255, 255, 129)" style:opacity="0.51" style:display="auto" />



I realize this is not the same element ID I posted before, before was just an example but this is the ID I am using in both the markup and the script. Thank so much for being so quick to respond.




Re: HD DVD Interactivity Authoring Style.Opacity

Amy Dullard - MSFT

its because you are using rgba for color. a = alpha and this is overriding your opacity value




Re: HD DVD Interactivity Authoring Style.Opacity

Guippy

I'm still having problems with this. Does anybody know what sections of the specification I should look at I've looked under both the scripting and XML sections and can't find detailed information that sheds light on my problem. According to what I've read what I've been doing should be working. Does anybody know if there's anywhere, in the specification or otherwise, where I could look for more detailed information Thanks a lot.




Re: HD DVD Interactivity Authoring Style.Opacity

Tingting Gi

First of all, the definition of getOpacity is not correct

function storage() {

...

this.getOpacity() = function() { ( should be ==> this.getOpacity = function())

};

}

Secondly, if your initial opacity is 0.5, the finial opacity value is Opacity()/255 = 135/255 = 0.52. Then, I don't think there will be any major visual difference. If you set the initial value to 1, you will see the opacity does change.

I've tried your code with the fix for getOpacity. It works for me.