hitTestPoint to change direction of moving object

I'm having a problem of changing the direction of a clip using hitTestPoint. I've got some balls on the screen who doesn't move left, right, up and down. and waiting for the way they move they must change direction. If they move right they have to change to a maximum.  left to the bottom right and left. I tried the following code to get a mobile ball right to change to a maximum of travel.

Note: movingDir is just a string that I use to keep track of how the ball is moving and is initially set to another class.

Here is an excerpt of the ball class:

this._movingDir = "right";
this._speedR = 5;
this.x += this._speedR; 

public function hittingRebounder(e:Event):void {
            for(var c:uint = 0; c < Ball.ballsArray.length; c++){
                if(Ball.ballsArray[c].hitTestPoint(this.x, this.y)){
                    if(Ball.ballsArray[c]._movingDir == "right"){
                        trace("right");
                        upMoving.push(Ball.ballsArray[c]);
                        Ball.ballsArray[c].addEventListener(Event.ENTER_FRAME, greenPo****U);
                    }
                    else if(Ball.ballsArray[c]._movingDir == "left"){
                        trace("left");
                    }
                    else if(Ball.ballsArray[c]._movingDir == "up"){
                        trace("up");
                    }
                    else if(Ball.ballsArray[c]._movingDir == "down"){
                        trace("down");
                    }
                }
            }
        }

public function greenPo****U(e:Event):void {
            for(var g:uint = 0; g < upMoving.length; g++){
                
                upMoving[g]._movingDir = "up"
                upMoving[g]._speedR = 0;
                upMoving[g]._speedU = 5;
                upMoving[g].y -= upMoving[g]._speedU;
            }
            
        }

Help would be very appreciated. Thank you.

What I mean is that your ball class will be on each moving balls.  He would boil up to something like the following...

package {}
    
import flash.display.MovieClip;
import flash.events.Event;
    
    
SerializableAttribute public class ball extends MovieClip {}
         
public var _startX:uint;
public var _startY:uint;
public var _movingDir:String;
public var _speedU:uint;
public var _speedR:uint;
         
public void Ball() {}
the constructor code
this.addEventListener (Event.ENTER_FRAME, ballMove);
This ._startX = this.x;
This ._startY = this.y;
}
         
public void ballMove(e:Event):void {}
{if (Start.isStartPressed)}
This.y += this ._speedU;
This.x += this ._speedR;
} else {}
This.x = _startX;
This.y = _startY;
}
}
}
}

The ball class doesn't have a table... it's just a balloon.  The range of balls would be something that is managed by a different process, something which oversees all the balls.  It could be your other package (since it deals with all the balls), or it could be another package.  But here's what I intended as far as the other class goes...

package {}

import flash.events.Event;
import flash.display.MovieClip;
    
SerializableAttribute public class PosRebounder extends MovieClip {}
         
public static var isRebounderHit:Boolean = false;
public static var ballsArray:Array = []; you need to fill in this table
         
public void PosRebounder() {}
the constructor code
this.addEventListener (Event.ENTER_FRAME, hittingRebounderElect);
}
         
public void hittingRebounderElect(e:Event):void {}
           
for (var i: uint = 0; i
If (ballsArray [i] .hitTestPoint (this.x, this.y)) {}
If (ballsArray [i] ._movingDir == "right") {}
._movingDir ballsArray [i] = "rise."
._speedU ballsArray [i] = - 5;
._speedR ballsArray [i] = 0;
} ElseIf (._movingDir Ball.ballsArray [i] == "left") {}
._movingDir ballsArray [i] = "down".
._speedU ballsArray [i] = 5;
._speedR ballsArray [i] = 0;
} ElseIf (._movingDir Ball.ballsArray [i] == "up") {}
ballsArray [i] ._movingDir = 'left ';
._speedU ballsArray [i] = 0;
._speedR ballsArray [i] = - 5;
} ElseIf (._movingDir Ball.ballsArray [i] == "down") {}
._movingDir ballsArray [i] = 'right ';
._speedU ballsArray [i] = 0;
._speedR ballsArray [i] = 5;
}
}
}
}
}
}

The code above is not intended to be plugged in and tested since the balls themselves are not defined in it and the initial positions of them aren't, nor their initial sense.  But that again is something that could be handled by a function of oversees who treats all the balls... maybe another function in the second class, shown above.

Tags: Adobe Animate

Similar Questions

  • moved object and type next to the bottom of preview page do not

    moved object and the type next to the wallpaper preview page cannot see how to change this sitting?

    With no text selected, press w.

  • Cursor changes direction to another language

    I have Hebrew support on my computer.

    When I type an expression of TS instruction, the cursor suddenly changes direction and the rest of the text is displayed in Hebrew (see attachment for example).

    Can someone help me solve this annoying problem?

    Thanks in advance.


  • How to change a property of objects from another VI

    Hi, I run my main vi. I have a preferences.vi window that opens.

    The preferenecs.vi opens with an invoke node.

    the preferences.vi must be able to fill the menu items of a control of the ring who lives in the main.vi

    I normally would you a property node, but as this object is in a another vi how can I communicate with her.

    I realize that a global variable seems to be able to pass values between the object and does not change the behavior of objects.

    Can someone help please!

    Thank you, Alec

    It should look like this.

  • How to change direction to leftToRight topToBottom presentation, if the screen orientation changes from portrait mode to landscape

    Hi, I want to change direction in container of topToBottom to leftToRight so change your screen from portrait to landscape orientation.

    How to do this?

    I'm already using this

    on QML

    attachedObjects:]
    {OrientationHandler}
    onOrientationAboutToChange: {}
    If (direction == UIOrientation.Landscape) {}
    myContainer.layout =... / / to leftToRight
    } else {}
    myContainer.layout =... / / to topToBottom
    }
    }
    }
    ]

    I do not know how to set the new value

    Thank you

    Hello

    Use this code below:

    attachedObjects:]
    {OrientationHandler}
    onOrientationAboutToChange: {}
    If (direction == UIOrientation.Landscape) {}
             myContainer.layout.orientation = LayoutOrientation.LeftToRight / / landscape
    } else {}
             myContainer.layout.orientation = LayoutOrientation.TopToBottom / / portrait
    }
    }
    }
    ]

    Thank you

  • I can´t see more save it button to overwrite the changes directly on an open pdf file. Is there a solution to this?

    Hi, I m a free user update to Acrobat Reader DC, but I can´t more see the Save button to overwrite the changes directly on an open pdf file. I mean, I give myself the option "Save as", but then I have to find the right place to save. In my older version of Acrobat Reader when I pressed the button 'save' the program automatically looked for the folder the document I was working on had been, but now it seems that I have to search the folder manually whenever I want to save a file on my computer. Is there a solution to this?

    If not, I would like to install my old version of Acrobat Reader (I m in doubt between X and XI: I think it was the last one). How can I install my old version without losing changes (comments, for example) I did on my pdf files? Thank you very much.

    Best regards

    The "Save" button becomes available when you make changes to the file. If you come to open a file and make any changes to it (and this isn't a temporary file) then this button is disabled. This is how applications work.

    You can get older versions of the player here: Adobe - Adobe Acrobat Reader DC Distribution

  • I subscribe to ICloud Creative pour a team of 2 people.  I was paying $ 114.95, taxes included. For two months, I pay $ 160,94 USD.  How to find l, subscription I had? can I make the change directly from my account?... .o

    I subscribe to ICloud Creative pour a team of 2 people.  I was paying $ 114.95, taxes included. For two months, I pay $ 160,94 USD.  How to find l, subscription I had? can I make the change directly from my account?... General do I contact Adobe?

    It's probably the passage of the special offer that lasts a full pot of for the price of one.

  • Script to change the presence of objects based on the range of amount

    Hello

    Is it possible to change a presence of objects (a field or a subtitle), from the amount range entered in a numeric field?

    For example:

    -The amount of entered number field is a range between 1 and 49 999, then "Signature subtitle 1" is displayed.

    -The amount of entered number field is a range between 50,000 and 250 000, then 'Signature subtitle 2' is displayed.

    Etc.

    Any advice for this script would be appreciated.

    Thank you!

    Hello

    Try something like this JavaScript in the event of your field digital output (you probably need to change the name of your objects in shape, SignatureSubhead1 and SignatureSubhead2)

    switch (true)
    {
     case this.rawValue >= 1 && this.rawValue <= 49999:
      SignatureSubhead1.presence = "visible";
      SignatureSubhead2.presence = "hidden";
      break;
     case this.rawValue >= 50000 && this.rawValue <= 250000:
      SignatureSubhead1.presence = "hidden";
      SignatureSubhead2.presence = "visible";
      break;
     default:
      SignatureSubhead1.presence = "hidden";
      SignatureSubhead2.presence = "hidden";
    }
    

    Concerning

    Bruce

  • How to change the type of object?

    I have an object type, as shown below:

    Here are the object and its type

    create or replace type test_object1 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );

    create or replace type test_type1 is table of the test_object1;


    Now I want to change the type of object. I want to increase the size of val1 to varchar2 (100).

    Any body could help for the alter script.

    Thank you
    Lavan

    >
    SQL > alter type test_object1 change attribute (varchar2 (100)) val1;
    >
    Which won't work OPs example. Your example does not include the second type of object that depends on the first type.

    You cannot change the underlying type unless you use the CASCADe or INVALIDATE option.
    >
    change the type of test_object1 change attribute (val1 varchar2 (100)) waterfall;
    >
    See the CASCADE clause in the link provided by Osame
    >
    CASCADE clause

    Specify the CASCADE clause if you want to propagate the type change to the tables and dependent types. Oracle database abandons the statement if errors are found in the dependent types or tables, unless you also specify the FORCE.

    If you change the property of the type between FINAL and NON-FINAL, you must specify this clause to convert data in the tables and dependent columns. Please refer to [NOT] FINAL.

  • Deletion of video moving object (use duplicate or Roto brush?)

    Hello

    I had a really hard time trying to remove clips moving objects. I am attempt to disassemble head out of the straighter statue, but could not find an effective way to do... When I use the clone stamp, she keeps track, but I can't seem to blend in realistically, given that the color of the sky goes like pans right claw. I also tried to use a cut-out image of heaven and who followed, but who could not blend as well...

    Screen Shot 2014-02-15 at 12.08.39 PM.png
    If anyone has any suggestions for this problem, I would be very happy. I have this same problem with a few other clips as well.
    Thank you
    G

    So I downloaded your video and took a look. To replace the head in the second figure on the left, I simply moved frame 250, duplicate the layer film, used the Clone Stamp to replace the head by Sky giving lots of filling, value paint paint on all chassis and paint to the entire timeline is extended. I also applied layer > time > Freeze Frame in the clip. Then I wrote before the first slip so that I could use a mask to be cut precisely around the neck. I then added a null value to follow movements in the comp and gave a quick run movement to the images pick up a few points on the second figure of the left who lived below the neck. I ran a path of motion, applied the path of motion for the null value, then related the pre-comp to the null so that it would follow the movement of the camera.

    Took about 10 minutes. Here's a CS6 project file that uses your footage. You need to replace the images in your computer and then it should work.

    You can use the PSD that you created instead of all the paint and motorhomes. IOW, if you replace the demo by the PSD you made to the appropriate image then calls on your mask and related DSP to null, everything should work perfectly.

  • Please help: cannot change the order of objects on the stage by dragging in the timeline

    Hi all, I am using Captivate 5.5 and try to change the order of objects on my stage.

    I searched on the internet and read the FAQ here. I cleaned my cache of projects. My slide number amounts to 61, so not very big.

    I wonder if it is because I have several interactive objects, on the other?

    For all the blocks on this stage, with the exception of the one on the left of the first line, I have a picture of grayout, a slidelet, a click box and a real picture, all stacked together. I need to order them correctly so that they play in the right way. I have the right order for the second block on the first line, but can not change the order for the rest of the objects by dragging in the timeline - it just won't let me hang out.

    Here is the screenshot of my scene and a part of the timeline. Thanks for the tips!

    Screen shot 2011-11-04 at 3.50.22 PM.png

    It turns out that I made a stupid mistake by dragging the names of objects instead of the real thing... Sorry guys.

  • Determine if there is a moved object.

    I would like to know on how to determine if there is a moved object. Is there a way to do this?

    I don't know if you start an another slides on the other object it will stop the moved object.

    Perhaps there is a public service that will interview on this subject?

    Randall

    From what I see in the help documentation, the startDrag method does not return a value when it is running, and the class Sprite is not an event that are associated with him from being dragged, so it is unlikely that a drag status is preserved automatically anywhere.  The second example I provided, which you say you use, should be enough for what you want.

  • Moving object to another post layer changes.

    Muse 2015.2: When I move an object between layers, he changes position and jumps to the top of the page. It happened not in previous versions. How can I avoid this?

    Hi Steve,.

    This bug should be fixed in our latest version of Muse, version 2015.2.1.21. Thanks again for reporting this issue.

    Dana

  • Change the color of a single moving object in video

    Hello, I am using first Pro CC and I would like to know how to change the color of a hat, that a person is wearing in the video from red to blue.while that him away one end of one room to another.  What would be the most effective way to proceed first?  Thank you.

    Hi Techman,

    You need to perform the secondary color correction. See if this video helps you.

    Thank you
    Kevin

  • Change the vertical position positive = UP when moving object? CS6

    When you move an object, you enter a positive value for the vertical position sends objects down. How to reverse this as you enter a positive value will move objects to the TOP? Thank you.

    What of the suggestion in the first post in this thread, Reasoner?

    http://forums.Adobe.com/message/3859580#3859580?TSTART=30#3859580

    It is more work that the help of a script (was related to highlight #4 in the other thread).

    We will have to ask Carlos to make a new script that works in CS6 (and in CS7 CS8 and so on).

    Carlos, what do you think?

Maybe you are looking for

  • Last Podcast not picked up

    I have published two podcats who were picked up fine and who are in the directory of podcast itunes (https://itunes.apple.com/us/podcast/my-big-fat-bloody-mary-podcast/id1116493218 ) but the episode #3 is not added. Other directories, such as Stitche

  • L750-114 satellite see 746 MB only 3 GB HARD drive

    I have a laptop Satellite L750-114 and I bought an external hard drive of 3 GB. The problem is that Windows see only 746MB and I can´t the complete hard disk format. What can I do? Thank you.

  • Can I get digital camera on Equium A200 for editing video or save?

    I use an Equium A200-1V0.I want to put my video holiday on laptop direct to the camera with a wire (think it's called a firewire) Anyone will be able to tell me how I can do this please? Thank you John

  • Parallelism test

    I am creating an application to calibrate DUT, the calibration is OK, now I make some change on my prog to make 2 parallel tests in a Panel. I create two threads where I put the code to test the object to measure. In my 'Start_Function_Callback' call

  • activation.exe error message

    message in the box indicates that the entry point for the mnysl.dll file not found