2

As a little warning, I have never worked with flash before, so I am a complete newbie with it.

I'm trying to build a little flash banner, which somewhere on the banner I want to show a country flag of where the user is located.

I discovered this while googling for a solution: Geolocation in Flash

This uses HTML5 navigator.geolocation.getCurrentPosition and translates into lat, long to later put that on a map.

I think what I'm trying to do is more easily achieved with looking up the IP address of the user and translating that into the country?

I'm sorry I can't post any code of what I've tried because I'm somewhat lost on how to tackle this in Flash.

Any help and pointers in the right direction are appreciated.

Community
  • 1
  • 1
Marius Prollak
  • 368
  • 1
  • 7
  • 22
  • How much control do you have over the pages where this banner is going? Can you write any server-side code for your environment? Whether you're putting this banner on a PHP page vs. pure HTML makes a difference in how you can handle the location logic. – Brian Nov 22 '13 at 18:33

2 Answers2

1

As understood, right now you are trying to use "geolocation" API of html5 to detect the current location, what is the problem in using this?

As far as flash and actionscript (for web) does not have any API to detect the current location, you will have to use any serverside code may be PHP,.NET,etc. This will add an extra call to the serverside code.

Thanks, Dhiraj

powercoder23
  • 1,404
  • 1
  • 13
  • 22
0

You can use a Javascript function to get the location, then look up the country code and use that to determine which image (containing a flag) to display.

The answer to this related question contains a whole bunch of resources explaining every step of the way.

Furthermore, this link explains how to call Javascript functions from Flash.

There is also tons of information on how to load and store images in Flash. You might want to look here and here.

At the end of the day, you just need to start coding. All you really have to do is gluing those snippets together, and it should work just fine. Also, make sure that every single snippet works as expected because else, debugging might become troublesome.

Community
  • 1
  • 1
Domi
  • 22,151
  • 15
  • 92
  • 122