Tuesday, December 21, 2010

Flex 3: two way binding with value objects

Today at work I was working with a VO and I didn't want to code an update function to update my VO every time there was a change. I feel like that extra function and calling updateVO all over the place looks sloppy.

What I ended up doing was inside my action script file I created a bindable instance of my VO.

[Bindable]
public var exampleVO:ExampleVO = new ExampleVO();


For the mxml file I ended up doing this.

<mx:binding source="txtFname.text" destination="exampleVO.fname">
<mx:binding source="txtLname.text" destination="exampleVO.lname">
<mx:Vbox>
<mx:Hbox>
<mx:label text="First Name:">
<mx:textinput id="txtFname" text="{exampleVO.fname}">
</mx:Hbox>
<mx:Hbox>
<mx:label text="Last Name:">
<mx:textinput id="txtLname" text="{exampleVO.lname}">
</mx:Hbox>
</mx:Vbox>

I had to be placed bindable tags at the top of page inside of the main tag. I set my bindings right after where I created my remote object.

That is how I did my two data bindings and I'm sure there are some other ways but this was the easiest for me and for what I was working on.

I did try to set the bindings with just AS3 using the BindingUtils.bindProperty() but I couldn't get it to work. I think my problem was that I didn't set it up to go both ways, so I might have to come back to that and try it.

Thursday, December 16, 2010

Flex 3 ObjectUtil.copy()

So the other day at work, I was working with a datagrid whose data provider was an arrayCollection that was holding a list of VO's. What I wanting to do was edit the selected VO in another component.

What I was doing was passing the VO into the component like:
exampleComponent.exampleVO = arrayCollectionExample[dataGrid.selectedIndex];
This was doing what I wanted, set the component VO to the selected VO. Worked great.

Now the problem I ran into was when I updated the VO and an error occurred. Although it wasn't updating in the database, the datagrid was updated. The item was binded I believe.

To corrected this I found this ObjectUtil.copy().
exampleComponent.exampleVO = ObjectUtil.copy(arrayCollectionExample[dataGrid.selectedIndex]) as exampleVO;

It worked for me and there was no more binding to the data grid. :)

Tuesday, December 14, 2010

Ok, I thought I had iHeartradio working

Ok, I thought I had iHeartradio working.

iHeartradio will work more then it did before. It turns out there are more IP address that need to be added to the "Do Not Cache" field inside your squid proxy settings.

Once I find out more those IP addresses, I will post them here for people.


Thanks!

Wednesday, December 8, 2010

Finally got iHeartRadio iphone app to work on home network

Finally got iheartradio to work on my network at home after months of trying.

I currently run pfsense with squid and squidquard packages for blocking network traffic to certain sites. It is very easy to set and manage.

But there was one problem that I ran into...iPhone iHeart Radio app wouldn't work. I couldn't figure out why it would work. At first I thought it was the squidguard blocking it but it turns out it wasn't. It would always work if I turned the squid proxy server off.

Being a noob to pfSense and networking monitoring, I couldn't figure out where to go to find the traffic logs. Finally I stumbled upon an article that says to run this command "tail -f /usr/squid/log/access.log". I SSH'd into my pfsense box and ran that command. When you start that command, get your iPhone and open the iHeart Radio app and try to stream, you will see the log file start filling up with the http requests.

For me that ip that iHeart was trying to use was 209.107.222.167 and the domain was akamaistream.net.

Now the fix once you find the ip address. In the web GUI of pfsense, go to your squid proxy server edit screen (services -> proxy server). On the general tab, there is a section for "Bypass proxy for these destination IPs". In the text field to the right, enter the ip address that you've found. In my case it was 209.107.222.167.

I couldn't find anything on the web about this and since I finally have it working, I wanted to let everyone know.