Oct 16 2008

Using Flex Builder and Flash together…

Published by under AS 3.0,Flex

Anyone who has written code using Flex Builder Plugin for Eclipse or just the Flex Builder by itself will agree with me completely that writing code using Flash IDE is not fun anymore. 

 

So when i had to write something in pure AS3 i decided to use FB for writing all the classes and Flash only for compiling the FLA. It is a bit of hassle but the efficient provided by FB far exceeds that hassle. Also in my case the project is integration of Flex and Flash, the pure AS3 swf is going to be loaded into a Flex project so i have to launch the project through FB. 

 

Some tips/suggestions from my experience of using this methodology,

  • For debugging the code in FB you have to select permit debugging check box in the Fla options.
I always run my projects in debug mode, it helps me to see what exceptions are being thrown if any and i love to use break points to debug the code. It has made my life lot easier. So for that flash only swf to connect to flex debugger we need to check this option otherwise it won’t work.
  • Some of the advantage of using FB is lost because the child instances of movieclips have to be declared as movieclips even if they have some class attached to it.
Let me explain this further, lets say in your AS3 document class you have a movieclip with instance name sample which has a class Sample.as attached to it. 

 

 

public var sample:Movieclip; this is how you would declare it or this is another way 

public var sample:Sample; Flash doesn’t like this declaration and it freaked out on me. 

you won’t get any compile errors but when you run the movie it won’t be as you expected. So because of this it has to be a movieclip and therefore the FB autocompletion is not much of use there.

  • Major annoyance is that every time you change the code and have to test out the swf, you have to compile it and then copy paste is into the bin-debug folder of your flex project. Cleaning the project takes long time.
Because of the earlier problem, FB doesn’t compile any classes which are assigned to the movieclips and there any errors are discovered only when you compile the fla. After compilation of the swf, you have to copy it in the bin-debug folder so that the most recent changes are reflected when you run the project.
So far it has been the above things, if i encounter something new then i will add to this post.

No responses yet

Oct 14 2008

Diving Anacapa Island….

Published by under Diving

I had booked this trip way in advance and then i tried canceling it late because of dandiya plans on saturday night but then i ended up not going to dandiya and boarded Spectre for a day of diving on Anacapa Islands.

 

I was planning to drive out early morning so I woke up at like 4.15 am and then got ready for the day of diving ahead. I left the house at about 5.15 and was on the boat at like 6.30. Met up with Amit and then just waited for the dives ahead. 

 

 

 

The conditions were great unlike yesterday when there were 15ft swells and the whole boat was rocking, it is about hr and half to the island. Amit and I buddied up and i was going to lead the dives. 

 

Dive 1: Gold Fish Bowl, Anacapa

 

That is the dive site name, don’t ask me why they choose that name. nope there weren’t any gold fishes at this site to see. The site was on the stern side and at a depth of like 40 ft or so. I was really looking forward to playing with my camera. I decided to dive with 6 lbs of weight on me since i wanted to get an accurate estimate of the weight i need. 

 

We descended along the anchor line on the stern side and then take it from there. The visibility was really good about 25 ft or so and there were so many star fishes to see at the bottom. I have never seen so many different kinds of star fishes, it was nice. I really wanted to find some nudis to take macro shots of and see how it went. I was trying to play with the settings but my glove was preventing me to do so effectively, i tried tightening it around the thumb but it wasn’t that helpful. 

 

The screen of my camera also was being shut after 30 secs to preserve battery and it was kinda annoying, i decided to switch the power saving feature off for the next dive and my battery ran out at the end of dive two :D. Well to be fair it wasn’t a new battery so i am going to use a freshly charged one the next time. 

 

We explored a bit and i came across a few spanish shawls as well but nothing too exciting initially but a seal zoomed past by us which was cool. I was more than happy to see all the different varieties of star fish and also the anemones were colorful and plenty. 

 

We were about 45 mins into our dive and then we decided to surface, making a safety stop at 15 ft was really hard for me because of the less weight, there was hardly any air in my BCD to remove, i tried to stay at 15ft but it was tough and then after a while i decided to surface, since our max depth was only like 37 ft.

 

Surprisingly even though the water was only 62F i was cold by the end of the dive not that much but still enough cold that it was necessary for me to get rid of wetsuit and warm up on deck.

 

Dive 1 Details:

Max Depth: 37 ft.

Time: 49 mins

Air Consumption: 1653 psi

Min/Max Temp: 16.8 – 18 Celcius

 

Some bit this fella.

 

Seal

 

 

Dive 2: Canyons, Anacapa

 

We moved to the south side of the islands, in my past two trips on this boat we always moved to Santa Cruz but not this time. We were going to stay near anacapa all the time. This site had some currents and minor swells as well so it was going to be an interesting dive.

 

We decided to descend along the anchor line and then swim in opposite direction of the current so that on the way back we would be along with the current. We dropped to about 30 ft and then started swimming against the current, also we were told that there were chances of some rays being there in sand so i was near the sandy area and decided not to get into the thick kelp and explore the reef.

 

It was really fun with the mild current and the swell pushing us around little and as we were moving along the edges of the reef there were couple of huge lobsters and also a huge dead one, sad. We didn’t catch sight of any rays along the sand, after about 7 mins (yes i was keeping watch on my time since i didn’t want to get lost with currents even though it was mild) into the dive i decided to head out into the reefs and the thick kelp.

 

At about 15ft we could feel the swell moving us around and i really enjoyed that and the kelp was really dense. Passing through it in those conditions was little tough and tiring as well, we explored the reefs for a while but it was getting too much for me so i decided to head out for the sandy bottom and we didn’t go into the thick kelp after that.

 

As we were heading in the opposite direction, i figured that we were going too far so i decided to head back, we also came across a few lobster pots and stuff and the usual anemones etc. Since i had turned off the power save option in my camera, the battery ran out but i wasn’t complaining since i had taken few good pictures. The sea lions came out to play in the next dive but i wasn’t that bummed about not taking their pictures.

 

Doing the safety stop was little better for me this time as i was prepared and was swimming hard to keep myself at the right depth, it was nice to be upside down and look at the school of fishes swimming and the sun shining above them. We surfaced not too far from the boat and I was really tired at the end of this dive.

 

Dive 2 Details:

Max Depth: 37 ft.

Time: 50 mins

Air Consumption: 1775 psi

Min/Max Temp: 16.4 – 17.6 Celcius

 

Anemone

 

Spanish Shawl

 

Star Fish

Lunch was served as we headed out to the next dive site and when we reached the dive site there were sea lions coming out, so it was certainly going to be a fun dive.


 

Dive 3: Underwater Arches.

 

Before the dive Amit told me that he was feeling tired and we might have to end the dive early, i was totally fine with it since i was tired myself and my legs were not happy. I was excited by the sea lions and didn’t want to sit out this dive at all and this site had an underwater arch which is always cool to explore.

 

The dive plan was same, descend along the anchor line, find the arch and then explore around it. We dropped down and as we were swimming along the arch there were sea lions. Those things are one of the most graceful creatures that you will see underwater, their movement is so smooth. They approached us once in a while and then swam past by, they were in mood of their own.

 

We came towards the arch and then swam underneath it, I saw quite a few spanish shawls out there. During the entire dive i must have seen at-least 8 of them. We swam along the edge of the reef structure and there were few big schools of fishes on the reef, amit pointed out that to me. I didn’t want to go there since it was probably at 10ft depth and i wasn’t in mood to struggle to stay buoyant at that depth.

 

We were just swimming along the archway and once in a while a sea lion would swim at us, i tried acting stupid in effort to interest him but he wasn’t amused. They were in their own world and didn’t bother to interact with us. Also tried to get fishes interested in my flashlight but the sun was out and my light wasn’t doing that much. After swimming around the archway and 40 mins into the dive i was getting tired so with about 700 psi left in my tank we decided to surface. Safety stop was relatively easy as compared to other dives and this time we surfaced right near the boat mainly because the structure was easy to navigate.

 

Dive 3 Details:

Max Depth: 33 ft.

Time: 45 mins

Air Consumption: 1413 psi

Min/Max Temp: 16 – 20 Celcius

 

I was really tired at the end of this dive, my legs were just killing me so i decided to call it a day and not do the final dive. I got into the hot tub, showered up, packed my stuff, immediately went downstairs and found myself a bunk. I slept the entire way back and woke up when we were near the dock. We reached the dock at about 5 pm which was kinda early, i didn’t expect us to be back so soon.

 

I reached my place at about 6.30pm, on my way picked up food from california vegan and finally after washing my gear etc, hogging all the food i dozed off at 11ish. It was a tiring day of diving and was fun as well. :)

3 responses so far

Oct 06 2008

Hiking Runyon Canyon

Published by under Hiking

After night of drinking on Friday, I woke up late on sat and i headed out for groceries. The weather was simply amazing, overcast skies, cool breeze with no rain. After the hot week that we had it was really nice to have this sort of change in weather and i felt like going for a hike.

 

It was about 1.30 pm by the time i decided that i should take advantage of this weather and go out for a hike. I needed to find a hike which was short and also close by. It had to be either Runyon Canyon or Griffith Park but since i didn’t want to drive i decided on the former. 

 

There is only one hike out there i believe and its a loop which runs across the park. So at about 2.45 pm i got out of my apt and started walking towards the park. I also took my new olympus 1030SW to take some pictures. It felt nice to just walk in this cool weather, after 15 mins or so cutting across the hoard of tourists on hollywood blvd i reached the park entrance. 

 

Its a really easy hike and there is a nice paved road going all the way up, there was another steep trail which went on the ridge in opposite direction but i decided not to venture on that route since it was my first time. So i just continued on this gradual uphill slope, initially the weather was changing there was no breeze and the sun was started to come out but as i was reaching the top it was coming back. 

 

I hiked at a fairly brisk pace and took some pictures as well in the meantime. I reached that bench on the top at about 3.45 or so and it felt really nice to see beautiful views, i could see all the way to santa monica, west wood to my left and the griffith park, hollywood sign to my far right. It was really beautiful and just standing there feeling the breeze with my eyes closed, i felt calm and relaxed. 

 

I decided to take an offbeat path to come down and it didn’t take me that long to reach the park entrance. On my way back i decided to skip the crazy walk past the tourist crowds on Hollywood Blvd and finally i reached my place at around 5ish. It was my first hike (certainly not the last) in Runyon Canyon and i look forward to more hikes in that place.

 
The Views of the City

 

The Hollywood Sign

 

The Panorama Shot. Click Image for bigger pic

 

One response so far

Oct 01 2008

Using ChangeWatcher

Published by under Flex


Data binding is one of the best things about Flex, frameworks like Cairngorm rely heavily on data binding. But what if you want to detect a change in variable value and then also do something else. Changewatcher comes in handy during times like those.

 

import mx.binding.utils.ChangeWatcher;

 

This is the class i am talking about, it lets you listen for changes in a variable. Lets say we have a class variable totalItems and we need to detect changes to that variable. This is a simple class.

 

package {

    class Model {
        //i shall leave the constructor to you

        [Bindable]
        public var totalItems:Number;

    }
}

Now to detect changes to this variable, the code would look something like,

import mx.binding.utils.ChangeWatcher;

public var watcherInstance:ChangeWatcher;

[Bindable]
public var model:Model;

public function init():void{

//this is useful if you want to unwatch or stop detecting changes to this variable
//ofcourse init function has to be called
model = new Model();
watcherInstance = ChangeWatcher.watch(model,["totalItems"],itemsChanged);

}

public function itemsChanged(event:PropertyChangeEvent):void{
//this function is called as soon as value of totalItem changes.
//if you want to stop watching this variable.
watcherInstance.unwatch();
}

So you can see that this is very easy way of detecting changes, the only thing to keep in mind is that the variables being watched have to be Bindable. You can also detect changes within chain of classes.

 

For Eg. ChangeWatcher.watch(model,[“shoppingCart”,”totalItems”],itemsChanged); the variable totalItems is inside the class ShoppingCart which is initialized in Model. So your chain of variables can be as long as you want.

 

Other Important thing to note is that the line code after the variable will be executed only after your listener function is called. Its not asynchronous like URLLoader etc.

 

EDIT: 02/20/09 Imp Note:

If you are tracking changes to a number, your changewatcher function will fire only if the number changes. Lets say your variable totalItems is 1 and after performing some calculation its again 1, in this situation your changewatcher won’t fire because the value of variable hasn’t changed. It can cause crazy bugs in your application and i have been bitten by this couple of times now. 

 

The example below shows how you can watch a chain and also how every variable has to be bindable etc.

Click here for the source.

 

 

8 responses so far

Sep 25 2008

Testing for null Objects

Published by under AS 3.0

I am not sure how many Flex/Flash programmers are aware of this fact or also you might call me to be a noob on this point but i discovered this today in AS 3.0, I just use ! to find if the object is null or not and don’t bother testing against another property within that object but sometimes there is no other way around it.

 

Consider the following example,

 

var strObj:Object = "";

//this is standard way of finding if the objects are null or not 

//since the object is initialized there should not be a trace

if (!strObj){ 

    trace("this shouldn't be happening");

}

But the trace statement shows up, it almost seems that Flash is treating this object as null but no if you look at the variable using the debugger the value is not null. So this isn’t the smartest way of checking if the object is null or not specially when you are dealing with strings.

 

Many people recommend doing it differently, like combing it with && for some property check of that object, it would look like this,

var strObj:Object = "";

//this is standard way of finding if the objects are null or not 

//since the object is initialized there should not be a trace

//ofcourse since this is string i am testing for length.

if (!strObj && strObj.length){ 

    trace("this shouldn't be happening");

}

Just something to keep in mind, its not always necessary.
 

2 responses so far

Sep 22 2008

Diving Oil Rigs…

Published by under Diving

This is my favorite dive spot and i try not to miss an opportunity to dive the oil rigs. Of the 45 dives that i have done so far 9 of them have been at the rigs. there are usually not too many fishes to see at the rigs but the other marine life is abundant, mainly anemones, brittle stars, hydroids and other invertebrates. I took my camera with me but it stopped working, I have finally discovered the cause behind this behavior and hope to remedy it or just buy a new camera :D. Sorry folks no pictures on this dive.

 

Woke up at abt 4.45 am and thankfully this time i didn’t wake up to a flat tire :), i reached sea bass at about 6.30 am and the boat was full. There were at least 6 doubles (two tank configuration for diving), three rebreathers and all that technical gear. I thought i was going to be the only one diving in a wetsuit :) but there were others. It is a short ride to the rigs and we were going to dive the farthest called Eureka.

 

A couple of guys were going to do a 4 hour long dive, they were going to dive only to 480 ft, stay there for about 12 mins and then spend rest of the time ascending….its going to be few years, maybe decades before i can even think of going that deep. I buddied up with Alberto rather Dr. Alberto a scientist with JPL. We decided on the dive plan and were not planning to go beyond 110 ft, I couldn’t anyway since i was diving on  32% Nitrox (mixture containing 32% O2 instead of Air which has 21%). 

 

Dive 1:

 

We got into water and the surge wasn’t that bad at all, Alberto and I dove down to 107 ft and we hung there for couple of mins. I forgot to clean my mask and was barely able to see, it wasn’t clear at all. I tried flooding my mask n then clearing it but it didn’t help grrrrr. I started taking pics but then becoz of lack of ability to see i was getting frustrated, my camera also got stuck. I spotted a nudibranch but wasn’t able to take pics. Add to that i was also consuming air pretty fast and it wasn’t a good sign. We ascended making stops and exploring as much as we could and i surfaced with about 200 psi left or maybe less, at this point i was not happy at all. We had to swim little bit and then few mins before we could get to the boat i was completely out of air before we reached it and in the process i must have swallowed quite a bit of sea water, not fun.

 

So it wasn’t a great dive but i learnt some valuable lessons, i could have tried to remove my mask and then wipe it clean underwater but at 100+ feet and 53F water didn’t want to take that chance :). On the bright side the new batteries for the dive light worked great and i used it to full advantage, something i haven’t done before.

 

Dive 1 Details:

Max Depth: 107 ft

Dive Time: 24 mins

Air Consumption: 2200 psi

Max – Min Water Temp: 20.4 – 11.6 C

 

Dive 2:

 

After that not so pleasant experience i decided not to carry my camera and also made sure that i cleaned my mask so that things would be more clear this time :D. This time Alberto decided not to continue with the dive and so i had to buddy up with Glenn and other two guys. Four of us decided to jump into the water as a group.  We were not planning to go beyond 85 ft which was fine since i didn’t want to consume air fast and not get a longer bottom time. 

 

We dropped to about 85 ft and yes i was able to see lot clearer. We explored one side of the rigs and i was using my dive light to find some interesting critters. I also was trying to play with the fishes using my dive light. Saw a lot of big male sheepheads and some of them were about 4-5 ft long.

 

After a while as i was trying to interact with fishes with my dive light, some of them got really interested in it. They did try to bite my dive light a few times thinking it was food, it was fun. I did that for few mins and was so involved in it that i didn’t check my air or depth, but i was at 40 ft and with more than 800 psi left so I was ok. Slowly ascended but for some reason Glenn he didn’t want to stay with the group. I wasn’t too pleased about that fact but i didn’t bother. Three of us surfaced but he was still in water, he didn’t bother to come up with us and we were picked up by the boat. He came up after a few minutes. It was a good dive and it was really fun playing with the fishes. 

 

Dive 2 Details:

Max Depth: 80 ft

Dive Time: 37 mins

Air Consumption: 1975 psi

Max – Min Water Temp: 22.8 – 12 C

 

Dive 3:

 

For the third dive, I didn’t wanna buddy up with Glenn because not only he was distant but also didn’t seem keen on exploring the rigs. luckily he decided to skip this last dive and i buddied up with Mark and Chad. The plan was to dive to 50 ft and then just circle the rigs. I was happy about that. So as planned we dropped to about 50 ft and headed in a different direction as previous dives. It was really cool, on one section of the rigs the anemones all of sudden seem to change colors and they were brownish instead of the usual pink or white. Also saw couple of big star fishes. We spent more time going around the rigs and such so didn’t really play with the fishes this time, but passing between the rig structures is fun as well. 

 

I was the one who was consuming air more rapidly than others and when i was at 500 psi we decided to head up, Mark wasn’t too pleased about it. I could have consumed another 100 before deciding to surface but i wanted to save some air to get to the boat. As soon as i got on the boat after removing my mask i had a bloody discharge from my nose which got me scared but people said it wasn’t anything bad so that got me little settled down.

 

Dive 3 Details:

Max Depth: 56 ft

Dive Time: 35 mins

Air Consumption: 1755 psi

Max – Min Water Temp: 24.8 – 12.8 C

 

One of my favorite things to do while diving the rigs is to stay in water at about 10-15 ft and then just ride the surge. Its fun when you keep on moving up and down along with every new surge of water, i experienced some of it during the first dive thats it. On the surface you have to be really careful to make sure that you don’t hit a steel column above as you rise along with the wave. I am bad with the exact terminology surf, wave or wake not sure what exactly it would be called.

 

We got 3 dives in by 2 pm and we reached the dock by 3 pm, it was cool. Had to attend a house party at Pankaj Uncle’s place in the evening so I was in two minds whether to go home or just change at Romil’s place at USC. I decided the latter, I showered up at Romil’s place to get ready for the party.

 

We stayed at Pankaj Uncle’s place till 4.30 am chit chatting about stuff and then finally after dropping everyone at USC and by the time i got all of my diving gear in tub it was already 5.30, i finally went to bed at about 5.45 am, only 24 something hours after i left for diving :)

One response so far

Sep 05 2008

Using Mapping Services with Flex

Published by under AS 3.0,Flex

For a project i decided to try out the Flex libraries for both Yahoo maps and Google maps as well and they both seem to be pretty cool.

http://developer.yahoo.com/flash/maps/ and http://code.google.com/apis/maps/documentation/flash/

 

After working with examples of both the API’s it was not that difficult to find out which had better features.Lets consider the Visual Aspects first,

 

Speed

When you change the map types, Google emerges the clear winner. you can see it for yourself how fast the maps load. 

 

Zooming

When you zoom in and out, yahoo loads one tile at a time and its not pretty specially while zooming in. Google maps just scales the original image and then when the tiles load it fades out. It could have been better implemented by just waiting for all the tiles to load but they choose not to. Its not 100% clean but still better than yahoo.

 

Dragging

When you drag the map at any level, google maps keeps on repeating the images where as yahoo map just shows one image.It doesn’t matter much but i think its a nice feature to have. 

 

So visually Google is winner but for a Flash developer, Yahoo maps have a lot more to offer.

 

Geocoding

When you geocode something, both work well but the results returned by yahoo provide a lot more information. You can get the state and country information from the city name etc. It is awesome feature which google maps lack and hence for our application we are using yahoo maps.

 

Edit: If you look at the comments, I have been corrected that google does indeed have geocoding features, but i am sorry to say that as of 9th September 2008 the geocoding could use some work. See examples.

 

Search and Traffic

Yahoo maps allows you to get the traffic situation and also perform local search and then display the results on the map. Google map has no such features. 

 

Overlays

Google maps has polygon overlay which yahoo map lacks but then it seems easy to draw everything in yahoo maps using the Flash drawing API’s. 

 

I haven’t looked into changing the look and feel of the buttons etc but it seems to me that both the api’s allow the same. Samples and examples can be found for both, I will be putting one with yahoo maps soon.

 

Examples:

For our application I just wanted the map to move as the region were selected by the city, state and country data. you can check it out here, 

 

Yahoo Maps: Application Source

 

Google Maps: Application Source

 

Please Note: I am using amfphp to get the countries, states (US) and cities data. Also i have edited the keys in the source.

 

If you have both examples open, try to select the country yugoslavia and then see the results. At this point i stopped working on google maps example because it returned everything with yugoslavia. It can be a good thing or a bad thing depending on your application, for me it was bad thing. 

 

So Yahoo which returns me the country works for me, I am using standard city, state and country format to get the geocode results. Yahoo seems to be giving priority in that order.

 

2 responses so far

Aug 29 2008

Ugly nature of Politics

Published by under General

I have never bothered with politics while i was in India, didn’t have any opinion about it and stuff. After i moved here, i thought things would be better out here in terms of politics but i was wrong. By better i mean in terms of scandals, honesty etc.

 

Surprisingly I have followed elections this year very closely, specially the Democratic primary battle between Hillary and Obama. No holds barred, that is the policy when it comes down to politics play to the psyche of the people and win.

 

I just want to list few instances of how politicians backtrack and play to the psyche of general public. Its my personal opinion i could be wrong and few might disagree with me as well.

 

New Hampshire primary, Hillary cried on camera and won it. I personally think it was a very well planned thing and it simply made voters sympathetic towards her specially women. The 3 am ad during Texas primaries was a masterpiece in highlighting Obama’s lack of experience. 

 

I have been a Obama supporter mainly because he is a straightforward guy which he demonstrated during the debates with Hillary. When asked if he would invade Iraq again after pulling out of it just because Al Qaeda had a base, his answer was a firm Yes while Hillary didn’t give a firm answer. During the end of primaries Obama was against the popular move of eliminating the state tax on Gas to lower its price. 

 

Obama, he isn’t all about being honest and straightforward.He has backtracked on some issues as well, he initially said that he would use the public funding system if his republican counterpart agreed to same but he backed out later, I don’t blame him he is raising millions more as compared to Mccain. Its an advantage he doesn’t want to loose as simple as that. Obama was against offshore drilling but then he said after a while that he would reconsider that option. 

 

He made lot of promises rather very grand promises during the Democratic National Convention (DNC) acceptance speech, it would be interesting to see how he keeps those or whether he keeps those if elected. Isn’t that the question we always ask about politicians. 

 

Bill Clinton, I was completely surprised to see how much he praised Obama, during the primaries he didn’t think Obama had enough experience to be a president but at the DNC he was all over Obama. Did he have a divine realization before the DNC that people were having same accusation against him (lack of experience) when he was running for presidency?

 

The best of all is the choice of VP for Mccain, Sarah Palin. She is a mom of 5 and looks gorgeous, i wonder how many men would vote for her only because of that. It is obvious that Mccain camp wants to attract women voters and it was highlighted by the fact that as soon as Sarah got on the stage she appealed to them. It doesn’t matter that she has been a governor only for two years and has lesser experience than Obama, she is going to bring in all those women votes for Mccain. By picking a woman they are playing to the psyche, its an added bonus that she is hot and ultra conservative as well which works for lot of republicans.

 

One of my friends told me, in presidential election you just have to pick the lesser of two evils. I would pick Obama if i could vote in these elections.

 

 

No responses yet

Aug 21 2008

Getting Shipping Rates from USPS

Published by under Flex

I have been working on a Flash/Flex shopping cart which uses AMFPHP to connect with OSCommerce and you can manage your cart using OScommerce. 

 

The client wanted to get shipping prices based on the weight and it had to be USPS. It turned out to be a really easy integration, I have used Flex but it would be the same using Flash as well. 

 

The only problem is when you hit the testing server of USPS they expect the xml to be exactly the same as they specify in the examples and also Rate3 API’s don’t work well. Shown below is the simple Flex code to get response from the testing server,

 

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” creationComplete=”sendService()”>

    <mx:Script>

        <![CDATA[

            import mx.controls.Alert;

            private function errorMsg(info:Object):void{

                var data:Object = info;

            }

            private function gotBack(event:Object):void{

                var data:Object = event;

                mx.controls.Alert.show(event.result.Error.Description);

            }

            private function sendService():void{

                var xmlData:String = ‘<RateV2Request USERID=”xxxxxx”><Package                                                                         ID=”0″><Service>PRIORITY</Service>’ + 

                     ‘<ZipOrigination>10022</ZipOrigination><ZipDestination>20008</ZipDestination>’                                     + ‘<Pounds>10</Pounds><Ounces>5</Ounces><Container>Flat Rate Box</Container><Size>REGULAR</Size></Package></RateV2Request>’;

                var requestObj:Object = new Object();

                requestObj.XML = new XML(xmlData).toXMLString();

                requestObj.API = “RateV2”;

                upsService.request = requestObj;

                upsService.send();

            }

]]>

</mx:Script>

<mx:HTTPService id=”upsService” url=”http://testing.shippingapis.com/ShippingAPITest.dll” result=”gotBack(event)”

  fault=”errorMsg(event)” resultFormat=”e4x” />

</mx:Application>

 

As you can see there is not much to it, you just have to use a simple httpservice and the parameters required is the XML and the API. You can request upto 25 rates and the details can be found on the usps site out here.

 

USPS will return an XML even if there is an error and for production you have to move to a different server but the basic things still remain the same. Now only if they would have a crossdomain.xml on their servers, have put in a request for that but i doubt they would be willing to have it. *sigh*

One response so far

Aug 20 2008

Mixed Day of diving this weekend…..

Published by under Diving

Since i won’t be able to dive the next two weekends i decided to take advantage of the excellent conditions and dive this sunday. I decided to go on Great Escape Charters and i loved what the boat had to offer.

 

I reached the pier at about 6.30 am and was pleasantly surprised to see Andrew on board, Ferris was going to be there too so i didn’t have to bother about dive buddies. I love the facilities on the boat, it has nice seating arrangement on the stern and the galley is spacious too. They have an amazing DVD collection, I won’t hesitate to spend a weekend on this boat, too bad i can’t make it for the labor day weekend trip they have. The boat wasn’t only half full so there was plenty on room to spread out the gear and take things easy. My only complain would be having those mugs for water, for some reason i tend to drink less water if there aren’t any water bottles.

 

I found myself a bunk and tried to take a nap since i was really exhausted from all the laser tag games from the previous night and I also felt not adequately hydrated. Didn’t get too much of sleep so i went on the deck and we saw a huge pod of young dolphins. There must be atleast 50 of them, I tried taking pics, will have to see if got them. 

 

We got out pre-dive briefings as we approached the site and there was this old guy who was without a buddy, i wasn’t too keen on buddying up with him but i did nevertheless. He told me that he was an instructor and it was his first time diving in Calif. I felt little more comfortable diving with this guy but at the end of the dive i was pissed.

 

So since he was the instructor out of respect and he being more experienced i asked him to lead the dive, a big mistake. He got into the water ahead of me and went in an opposite direction of the dive site, i didn’t think too much about it then. We dropped to about 70 ft and kept going deeper, I wasn’t sure why was he going deep since the dive site was in about 30 ft of water and on the opposite side as well. I followed him, didn’t have a choice and we soon reached 110 ft. 

 

After 5 mins into the dive i saw his SPG was leaking air so i swam upto him and pointed it out. He said it was fine and we continued the dive, he briefly headed out in the correct direction and we came across a small reef in about 40 ft of water but then suddenly not sure what struck him he headed of in the wrong direction again. After a while all of sudden he signaled out of air and indicated that he was going to ascend. I expected him to take a safety stop at 15 ft and then after a while hit the surface but as soon as i came to 15ft for my safety stop he was at the surface. 

 

Wow, what reckless diving from an instructor, skipping a safety stop after hitting 110 ft and we were at 100+ feet for a few good minutes as well. I completed my safety stop and then met him at the surface, he said he was fine and he just ran out of air. duh!!!! i pointed out that your spg was leaking so you should have monitored your air and immediately moved to a lower depth instead of loitering more at 100+. We could have also shared air and completed safety stop together but he didn’t bother. 

 

I was super pissed at the end of the dive not only did we missed the dive site but also for some reason my camera won’t work in its case. Also I was completely surprised how that instructor acted, it was completely irresponsible on his part. He didn’t bother to ask about my dive experience or my certification level and went to a depth of 100+ without actually bothering to see how i was doing etc. He acted as if he was on his own during the entire dive, why did he want a buddy in that case?

 

Dive 1 Details: 

Max Depth: 112 ft.

Dive Time: 20 mins.

 

I was glad that he decided not to dive again and his SPG was still broken. I was going to buddy up with Andrew and Ferris for the next two dives, boy i was glad or what. I tried opening my camera up and it just wouldn’t budge, for some reason it didn’t want to take pictures when i put it inside the case. So i gave up on the camera and decided to dive without it, wish i had it one me though.

 

For the second dive we moved to a different spot and I got into the water first, Ferris had some problem with the tank so i had wait almost 15 mins but it was no biggie since i was very comfortable in water and i preferred that instead of getting heated up on the deck. 

 

We dove right next to the reef and were exploring it, the usual critters were there nothing too exciting till i found an eel, It was a big moray and as soon as i come little closer it opened its jaw as if trying to intimidate me. It was more like a yawn to me and it seems that they breathe that way too. That was the highlight of the dive and we just explored kelp a lot more. Ferris was having a good time clicking pictures with her brand new camera. I also found another eel, it was hiding in the rocks. There was also a gang of Garibaldis who were going crazy, they were really fighting it out over something and each of them was big. It was fun watching them slog it out so to say. 

 

Andrew found a lobster and was shining his bright light on that guy, it was interesting to watch the lobster react to it, the lobster was kinda curious and also appeared to be confused at the same time, what is this bright thing. It was cool. We finished the dive soon and it was time for lunch. Had veggie burger which was good and we were going to stay at the same spot for the final dive.

 

Dive 2 Details:

Max Depth: 76 Ft

Dive Time: 43 mins

 

Steve, the divemaster was also diving by himself and when he came aboard he mentioned that there were few Giant Sea Bass  (GSB), I was super excited always have wanted to see these huge monsters and today could be my lucky day. Indeed it was. I told Andrew that we need to find these guy and so we decided to stay at about 50 ft and just outside the kelp. It would be little cold but would be worth it. 

 

We got into the water and hit the bottom where i saw a flounder sitting there, i pointed it out to Ferris since she was the one with camera. After that picture Ferris mistook some other divers for us and we lost her. We looked for her for sometime but couldn’t find her. Me and Andrew continued the dive and as we were hanging by the kelp I saw a couple of GSB, i just caught a brief glimpse, the vis wasn’t that great as well. I wanted to follow them but they were headed in the direction of ocean so i decided against it. We explored the kelp more and I was losing sight of andrew a lot in the kelp, it was like a little game of hide and seek. 

 

After a while as i was hanging near the kelp, I saw another GSB this was going into the kelp so i decided to approach it, It was an awesome experience that thing was huge atleast 4 – 5 feet and seemed like 250 lbs easy. After that experience I also saw a kelp bass which was about 2.5 – 3 feet, never seen those guys get so big as well. Found an eel hiding in the rocks as well after a while and it didn’t seemed to be bothered by our presence. I was at 550 psi and so it was time to end the dive soon.

 

Dive 3 Details:

Max Depth: 71 ft

Dive Time: 47 mins.

 

I packed up my stuff, took a shower and it was time for fudge and ice cream, that thing was good. Also earlier in the day there was some sort of sweet bread called as Monkey bread, it seemed as if it was dipped in honey. I totally digged that stuff, couldn’t stop eating it. As usual I went to the bunk and dozed off on the way back home. 

 

We reached early and i was at home by 6.30 pm. Cleaned my stuff and went to ralphs to get water, soon i passed out after having dinner at Taco Bell. A mixed day of diving but nevertheless was good.

 

Finally after today’s experience and in general the more i dive, more i appreciate how well you have taught me Jeanne, thank you hollywooddivers. Now only if you could improve your website 😉

Mean Eel

That is one mean Eel Eyeballing.

 

State Fish of California, Garibaldi

Pictures Courtesy of Ferris.

No responses yet

« Prev - Next »