AS3: Hide elements outside the stage in loaded swf

只愿长相守 提交于 2019-12-08 08:21:26

问题


Myapp loads an external swf and adds it to MovieClip. External swf movie has elements that are placed outside the stage (they go on the stage during swf playing). But after loading that elements are visible in the main MovieClip.

In other words, it looks like the whole space outside the stage is visible as well as the stage.

How to hide elements outside the stage of loaded swf?


回答1:


Adobe has a page about this, with the following code example showing you how to add a mask to the loaded clip at runtime:

import flash.display.*; 
import flash.net.URLRequest; 
var rect:Shape = new Shape(); 
rect.graphics.beginFill(0xFFFFFF); 
rect.graphics.drawRect(0, 0, 100, 100); 
addChild(rect); 
var ldr:Loader = new Loader(); 
ldr.mask = rect; 
var url:String = "http://www.unknown.example.com/content.swf"; 
var urlReq:URLRequest = new URLRequest(url); 
ldr.load(urlReq); 
addChild(ldr);

Full link to the page: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7c83.html



来源:https://stackoverflow.com/questions/5679505/as3-hide-elements-outside-the-stage-in-loaded-swf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!