Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-18-2009, 11:12 PM   #1
Onakanta4
Registered User
 
Join Date: Jun 2009
Posts: 3
Default movieclip chain/propagation, need help

I am trying to get a visual volume control type effect with movieclip boxes and clicking. So far I can do it, but the code is probably not optimal. I am trying to write it so I can include more or less movieclips in the future without rewriting all the code every time. Is there a better way to do this?

ActionScript Code:
var mc:MovieClip = new MovieClip(); mc.graphics.beginFill(0xFF0000); mc.graphics.drawRect(60, 20, 100, 80); mc.graphics.endFill(); mc.label = "mc" addChild(mc); var mc1:MovieClip = new MovieClip(); mc1.graphics.beginFill(0xCCFF00); mc1.graphics.drawRect(60, 120, 100, 80); mc1.graphics.endFill(); mc1.label = "mc1" mc.addChild(mc1); var mc2:MovieClip = new MovieClip(); mc2.graphics.beginFill(0x66CC66); mc2.graphics.drawRect(60, 220, 100, 80); mc2.graphics.endFill(); mc2.label = "mc2" mc1.addChild(mc2); var mc3:MovieClip = new MovieClip(); mc3.graphics.beginFill(0x63B8FF); mc3.graphics.drawRect(60, 320, 100, 80); mc3.graphics.endFill(); mc3.label = "mc3" mc2.addChild(mc3); mc.addEventListener(MouseEvent.CLICK, mc_clicked); mc1.addEventListener(MouseEvent.CLICK, mc_clicked); mc2.addEventListener(MouseEvent.CLICK, mc_clicked); mc3.addEventListener(MouseEvent.CLICK, mc_clicked); function mc_clicked(event:MouseEvent):void {     mc.alpha = 1     mc1.alpha = 1     mc2.alpha = 1     mc3.alpha = 1         if(event.target.alpha < 1){         event.target.alpha = 1;     }else{         event.target.alpha = .4;     } }
Onakanta4 is offline   Reply With Quote
Old 06-19-2009, 12:45 AM   #2
sydd_hu
Senior Member
 
Join Date: Nov 2008
Posts: 100
Default

ActionScript Code:
var marr:Array=new Array for (var i:int=0;i<5;i++){ var mc:MovieClip = new MovieClip(); mc.graphics.beginFill(0x66CC66); mc.graphics.drawRect(60, 20+i*100, 100, 80); mc.graphics.endFill(); mc.label = "mc"+i addChild(mc); mc.addEventListener(MouseEvent.CLICK, mc_clicked); mc.addEventListener("otherclicked",revertcolor); marr.push(mc) } function mc_clicked(event:MouseEvent):void { event.target.dispatchEvent(new Event("otherclicked")) event.target.alpha = .4; } function revertcolor(e:Event):void{ e.target.alpha =1 }
something like this?
sydd_hu is offline   Reply With Quote
Old 06-19-2009, 02:10 AM   #3
Onakanta4
Registered User
 
Join Date: Jun 2009
Posts: 3
Default

Thanks, that's sort of what I was looking for, except that the squares should only fade in sequence, depending on where you click, and not individually.
Onakanta4 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble when movieclip has more than 22 layers rcharamella ActionScript 2.0 2 12-18-2008 07:10 PM
Modifing variable values of another movieclip super8mm ActionScript 2.0 0 12-05-2008 10:04 PM
Control a Nested MovieClip from a button component inside a seperate MovieClip. Robert.Alvarez ActionScript 3.0 0 11-10-2008 03:49 PM
Controlling a MovieClip timeline with another MovieClip kritter ActionScript 3.0 5 08-09-2007 11:33 AM
sequential Location for attaching a movieclip nish ActionScript 2.0 6 07-03-2006 12:16 PM


All times are GMT. The time now is 06:52 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.