Feb
02
2008
--

godaddy-sql-server-2005-c

godaddy sql server 2005 c

for some odd reason, I woke up at 6:30 this morning on a mission to crack my .Net connection. Perhaps, it had something to do with watching the latest episode of Lost (S4e1) and the classic Quadrophenia last night.

I consider myself a beginner with ASP.NET and SQL Server 2005 but I’ve had some experience mining databases with PHP and MySQL. I’m an expert in Flash actionscript though, and have heard great things about C# being very similar in syntax to AS3. I’ve also worked at 2 large .NET shops (Eloqua and Navantis) working closely with .NET developers on Flash/.NET integrations, and drank too much of their kool-aid. Also, at Push, our lead back-end developer, Mark Aucoin, is quite the .Net pusher.

I’d like to offer a very brief tutorial [pretty much just the configuration scripts which I found extremely hard to find ] about what to do after you’ve setup your SQL Server 2005 database from your Godaddy admin panel — Godaddy provides adequate help about how to do this but seems to be missing this solution or at least I couldn’t find it.

Goal: to create a webservice so that Flash (AS 3) can talk to ASP.NET and SQL Server.

You basically need to create these 2 files:

// web.config
//—————————————————




//————————————————–
// WebService.asmx
//—————————————————
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;

[WebService(Namespace = "http://www.headwinds.net/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService
{

[WebMethod]
public DataSet GetCarbonQuizTable()
{
SqlConnection Con;

string sSQL;
// its recommended that you put your connection string in your web config file but I’ll show you an alternative:
//sConstring=”user id=yourid; password=yourpassword;database=yourdatabase;server=yourserver”;
// ["ConnectionInfo"] <— square brackets — very important
string sConstring = ConfigurationSettings.AppSettings["ConnectionInfo"];
// you can add complex sql here but for this tutorial I’m just going to return the entire table
// once you’ve mastered this you can progress to stored procedures and views
sSQL = “select * from YourTableName”;
Con = new SqlConnection(sConstring);
DataSet ds = new DataSet();
Con.Open();
SqlDataAdapter da = new SqlDataAdapter(sSQL, Con);
da.Fill(ds, “CarbonQuiz”);
return ds;
}
}
//—————————————————

Once you’ve configured these files to match your credentials, you upload both of them to the root of your hosting account. You can test the WebService.asmx by opening it in a browser.

Next, you can see the results in Flash CS3.

//TestWebservice.fla
//—————————————————
import alducente.services.WebService;
import flash.events.*;

var ws:WebService = new WebService();
ws.addEventListener(Event.CONNECT, connected);
ws.connect(“http://www.headwinds.net/WebService.asmx?WSDL”); // enter the path to your webservice here
ws.cacheResults = true;

var initTime:Number;

//Once connected, call an available method on the service named “ResolveIP” with the appropriate parameters
function connected(e:Event):void
{
trace (“CONNECTED!”);
ws.GetCarbonQuizTable(onComplete);

}

//This function is called when there is a response from the sesrvice
function onComplete(serviceRespone:XML):void{
trace(“\nWeb Service Result: “);
var time:Number = getTimer();
trace(“Call duration: “+(time – initTime)+” milliseconds”);
initTime = time;
trace(serviceRespone);
}
//—————————————————

RESOURCES

a decent read
programming C# from O’Reilly

GOFR – Flash AS3 webservice package by Carlo Aducente

I highly recommend the following series especially #8 — big eureka moment for me when it all comes together.
SQL ASP.NET Tutorials

the above are free, you can also get 500 more for $49 from here:
www.learnvisualstudio.net

Get the free Visual Studio Express suite

Godaddy Hosting — enter DIGG and get 10% off

Written by in: Uncategorized |
Feb
01
2008
--

line-physics

line physics 3

A few days ago, I ported Emanuele’s AS2 line rider tutorial to AS3 in about an hour, and then went on to add keyboard control and gave him a grenade launcher — I’m not going to include the source in this post because it was fun to port and don’t want you to miss out. Its amazing how fast one can knock together a Metal Slug prototype these days.

For our game [stay tuned], I needed to change a few things such as moving the terrain and not Manny so that he stays locked to the centre of the screen; giving the illusion that he’s actually moving — this prevents him from sliding off the screen.

I’ve been been experimenting with different collision detection techniques (hitTestPoint, using circles, and even colour getPixel), and found Keith Peter’s book invaluable; especially the relatively simple radius detection (compared to the vector stuff) — great introduction to trig and physics — I wish he was my highschool math teacher. I’ve learned that switching between different techniques can increase performance dramatically.

Written by in: Uncategorized |
Feb
01
2008
--

line physics

line physics 2

A few days ago, I ported Emanuele’s AS2 line rider tutorial to AS3 in about an hour, and then went on to add keyboard control and gave him a grenade launcher — I’m not going to include the source in this post because it was fun to port and don’t want you to miss out. Its amazing how fast one can knock together a Metal Slug prototype these days.

For our game [stay tuned], I needed to change a few things such as moving the terrain and not Manny so that he stays locked to the centre of the screen; giving the illusion that he’s actually moving — this prevents him from sliding off the screen.

I’ve been been experimenting with different collision detection techniques (hitTestPoint, using circles, and even colour getPixel), and found Keith Peter’s book invaluable; especially the relatively simple radius detection (compared to the vector stuff) — great introduction to trig and physics — I wish he was my highschool math teacher. I’ve learned that switching between different techniques can increase performance dramatically.

Written by in: Uncategorized |
Feb
01
2008
4

line physics

line physics

A few days ago, I ported Emanuele’s AS2 line rider tutorial to AS3 in about an hour, and then went on to add keyboard control and gave him a grenade launcher — I’m not going to include the source in this post because it was fun to port and don’t want you to miss out. Its amazing how fast one can knock together a Metal Slug prototype these days.

For our game [stay tuned], I needed to change a few things such as moving the terrain and not Manny so that he stays locked to the centre of the screen; giving the illusion that he’s actually moving — this prevents him from sliding off the screen.

I’ve been been experimenting with different collision detection techniques (hitTestPoint, using circles, and even colour getPixel), and found Keith Peter’s book invaluable; especially the relatively simple radius detection (compared to the vector stuff) — great introduction to trig and physics — I wish he was my highschool math teacher. I’ve learned that switching between different techniques can increase performance dramatically.

Written by in: Uncategorized |

Powered by WordPress | Theme: Siteslike