The answer to this question is, it depends on how you read the rules.
In 3.0, you could not flank with a ranged weapon.
In 3.5, the rules text that specifically prohibited this was removed.
In 3.0, you were flanking specifically when you were making a melee attack against an opponent that was threatened by an ally.
SRD said:
If a character is making a melee attack against an opponent, and an ally directly opposite the character is threatening the opponent, the character and the character's ally flank the opponent.
This is an important change in the rules because, all else being equal, it allowed you to be considered flanking outside of your own turn. For instance, consider a feat that appeared in a recent Dragon magazine:
Summary from Dragon 313 said:
Pack Tactics: When you are flanking an opponent, your allies that are not flanking the same opponent receives a +1 bonus to their melee attacks against that opponent. Your flanking allies retain their normal +2 bonus.
In 3.0, a feat similarly worded would be almost useless. During my attack (the only time I'm considered flanking), my allies would gain an attack bonus - which they couldn't benefit from, because, generally speaking, they can't attack during my attack.
Similarly, any ability that said "When an opponent you are flanking does X ..." would be useless - because, when the opponent does X, I'm not usually in the process of making an attack, and therefore am not flanking him, and can't benefit from the feat.
So, how did the definition of flanking change in 3.5? The method for determing wheter or not something was flanking was rewritten as what I call the "line test."
SRD said:
When in doubt about whether two friendly characters flank an opponent in the middle, trace an imaginary line between the two friendly characters’ centers. If the line passes through opposite borders of the opponent’s space (including corners of those borders), then the opponent is flanked.
Notice how, in this section, it says nothing about "in melee," "threatening," etc.
Where are those types of words mentioned?
In the previous section, which talks about when you get a flanking bonus on attack rolls:
SRD said:
When making a melee attack, you get a +2 flanking bonus if your opponent is threatened by a character or creature friendly to you on the opponent’s opposite border or opposite corner.
So, yes, you obviously only get flanking bonuses to attack rolls when making melee attacks.
The question you need to answer is, what defines flanking? Am I flanking only when I get the bonus on my attack roll (in which case you have 3.0 problems)? Or, are you flanking whenever you pass "the line test" (which [likely accidentally] allows ranged flanking)?
I agree that, in all likelyhood, the designers wanted flanking to be a close-combat-only thing. However, try as hard as I can, I can't think of any rules language that specifically limits it to that without, simultaneously, resulting in other undesirable issues.
For instance, f you limit it to "when you are in melee with an opponent," then it means a rogue, with his monk friend appropriately placed, hitting a bar patron in bar brawl can't sneak attack his opponent with a punch - unless his opponent pulls a knife, in which case, the rogue can kidney-punch him.
EDIT: Hyp also brings up an important point. The only person who needs to threaten anyone in order to grant a flanking bonus is your friend - not you.