Wednesday, December 30, 2009

Best Buy Remix API - AJAX and JSON

Best Buy has released an API for its product catalog, store finder, and search. There are some other features offered too. The API is nice and simple. It's REST based to keep things easy to understand and offers two formats, XML or JSON. (I need to note this right away. I don't have a public page for viewing since I've slacked on getting my new domain setup.)

Step 1, get yourself an API key.
Step 2, get jQuery.

I used the AJAX option in jQuery. It's easy to setup and you can specify a return type.

Here is the ajax call I setup that grabs page 1 of the results.
Make a call to jquery, I have 1.3.2.
Setup a document.ready function and in there setup your ajax call. specify the type, url, I set the cache to true and the success: option. DataType will either be xml or json. This will match the format you choose in the URL you pass to Remix.

$(document).ready(function(){
$.ajax({
type: "GET",
url: ""http://api.remix.bestbuy.com/v1/products?page=1&apiKey=YOURKEYHERE&format=json&callback=?,
cache: true,
success: function(data) {
alert('test');
},
The simple thing for testing is just put an alert right here. If successful, the alert fires.
dataType: 'json"
)};
)};

Once you have everything working, just put jQuery's version of a "for" loop in. $.each

$.each(data.products, function(i,products) {
your formatting here. here's mine
$('
').html("SKU: " + this.sku).appendTo('#results');
});

Results is my main div that I just add stuff too for testing. You'll want some formatting here.

Sunday, November 22, 2009

Flash CS3/Actionscript 3 Hover ALT TEXT

I needed to create some hover text over my buttons in Actionscript 3. I Google around and couldn't successfully find an AS3 version. I did find a AS1/2 version at kirpa.com. So I ventured out and did a quick write of my own.

First thing you need to know how to do is pass in multiple parameters on an "addEventListener". Then you just need to write a function to accept these parameters.

Here is what I did. I wrote a generic function called, HoverText. It accepts three parameters. The first is a text string, this is what I want the hover to display. The second is the X position of the hover text. The third is the Y position of the hover text.
HoverText(_text:String,capX:Number,capY:Number)

Since I knew the X & Y coordinates of the buttons and the hover text I wanted to pass in, it made the function really simple. I didn't have calculate anything. Just display at the proper spot.

In AS3 I put two MouseEvent eventListeners on each button, a MouseOver, and a MouseOut. All I had to do was create a function on the eventlistener to allow me to pass multiple parameters. This is a bit different than Javascript, but I figured it out.

Here are my two eventListeners for each button:
btn_1.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event) { HoverText("This is my main hover text sentence",713,256);});
btn_1.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event) { HoverText("out",0,0);});

The first one, Mouse Over, I setup to be the display of the hover text. The second one, is my mouse out. So I set this text to be "out". I could have probably done a NULL, but didn't.

Then my function takes the three params and generates a text field.



var captext:TextField;

function HoverText(_text:String,capX:Number,capY:Number):void {
trace(_text + " " + capX + " " + capY);
if (_text == "out") {
trace("out");
removeChild(captext);
}
else {
trace("in");
captext = new TextField();

captext.x = capX;
captext.y = capY;
captext.text = _text;
captext.background = true;
captext.autoSize = TextFieldAutoSize.RIGHT;


addChild(captext);
}

};



So the function has its three parameter pass ins. The first if the message I want to display. The second is the X coordinate. The third is the Y coordinate. You can see that I create a new dynamic textfield called "captext". I set the X and Y to the proper coordinates. Then the text to the string passed in. I turn the background on. Why you ask? If I don't, the background is transparent and the text blends right in. I set the text field to autosize in width and height from the "RIGHT", which means the top right corner of the text field.

I put in an "IF" statement too...if I'm passing in the "out" statement. I want the hover text to disappear so I just do a removeChild on the element I added on the mouse in event.

Friday, September 4, 2009

Roll Out Customer Support

When a product rolls out, there is nothing in the world that can prepare you for the questions coming. You think you have a pretty good handle on the actual questions related to the product. It's the unknown questions that will freak you out and just make you shake you're head and think, WTF. Since our roll out a couple weeks ago, we have encountered a handful of legitimate bugs. The sort of things your try and catch in testing, but somehow make it through to the release. I have had several good learning questions. One thing we asked our users to do is, before you even try to enter something in the system, call me. Then when a user gets an assignment, call me. We did this because, 1. our whole organization is migrating to this system and we'll have new users. 2., it's just a confidence booster for our users to see. Yes it really is that easy to use the new system.

Then we have the resistance to changers. No matter what you do, it's going to suck. I had comments of, "It's a complete failure for us.", "the system doesn't work for me", "I thought this was supposed to be better", "I thought this was supposed to be easier", and my favorite, "I'll ask this question, but I"m going to do what I want anyway."

I and some of the supervisors have handled everything very professionally so far. No name calling or people storming off, we have answered every one's questions politely and when a bug (aka feature) is discovered we put in on our punch list to fix. We've even had to delve into the corporate Active Directory system to fix a few accounts because a few distribution lists were incorrectly setup.

All in all. It's very time consuming and tiring, but so far so good. We are starting to look at phase 1.1 requests outside of bug fixes. Users are excited about that. I think we may have to do some basic computer training after a few of my experiences. One of my users, I swear after you could guarantee the computer was actually plugged into the wall for power, it should have been taken away from the user. It is disturbing to know that some people whose job is to work daily with a computer and process all the business on it. Couldn't turn it on if you asked him/her too, much less do something that required thought.

One general thing I will bring up probably to management is this particular video, Inbox Zero. After helping the couple users who have asked to have some e-mail inbox rules setup, which is legit request in my book. There is nothing easy about it. Our department can use a few trick on how to manage an inbox. It's part art, part science, but very good practice. Till next time when I think I'll start at ground zero with this project and step everyone through start to finish (and my slow death) he he.