getPixel to RGB values

This has been driving me nuts…

So, I’m using the BitmapData class and getPixel to retrieve the colour of a pixel. It works fine and returns a number like “16706965”. I’m not sure what kind of value this is? If I place a ‘toString(16)’ on the end of it, I get a HEX value, but sometimes it isnt 6 digits long, sometimes 5 sometimes 4, so I can’t just convert it from HEX to RGB.

I can make this number into a string with 6 digits, but then it doesnt recognise when I try to convert it to RGB

I feel like I’m going about this the wrong way, but I’m unsure which is the right way to go.

Any suggestions?