Copy link to clipboard
Copied
Hi guys
I have a function that checks if something is happening before keep on going...
Now, my question is, if I want it to check 3 conditions, instead of one only, how do I have to code it?
Here is what I have:
function hRelease(event:MouseEvent):void {
var item5:MovieClip=letritaH(event.target);
item5.stopDrag();
if (targeth.hitTestPoint(item5.x,item5.y)) {
item5.x=targeth.x;
item5.y=targeth.y;
myTween.stop();
addChild (flecha2);
var t1:Timer=new Timer(1000,1);
t1.addEventListener(TimerEvent.TIMER,removeFl);
t1.start();
function removeFl(e:TimerEvent):void{
if (flecha2.parent) {
flecha2.parent.removeChild(flecha2);}
}
} else {
item5.x=276;
item5.y=(stage.stageHeight - 100);
}
}
and what I want to do is: before the "myTween.stop();" I want it to check if i.x=273, letrao.x=447, and letral.x=575,50
Thanks once again for all your help
To check all three in one conditional you would use:
if(i.x == 273 && letrao.x == 447 && letral.x == 575){
Two other things...
1) you should not nest named functions within other functions
2) Within that function that you are nesting, you are testing if an object has a parent using...
if (flecha2.parent) {
IF fletcha2 is an object in the timeline such that you can target it that way, that timeline is the parent, so there is no need to test for its parent, nor do you need to target its par
...Copy link to clipboard
Copied
To check all three in one conditional you would use:
if(i.x == 273 && letrao.x == 447 && letral.x == 575){
Two other things...
1) you should not nest named functions within other functions
2) Within that function that you are nesting, you are testing if an object has a parent using...
if (flecha2.parent) {
IF fletcha2 is an object in the timeline such that you can target it that way, that timeline is the parent, so there is no need to test for its parent, nor do you need to target its parent to remove it. YOu can just target fletcha2 directly to test for its existence and to remove it.
Copy link to clipboard
Copied
Great!!!!
I did as you said and it is working fine.
Let me ask you, to better understand:
1) Why should not I put one function inside another?
2) Before I asked here, I tried to define that if myself, but writing one = instead of two == ... what is the meaning of = and ==?
By the way, thanks a lot!!!!
Copy link to clipboard
Copied
You're welcome
1) The non-technical answer - It can mess up the scope of things, leading to problems that have you scratching your head and going cross-eyed wondering what could be wrong.
2) = assigns a value to whatever precedes it.
== compares the equality of two values
Copy link to clipboard
Copied
Excellent!. Thanks a lot!!!
(as you may see I am still learning )
Find more inspiration, events, and resources on the new Adobe Community
Explore Now