Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

A question about conditional if

Explorer ,
Aug 02, 2013 Aug 02, 2013

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

TOPICS
ActionScript
733
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 02, 2013 Aug 02, 2013

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

...
Translate
LEGEND ,
Aug 02, 2013 Aug 02, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 02, 2013 Aug 02, 2013

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!!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2013 Aug 03, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 03, 2013 Aug 03, 2013
LATEST

Excellent!. Thanks a lot!!!

(as you may see I am still learning )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines