如果你想让背景改变颜色,而不必绘制它,JavaScript可能是一个很好的解决这个问题的方法。
更改内容取决于嵌入代码,但您要更改的参数是bgcolor。
原型时,JavaScript将是这个样子:
$('yourFlashContainerId').down('[name="bgcolor"]').writeAttribute('value','#000000');
把它画在Flash中,你可以做这样的事情:
var bg:Sprite = new Sprite();
bg.graphics.beginFill(0x000000);
bg.graphics.drawRect(0,0,stage.stageWidth, stage.stageHeight);
bg.graphics.endFill();
bg.x = 0;
bg.y = 0;
addChildAt(bg,0);
这将绘制一个正方形,用黑色背景(更改第2行的十六进制以更改颜色),将其大小设置为舞台的大小,将x和y设置为0,然后将其添加到显示堆栈的底部。
这两种方法中的任何一种都应该起作用。
编辑:另一种方式:
您还可以设置的wmode参数去“透明”,并更改包含div背景颜色。
假设你的闪存嵌入有以下几点:
<param name="wmode" value="transparent">
原型:
$('yourFlashContainerId').setStyle({'background-color':'#000'});
的jQuery:
$('#yourFlashContainerId').css({'background-color':'#000'});
母语:
document.getElementById('yourFlashContainerId').style.background-color="#000";
在舞台上绘制精灵真的是改变背景色的最好方法吗?看起来对我来说很奇怪,因为舞台本身有一个可以在Flash中定义的背景。 – 2010-10-16 22:51:53
在IDE中,你实际上并没有改变背景颜色,你只是告诉flash,如果你发布为html文件,将其设置为默认的背景颜色。如果将wmode参数设置为透明,则背景将一起消失,并且可以更改包含div的背景颜色以获得相同的效果。 – Jesse 2010-10-16 22:54:31