Copy link to clipboard
Copied
When i mouseover trader, the pink and blue area alpha are 1, the other area 's alpha will be 0.2 When the user click the pink button. it will addChild. But due to the layer order in the timeline, I only can click a little area in the pink area. (See the photo2 bottom). because the other area, whom alpha=0.2 overlay the pink layer. The red area in the photo2 is overlay area. How can I solve it? I want to click a whole pink area.
var alp:Number=0.1;
relationship.pinkL3.addEventListener(MouseEvent.CLICK, onClick8);
relationship.arc8.addEventListener(MouseEvent.CLICK, onRelat8);
relationship.traders.addEventListener(MouseEvent.CLICK, onRelat8);
function onRelat8 (evt:MouseEvent):void{
relationship.blueL1.alpha=1;
relationship.blueL2.alpha=alp;
relationship.blueL3.alpha=alp;
relationship.blueL4.alpha=alp;
relationship.pinkL1.alpha=alp;
relationship.pinkL2.alpha=alp;
relationship.pinkL3.alpha=1;
relationship.pinkL4.alpha=alp;
relationship.yellowL1.alpha=alp;
relationship.yellowL2.alpha=alp;
relationship.yellowL3.alpha=alp;
relationship.orangeL1.alpha=alp;
relationship.orangeL2.alpha=alp;
relationship.orangeL3.alpha=alp;
relationship.orangeL4.alpha=alp;
relationship.redL1.alpha=alp;
relationship.businessOwners.alpha=1;
relationship.sexWorkers.alpha=1;
relationship.drugAddicts.alpha=alp;
relationship.workers.alpha=alp;
relationship.tourists.alpha=alp;
relationship.security.alpha=alp;
relationship.domestic.alpha=alp;
relationship.traders.alpha=1;
relationship.seekers.alpha=alp;
}
function onClick8(evt:MouseEvent):void{
addChild(traderSexN);
traderSexN.x=150;
traderSexN.y=100;
traderSexN.mc1.gotoAndPlay(1);
trace("ok");
}
Copy link to clipboard
Copied
If the general idea of your app is, that anything with a higher alpha value should always be in front of sth with a smaller one, you should write a function that will provide such service.
Copy link to clipboard
Copied
Oh that is what i want to acheive! But what kind of function. Since I have not add the Child for each area such as pink and blue. I only have put them into moiveclip and addChild movieclip Then say that
movieclip. pinkarea. addEventListenet(MouseEvent.CLICK, onClick1);
like this How can I solve this problem to make anything with a higher alpha value should always be in front of sth with a smaller one,
Copy link to clipboard
Copied
//push all the MovieClips that you want to have sorted into an Array
var mcArray:Array = [];
for (var i:uint = 0; i< this.numChildren; i++)
{
if (getChildAt(i) is MovieClip)
{
mcArray.push(getChildAt(i));
}
}
//constantly run the following function to check if the alpha values have been changed
stage.addEventListener(Event.ENTER_FRAME, sortByAlpha);
function sortByAlpha(e:Event):void
{
mcArray.sortOn( "alpha", Array.NUMERIC );
for (var j:uint = 0; j< mcArray.length; j++)
{
trace(mcArray
this.setChildIndex(mcArray
}
}
Copy link to clipboard
Copied
oh it seems get an error setChildIndex is not a function Is it because of ("this")?
*var mcArray:Array= ["relationship.blueL1","relationship.blueL2","relationship.blueL3","relationship.blueL4","relationship.orangeL1", "relationship.orangeL2", "relationship.orangeL3", "relationship.orangeL4", "relationship.pinkL1", "relationship.pinkL2", "relationship.pinkL3", "relationship.pinkL4", "relationship.redL1"];
for (var i:uint = 0; i< this.numChildren; i++)
{
if (getChildAt(i) is MovieClip)
{
mcArray.push(getChildAt(i));
}
}
stage.addEventListener(Event.ENTER_FRAME, sortByAlpha);
function sortByAlpha(evt:Event):void
{
mcArray.sortOn( "alpha", Array.NUMERIC );
for (var j:uint = 0; j< mcArray.length; j++)
{
trace(mcArray
this.setChildIndex(mcArray
}
}
Copy link to clipboard
Copied
1.you are adding strings to your array, while you should add MovieClips.
remove all quotation marks inside mcArray
2.If you add all the needed MovieClips in the beginning you can leave out the loop
for (var i:uint = 0; i< this.numChildren; i++)
{
if (getChildAt(i) is MovieClip)
{
mcArray.push(getChildAt(i));
}
}
Copy link to clipboard
Copied
Oh Are you mean I need to addChild in each area PinkL1 PinkL2 PinkL3......? it seems get an error setChildIndex is not a function
var mcArray:Array= ["blueL1","blueL2","blueL3","blueL4","orangeL1", "orangeL2", "orangeL3", "orangeL4", "pinkL1", "pinkL2", "pinkL3", "pinkL4", "redL1"];
for (var i:uint = 0; i< this.numChildren; i++)
{
if (getChildAt(i) is MovieClip)
{
mcArray.push(getChildAt(i));
}
}
stage.addEventListener(Event.ENTER_FRAME, sortByAlpha);
function sortByAlpha(evt:Event):void
{
mcArray.sortOn( "alpha", Array.NUMERIC );
for (var j:uint = 0; j< mcArray.length; j++)
{
trace(mcArray
this.setChildIndex(mcArray
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now