Using an Embedded Flex Image in Papervision3D

One of the problems had setting up the demo in the previous post was using embedded flex images for materials in the Papervision 3D scene, here is the solution.

Create a variable for with the embedded image and the variable for the material.

[Embed(source="assets/earthmap.jpg")]
public var earthMap:Class;
private var moonMaterial:BitmapMaterial;

Create a new BitmapAsset variable cad cast the image class to it.

var earthAsset:BitmapAsset = new earthMap() as BitmapAsset;

Finally assign the new variable as a material.

earthMaterial = new BitmapMaterial(earthAsset.bitmapData);

Papervision3D

Ok so I have started and the first thing I realised when I looked at the template is that it was doing stuff in 3D so I figured that I probably need to learn how to do that. The template was called Ultra biz papervision 3d flash I figured that Papervision3D is what was doing all the 3D heavy lifting it turns out I was right.

I downloaded the swc and tried to work it out, this is what I managed.


To view the source right click the movie and select view source.

Project Template

A few weeks ago after spending ages trying to make a cross browser Javascript application and ending up with two lots of code one for IE 7 and one for the rest of the browsers, I decided that there must be a better way enter flex. I spent a week doing the flex in a week and then it was time to come up with an project to see how this flex thing really works.

This is where the contest I won came into play I won $100 of templates and got this template so I figured what better way to learn flex that to try and recreate it using flex instead of boring old flex so project template was born, I will update here as I work through it with all source code included.

Out in the Wild

My pet project has just finshed its first test in the wild and from what I can tell things went great. To have a look at the website where you to can ask for information feel free to go to the ultimate iphone and iPod Touch Survey Software for Market Research tool, yeah I know its a long link but i do what I am told.

Excel Reader Writer (excel not required)

Ok as promised here it is a very simple(1 days work) wrapper for reading and writing excel files using 2007 Office System Driver: Data Connectivity Component. Below is an example function that shows what the class library can do. Remember to include a reference to the library in you project.

public void CorichExcel()
{
string file = "C:/excel.xls";

string sheet = "";

try
{
//Gets a liost of sheets from the excel file
string[] sheets = Corich.Excel.ReaderWriter.GetSheets(file);
sheet = sheets[0];
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}

//Check to see if the sheet exist
if (Corich.Excel.ReaderWriter.SheetExists(file, sheet))
{

//gets a list of colums from the first sheet in the excel file
string[] columns = Corich.Excel.ReaderWriter.GetColumns(file, sheet);

//Loads the data in the first excel sheet into a data table
DataTable data = Corich.Excel.ReaderWriter.Read(file);

//Writes the data from the first sheet to a new excel file, currently only writes to xlsb files
Corich.Excel.ReaderWriter.Write("C:\new_file.xlsb", data);

//Writes the data from the first sheet to a new excel file in the temp directory then opens it, currently only writes to xlsb files
Corich.Excel.ReaderWriter.WriteToTemp("new_file.xlsb", data, true);
}

}

You can download the .dll and the source here the code is under the GNU GPL licence it would be nice to point people to my site if you use it.

Excel Sheet Names using ODBC

I recently needed to import data from excel into a c# application after doing some searching I found the 2007 Office System Driver: Data Connectivity Components there is a lot of good info on the net so I quickly got it up and running.

There was only one problem nowhere I looked could I find out how to get the sheet names. I stared putting various stuff into a data grid until I cam up with the code below.

string filename = "your filename";
string connectionString;
connectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};dbq=" + filename + ";fil=excel 12.0;readonly=0;usercommitsync=Yes";

OdbcConnection myConnection = new OdbcConnection(connectionString);

myConnection.Open();
DataTable data = myConnection.GetSchema("Tables");
myConnection.Close();

List sheets = new List();
foreach (DataRow sheet in data.Rows)
{
sheets.Add(sheet["TABLE_NAME"].ToString().Trim('\'').TrimEnd('$'));
}

P.S. I have built a whole static class library to read and write excel sheets I will post it here when I have some time to comment it.

Theme Fail

Most of the time google does things great but once in a while there is a slip and this is a one of them.

I have the ninja them on my game because lets face it Ninja's are cool, anyway I got some spam and opened it and was greeted with a warning the which is all well and good but there is a "learn more" link but it is red on red you can read it oops.