11.05.08

Goodbye Micheal Crichton

Posted in Books at 11:13 am by rbezemer

Micheal Crichton Succumbs to Cancer

Wow, very surprised by this news. His books were a favorite of mine in my teenage years. He will be missed. Thanks very much for all the great stories, they were a joy to read with rich imaginary worlds to explore.

10.10.08

ActionScript 3 Photobucket API Basics

Posted in Flex Code at 8:11 pm by rbezemer

So by popular demand, and just because it’s fresh on my mind, I’ve revisited the Photobucket photoflow example. This version of the app goes a step further and uses the full blown ActionScript 3 Photobucket API. This API is actually relatively new and I was actually working on a similar interface to their API when they released theirs. Anyway the API details can be found here:

http://code.google.com/p/photobucketas3lib/

and of course you will need developer keys from Photobucket in order for this to work. Also since Photobucket does not have a crossdomain.xml yet, so you’ll need a local proxy if you want to use the coverflow container. I detailed a very basic one in an earlier post.

What I will do for this example is load a user’s album in Doug McCune’s photoflow container.

The Photobucket API is pretty straightforward to use. The work flow is basically the following:

1) log in to Photobucket with your developer keys

1
2
private var login:Login = new Login();
login.setConsumer(PhotobucketKeys.CONSUMER, PhotobucketKeys.PRIVATE);

2) Query for a user’s album information

1
 var _pbAlbum:Album = PhotobucketService.getInstance().albumFactory(user) as Album;

3) Request all the images from the album

1
 list.dataprovider = _pbAlbum.images;

4) List any sub-albums

1
subAlbums.dataProvider = _pbAlbum.sub_albums;

And that is basically it. There is some weirdness in their API in regards to the way they treat data providers. If you pass their return objects in as the dataprovider attribute to a display object you are fine, but it you want to do any advanced processing of the return values you have to do some work arounds to the way the return data to you. you can see the details in the source code below, but to put it simply they destroy the original dataprovider before they fill it with data so attaching listeners to the data provider does not work the way you expect.

Here’s the finished project. You can view the source here. To use it, enter a Photobucket user name that has public images available (private images will not be displayed) and press enter or click load. The user’s main album will show in the photoflow and all their sub-albums will show in the combobox. Select a sub-album to show it in the photoflow.

It’s pretty basic, but should give you a good starting point to jump into the Photobucket ActionScript API. My code is released under the Creative Commons Attribution license so anyone (personal or corporate) can use or modify it, just give a shout out to me if you do. Have Fun.

Stylesheets and mx_internal

Posted in Flex Code at 10:45 am by rbezemer

To make a long answer short… they don’t work well together.

basically if you want to set a style property on a CSSStyleDeclaration and you have mx_internal declared in your class (i.e. you are overriding a flex sdk component such as a button or list) then you will get weird ambiguous reference warnings like the following:

Id 1000: Ambiguous reference to setStyle

The solution is simple, instead of declaring use namespace mx_internal you just have to scope each of the variables or functions you want access to. i.e. mx_internal::adobe_hidden_variable. After doing this all your CSSStyleDeclarations::setStyle should work, however your code will now look very verbose with all the mx_internals all over the place.

more details can be found here.

10.09.08

Creating a php proxy for flash

Posted in php at 11:16 pm by rbezemer

So I’m planning on updating my photobucket samples, but I wanted a live flash file on my site instead of the crappy static image I had before. Unfortunaly since the coverflow component requires access to the BitmapData to create the reflection, loading any external images will throw an error. Since Photobucket doesn’t have a crossdomain.xml file yet, the best way to do this is with a simple php proxy to trick flash into thinking it was loaded from your own domain.

Since php is one of those languages I use, but not enough to remember the exact syntax I went searching online.The best example of this I could find was here. There were a few things missing from the script but not a lot. The one major thing I added support for was to verify that the request was coming from the same domain (Sorry but I don’t want everyone cutting and pasting my code and flooding my host with proxy requests and I’m sure you wouldn’t want the same either).

Once the proxy is in place usage is simple. in order to load an image from photobucket:
http://yourserver.com/proxy.php?url=http%3A//www.photobucket.com/some/link/to/image/image.jpg

Anyway here is my modified php code for a simple proxy:

proxy_php

Flex - Adding icons to a ToggleButtonBar

Posted in Flex Code at 2:28 pm by rbezemer

This was one annoying problem, I wanted a single icon on each button on my toggle button bar but for the life of me I couldn’t figure out what was going on. I had set the icon property in my buttonStyle in my applications stylesheet, but my icon was nowhere to be found.

Finally after pullling my hair out for a while, a trip to flexexample found me what I was looking for. The ToggleButtonBar (and any navigation component) uses the data provider supplied to it to pull out the icon resources for each button, so the dataprovider was overriding my stylesheet with null.

So easy fix was to just set a icon property on each item in the data provider with the image you are wanting to use.

here is the link to the example on flex examples: Flex Examples

Strength of Canada’s economy

Posted in Canada at 5:45 am by rbezemer

Ok, I know it’s a coding blog for the most part, but I thought this article was a excellent read on why Canada’s economy isn’t going down the drain like everyone elses. To me this is exactly how regulation of the banking industry should take place. For those to lazy to read the article (and I warn you it is fairly long) basically the Canadian governments policy is no we are not going to create money our of thin air for you, if you want to give out more loans you need to raise more capital on your own. This was their policy even when the Liberals we in power going back at least 20 years.

I am probably the furthest thing from an economist, but to me this makes much more sense than the American version which is, what you don’t have enough money well let me make some up for you…

Is it any wonder the deficit of our neighbors to the south is skyrocketing out of control. Which one is the socialist nation again?

09.23.08

9-slice scaling

Posted in Flex Code at 9:29 am by rbezemer

Here is a pretty good write up on using 9-slice scaling in Flex to make sure your resources scale properly when you are skinning controls, it’s pretty easy concept, just hard to find in the flex documentation.

Flex skinning example

09.22.08

Transparent List in Flex

Posted in Flex Code at 10:28 pm by rbezemer

So my client wanted a list that had no layout information, or a List where you could only see the items in the list, no selection colours, no borders, no background, etc… I spent a lot of time racking my brain trying to figure out the best way to do this. Finally out of desperation I looked at the api and a few related blog posts and the answer was simple. Flex provides support for this in the base list class, so just extend the List class and tell it to not draw anything. How simple is that!

here is the code to do it:

package
{
import mx.controls.List;
import mx.controls.listClasses.IListItemRenderer;

public class TransparentList extends List
{
override protected function createChildren():void
{
super.createChildren();

setStyle( “backgroundAlpha”, “0″ );
setStyle( “borderStyle”, “none” );
}

override protected function drawItem( item:IListItemRenderer,
selected:Boolean=false,
highlighted:Boolean=false,
caret:Boolean=false,
transition:Boolean=false):void
{
super.drawItem(item, false, false, caret, transition);
}
}
}

The draw item function allows you to pass a boolean for selected and highlight parameters. very simple and easy fix to what looks at first glance to be a difficult problem. You would think as an old hand at extending the default flash library this would have been the first solution I would have looked at, must be getting lazy in my old age…

09.17.08

Monitoring Memory usage in C++

Posted in C++ at 9:34 pm by rbezemer

Wow it’s been a long time since I posted last. Anyway I found this very indepth article on creating tools to assist in debugging memory usage problems in c++. I’ve always been interested in the behind the scene’s working of memory analysers and this is a great read.

Monitoring Memory Usage - Gamasutra

Now if my other projects ever slow down I might just get a chance to play with some of these things.

06.08.08

Telus is Evil

Posted in evil at 10:24 am by rbezemer

Does this article scare anyone else as much as it scares me? I’ve seen this mentioned for a while, but it really hit home when it’s companies you are used to dealing with in Canada. This subscription based internet site business model goes against the very foundation of what the internet was based on. But I can see how the corporate world loves this idea of how they can partner and sell content to each other.

Remember all you Telus and Bell customers out there are supporting this kind of garbage and every dollar you send them gives them another dollar to push this kind of subscription based internet. This is why Canada needs to support Net Neutrality legislation. Don’t forget your member of parliament is only an e-mail away. Don’t hesitate to contact them concerning your views on any piece of legislation. that’s exactly what they are there for! I know I’ve e-mailed my mp many times over the past few years, I may not have voted for him but he was elected to carry my voice to parliament.

Do you really want the internet to be like cable TV? Just imagine when this is what we are reduced to when signing up for a broadband subscription:

« Previous entries