AI Tutorial – Creating your own Simulated AdServer

21 Mar

Here is a tutorial on how to create and implement your own Simulated Ad Server in AI.

1. In AI, place a HorizontalArrangement at top and drop a button onto it. Make both of them Fill parent for Width.

2. Add a Clock and set the TimerInterval to 5000 millisecond (5 second) or as needed. This could also be changed programmatically using Clock.SetInterval

3. Create n (I have created 5 for my test) number of 320 x 48 images (.jpg) that represent your adds. Use a naming convention for your image names; e.g. ad1.jpg, ad2.jpg, ad3.jpg, … FTP the images in some folder on your server; e.g.

5. In Block Editor, create 2 variables (prevImg and nextImg) and set them to same value. Also, create a function getRandomImage — Click HERE to see blocks that are needed.

6. Update the getRandomImage to get random numbers from 1 to max number of images that you have created.

7. In Screen1.Initialize, blank-out your button text, by setting its text to blank (see image in link above)

8. In Clock1.Timer set button.image to invoke getRandomImage

When app starts, every 5 second, it will invoke the getRandomImage function which will retrieve an ad from server and display it as button image.

For another approach for adding adds into AI, please see this LINK.


Posted by on March 21, 2011 in Uncategorized


8 responses to “AI Tutorial – Creating your own Simulated AdServer

  1. site

    June 3, 2012 at 7:43 pm

    Good Stuff, do you have a twitter profile?

  2. Jeff

    June 17, 2011 at 2:52 pm

    That would be awesome. I would love to be able to include ad mob or similar type advertisements into my apps. I want to make some money but I want to provide apps for free too. By the way, you are a genious.

  3. Robert Ketter

    April 18, 2011 at 7:18 pm

    I am thinking one way to create ad links is to use the filename and use some sort of redirect on the server. If you use a naming convention that is predictable then you can add additional links without breaking.

  4. Gabriel Smith

    March 22, 2011 at 12:47 am

    Thank you very much for this!!

    Very Cool!!

    Do you know of a way to implement ad mob or similar service via AI say call out to the internet and stream back ads…etc?

    • M. Hossein Amerkashi

      March 22, 2011 at 7:46 am

      Via AdMob, no. Using this Simulated AdServer, it streams ads back from Internet, so that you can change Ad on the server, and the new one will be displayed on User Mobile. However, what’s missing is the link that goes with the Ad. I haven’t had time to actually look into that, but am hoping that I will.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: