AS3: finding an object by it Instance name in a dynamic added child

女生的网名这么多〃 提交于 2019-12-12 00:54:38

问题


I am doing an Adobe AIR Kiosk app but I am having a little problem.

First step is to generate a webcam container:

var bandwidth:int = 0; 
var quality:int = 100;
var camera:Camera = Camera.getCamera();
camera.setQuality(bandwidth, quality);
camera.setMode(885,575,30,true);
var video:Video = new Video(885,575);
video.attachCamera(camera);
video.name = "camara";
webcam.addChild(video);

It works ok, the problem is that I want to apply to it a custom filter

It works ok if I write it this way:

MovieClip(parent).contenedor_postal.postal.webcam.filters = [filter];

But I want to affect only the child inside the clip "webcam" without affecting other MC's, so I write it like this:

MovieClip(parent).contenedor_postal.postal.webcam.camara.filters = [filter];

and does not work. I used to program in AS2, so maybe the trick is very simple but I can't find anything that works. Thanks in advance!


回答1:


If the video has a name property "camara" then this should work:

MovieClip(parent).contenedor_postal.postal.webcam.getChildByName("camara").filters = [filter];


来源:https://stackoverflow.com/questions/11399814/as3-finding-an-object-by-it-instance-name-in-a-dynamic-added-child

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