Check X any Y boundaries for the respective objects.

So, basically you want your object's X value to be be greater than RED's X value and less than BLUE's X value (so it's horizontally between them), and your object's Y value to be less than the max Y value RED/BLUE (whichever has a greater Y, less than that). When it passes the lower Y value then you note that it passed that and wait for it to pass the greater Y value.
To roll your own here will take a little thinking, particularly if the goal posts (the RED/BLUE objects move) and especially if they move independently. If they are always fixed (game of marbles) when checking this stuff then you can first test to see whether they are vertical or horizontal, relative to each other, and have slightly different sets of checks. Presumably you'd need to calculate distance to objects and figure which pairs of objects you might potentially pass through.
Because these are spheres, you either have to track two X values and two Y values (respective straight line edges) or calculate those two values from the coordinates of the sphere's center and it's radius.

I suppose if you can construct two right triangle by drawing a line connecting the spheres and so, then you need only check if if the ball passes either or both of straight lines that comprise the outside of the triangles(i.e. ball X,Y intersected the line)...
As suggested above, some kind of linear algebra would probably simplify this a bit. I forget exactly how to apply it but you're effectively testing intersection with a line inside a certain domain.
If you know the equation of the line that describes the object's current motion (movement/velocity vector?) and the equation of the line between the two objects then the solution to the system of equations (i.e. those two -- two eqns, two unknowns?) there would be the intersection point. If there is any solution inside the domain then you have a potential collision point. You could get the slope of line with the distance between the two points (RED/BLUE sphere centers).
slope = rise/run = (Y2-Y1)/(X2 - X1)
http://en.wikipedia.org/wiki/System_of_linear_equations
^ You need the line in standard form for this
basic example of how to solve them: http://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html
I think you are only dealing with X,Y here so it is line intersections between two lines. Collision is, I guess, there being a solution to the system and your object being at/close to/past the point of intersection