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
- PHPWind-- A PHP forum script applcaition in China
- How to blend adsense inside your post?
- Formatting my post
- Notepad++ - Add C++ compiler
- Install PHPMailer 5.2.4 and use smtp gmail
- Set up a child account and set screen time limit in Windows 8
- Wayback Machine - see archived versions of web pages across time
- phpexcel toggle expand and hide column in EXCEL and summary
- Install PHP ibm_db2 extension in Linux (redHat)
- PHP: add a download as pdf file button in report page
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