views:

432

answers:

2

How do I do this? I have a seekbar which I'm retrofitting to resize with the FLVPlayback. Right now it gets the mouseX when you click the seekbar, and divides that by the length of the seekbar in order to know what percentage it should seek to.

My problem is that now that I'm dynamically setting the width of the seek movieclip the width returns the width I set, while the mouse event returns the position as if it was still the original width it has in the library.

How do I get around this problem?

A: 

The MouseEvent object has a stageX and stageY property - you just need to offset those values by the position of the clip and you should be set.

Branden Hall
+1  A: 

Just scale against the original width you had. Say that you've got a 100px wide bar, just go:

var seekTo:Number = seekbar.mouseX / 100;

This will give you the percentage clicked at regardless the current width of the seekbar.

Nice and easy and no funky coord space conversions needed.

grapefrukt
This is basically what I did, but I used the below so I didn't have to know the original width:var pointerX:Number = e.localX;var percent:Number = pointerX * this.seekHit_mc.scaleX / this.seekHit_mc.width;How the hell do I get this to come out formatted? This reads like gibberish.
Joren