Hello,
What I am trying to do with AS3 in Flash cs4 is calculate the cursor’s distance to given point (let say 400,300) and use that distance to constantly (20 fps) change my curtain’s alpha value. (which is basically a box turned into a movie clip)
I’m very new to AS3 environment, so I could have been doing lots of mistakes but here is my code.
function where(event:Event) {
xval=mouseX;
yval=mouseY;
}
state.addEventListener(Event.EXIT_FRAME, where);
//I need to check which value is bigger since i dont know how to use absolute value function in AS3.
if (xval>=400) {
distancex=xval-400;
} else {
distancex=400-xval;
}
if (yval>=300) {
distancey=yval-300;
} else {
distancey=300-yval;
}
distancet=distancex+distancey;
//I want to show the items behind my curtain if the cursor is very close to my point, so if the distance is more than 400, aplha will be stayed as 1 and will not show what’s behind.
if (mesafet<400) {
mesafea=mesafet/400;
} else {
mesafea=1;
}
function update(event:Event):void {
perde.alpha=mesafea;
}
stage.addEventListener(Event.ENTER_FRAME, update);