首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

配合wmode使FLEX使用完全透明

2012-10-16 
配合wmode使FLEX应用完全透明看到网上有人提出过这个问题,想使FLEX生成的SWF文件如同FLASH IDE生成的,在wm

配合wmode使FLEX应用完全透明

看到网上有人提出过这个问题,想使FLEX生成的SWF文件如同FLASH IDE生成的,在wmode=transparent时效果相同。
但通过简单的设置backgroundAlpah=0是无效的,FLEX仍会生成一层透明的背景。
通过追踪Application代码,可以得知Application继承了LayoutContainer,
而在LayoutContainer的updateDisplayList方法中(第403行),可以找到如下代码:
// Wait to layout the border after all the children
// have been positioned.
createBorder();
createBorder是LayoutContainer继承的Container类中的方法:
Container中4008行:
rawChildren.addChildAt(DisplayObject(border), 0);
可知在索引0处增加了一个border,定位到498行:
/**
* @private
* The border/background object.
*/
mx_internal var border:IFlexDisplayObject;
除此之外,在systemManager存在一个Sprite的实例:mouseCatcher,见SystemManager 435行:
private var mouseCatcher:Sprite;
是SystemManager的第0级child(1级为application)
和stage高宽相同,且透明度为0。
转到2799行,可以看到绘制过程:
private function resizeMouseCatcher():void
{
if (mouseCatcher)
{
try
{
var g:Graphics = mouseCatcher.graphics;
var s:Rectangle = screen;
g.clear();
g.beginFill(0×000000, 0);
g.drawRect(0, 0, s.width, s.height);
g.endFill();
}
catch (e:SecurityError)
{
// trace(“resizeMouseCatcher: ignoring security error ” + e);
}
}
}
OK,现在回到主程序中,我们在applicationComplete事件将以上两个对象提出出来,然后在updateDisplayList中进行处理。最好不要尝试移除这两个对象,这样有可能产生异常;如果不是特别要求,尽量不要干涉或修改FLEX管理机制

1 楼 alvin198761 2011-10-17   你想说什么

热点排行