10.10.08
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.
Permalink
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.
Permalink
10.09.08
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
Permalink
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
Permalink
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?
Permalink