Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- How to blend adsense inside your post?
- Formatting my post
- PHP: add a download as pdf file button in report page
- PHPWind-- A PHP forum script applcaition in China
- Notepad++ - Add C++ compiler
- PHP connect IBM db2 database in XAMPP
- Datatable export excel wraptext and newline
- phpexcel toggle expand and hide column in EXCEL and summary
- Renew SSL certificate from StartSSL
- Sweet Alert JS library - beautiful replacement of JavaScript Alert
Wednesday, September 25, 2013
ActionScript 3 (AS3): list all child MovieClip
List all child MovieClip and make interaction between children.
For example in AS3, we want to check if MovieClip dragger, volume_btn and vol_slider have same parent, we can list all children of parent:
for (var i:uint = 0; i < this.parent.numChildren; i++){
trace ('\t|\t ' +i+'.\t name:' + this.parent.getChildAt(i).name + '\t type:' + typeof (this.parent.getChildAt(i))+ '\t' + this.parent.getChildAt(i));}
When I mouse up for dragger, I want volume_btn in out status of button, and vol_slider invisible, we can use
var mc:MovieClip = this.parent.getChildByName("volume_btn") as MovieClip;
if(mc)
{
mc.gotoAndStop('out');
}
var mc1:MovieClip = this.parent.getChildByName("vol_slider") as MovieClip;
if(mc1)
{
mc1.visible = false;
}
put together:
dragger.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
function mouseUpHandler(e:MouseEvent):void{
dragger.stopDrag();
var mc:MovieClip = this.parent.getChildByName("volume_btn") as MovieClip;
if(mc)
{
mc.gotoAndStop('out');
}
var mc1:MovieClip = this.parent.getChildByName("vol_slider") as MovieClip;
if(mc1)
{
mc1.visible = false;
}
/*
for (var i:uint = 0; i < this.parent.numChildren; i++){
trace ('\t|\t ' +i+'.\t name:' + this.parent.getChildAt(i).name + '\t type:' + typeof (this.parent.getChildAt(i))+ '\t' + this.parent.getChildAt(i));
}
*/
delete this.onEnterFrame;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment