Kun Janos around Adobe’s <Flex> and <Flash>

about me, my life and my work

Using Locales in Flex

Posted by admin on February 24th, 2010

Locales are used to display localized(in English or Hungarian, French…) information(labels, messages,…) in our Flex application. Localized info can be used for Flex components or our custom components too.

Flex SDK arrives with en_US default locale but we can create our own locales for hu_HU(hungarian), fr_FR(french) or any other language we would like to use in our application.

Assume we would like to have the application in hungarian. We will have to create the framework locales for hungarian and also our custom resource locales in hungarian too.

Create framework locales for hu_HU
First step is to copy the locales from en_US to hu_HU. For this step, we will go to flex sdk bin directory(on my computer it’s located at C:\Program Files\Adobe\Flex Builder 3\sdks\3.5.0.12683\bin\) and will launch the command:
> copylocale en_US hu_HU
This will copy framework locales from en_US to hu_HU. At this point, all locales for hu_HU are in english language, but framework is compiled and can be used.

If we would like to use our hu_HU in hungarian language, then we have to edit the resource files for hu_HU and recompile the framefork swcs.
Our hu_HU resource files are located in the sdk directory(C:\Program Files\Adobe\Flex Builder 3\sdks\ 3.5.0.12683):
\frameworks\projects\airframework\bundles\hu_HU\src
\frameworks\projects\framework\bundles\hu_HU\src\
\frameworks\projects\rpc\bundles\hu_HU\src\
The compiled swc files for hu_HU are located in: frameworks\locale\hu_HU\

After modifying the framework src files for hu_HU, we can recompile the framework swcs using the following commands, launched from the sdk directory(C:\Program Files\Adobe\Flex Builder 3\sdks\3.5.0.12683\):
>bin\compc -locale=hu_HU -source-path+=frameworks/projects/framework/bundles/hu_HU/src -include-resource-bundles=collections,containers,controls,core,effects,formatters,logging,SharedResources,skins,states,styles,utils,validators -output=frameworks/locale/hu_HU/framework_rb.swc

>bin\compc -locale=hu_HU -source-path+=frameworks/projects/airframework/bundles/hu_HU/src -include-resource-bundles=aircontrols -output=frameworks/locale/hu_HU/airframework_rb.swc

>bin\compc -locale=hu_HU -source-path+=frameworks/projects/rpc/bundles/hu_HU/src -include-resource-bundles=messaging,rpc -output=frameworks/locale/hu_HU/rpc_rb.swc

Create custom locales for hu_HU
Create locale\hu_HU directory in our main application. Add new file myResources.properties and add properties like:
GREETING=Udvozollek
Save the file and go to Project properties->Flex Compiler and edit the Additional Compiler Arguments like: -locale=en_US,hu_HU -source-path=../locale/{locale}
Keep in mind, you have to create the framework swcs in hu_HU first.

Add the following code in the MXML:
<mx:Metadata>
[ResourceBundle("myResources")]
</mx:Metadata>
Now we can use the following mxml syntax to get our custom local: <mx:Label text=”{resourceManager.getString(’myResources’, ‘GREETING’)}” fontSize=”48″/>

Posted in Uncategorized | No Comments »

My first experience with ebay and PayPal

Posted by admin on January 19th, 2010

I wanted a laptop since I bought my first desktop in 1998. Never had enough money to buy one, at least not a good one.

Usually I buy everything inside the country I’m living in(Romania), but I knew about ebay and I’m pretty familiar with some of the current payment processors(ECHO, PayPal, Authorize.net) as being a software developer I made several e-commerce solutions where I integrated those payment methods.

In the first place I was looking for a good laptop in Romania. After lot’s and lot’s of research I decided what I would like to buy:
- HP or Dell manufacturer
- Intel Core I7 720QM CPU, 1.6Ghz upto 2.8 Ghz using Intels Turbo Boost
- 17″ LCD with 1440×900 or 1600×900 resolution
- 320 GB or bigger HDD
- 4 GB or more memory, possible DDR3
- HDMI, DVD RW, wireless

Once decided about specs, I started looking for such a laptop in romanian shops. I found a Dell Studio 1747 at 6200 RON (2170 USD). I thought that’s way to mutch, so decided to look for same item on ebay.

Once I got to the ebay page, I found a new HP at a reasonable price (1122$, shipping and insurance included). Looked up sellers ratings, seamed ok so decided to buy that one :)

Created an ebay account, created a paypal account and thought: wow, this is easy.
Well, it’s NOT :( Paypal Romania needs a credit card attached to the paypal account. Trying to attach the card I encountered lots and lots of issues: first, even through Paypal asks for CVV2 code, it doesn’t send it to the bank, so the bank immediately refuse the transaction.
My first attempts to link the card to my account failed. After a few emails back and forth with paypal I went to my bank and disabled CVV2 protection. I also raised the limit on my account, so I can easily pay that item. After a few days I managed to link my card to the paypal account. They made a transaction, I went to the bank, got the paypal code I had to use for confirming my card.

Once my card was confirmed, I signed into ebay and used the “Buy it now” button. My nightmare just stared.
My ebay and paypal accounts were linked together, and because my card is linked with paypal all the payments I made using paypal should be immediately taken from my card.

So, my first attempt of paying the item from ebay resulted in an error, saying:
“Your request could not be processed at this time , Sorry, this page is not available at this time.”
I sad, OK…let’s try again…and again, and again. Contacted ebay support, they sad a lot of blablabla and that I can’t pay yet, because the paypal security system rejects my payment(Paypal easy to use, right?).
Now started emailing paypal. They sad a lot of blablablas and then: our system is refusing the transaction and there is nothing we can do about it…try again later, leave it for 24-48 hours.

I emailed the seller about what’s happening. Tried paying again again and again, without any luck. After 4 days that I confirmed my paypal account I was able to send money to the seller using paypal, but he refunded in 5 minutes, saying that I should pay using the “pay for ebay items” option. Didn’t understand his action, I mean, I sent him over the full amount. Refunding with paypal however has some negative actions associated: they can hold up your money from 1 to 4 weeks before you can see them on your bank account.

Next I tried paying him again, payment didn’t succeeded, as for that day the maximum amount set by my bank was reached. So, my bank refused the payment. Guess what paypal did? Well, they blocked my payments again, saying that their system blablabla and that they can’t do anything.

In the same time, the seller opened an unpaid item case for the purchase. Well, I sent him the money over paypal using money transfer and he refunded. Ok, lets say, I can understand him. He doesn’t know me, doesn’t trust me, he needs some insurance, right?

I tried signing up on http://www.escrow.com/ , the escrow company that ebay recommends, but got the message “Your access to Escrow.com has been denied.“  After contacting them using email, they sad that they don’t provide services to Romanian users. Wow, being born in Romania sucks. Isn’t this discrimination?

Today, I am trying to pay that item again again and again…no success. 5 days have passed since I used the “Buy now” button.

My first experience with Paypal is horrible. Wouldn’t recommend to anyone. The people answering the emails, the lady calling you on support might be nice, but their system is just STUPID. How can they block me, when the card is linked and confirmed?

Here it is  the first of their emails, looks like copy paste, probably they are sending it to many many paypal users, experiencing the issues I did:

We employ complex statistical models to identify patterns of behavior.
This is similar to the way banks and credit card companies identify
patterns of behavior that are out of the ordinary when approving
individual transactions. When our system does not allow a certain funding
source for a transaction, it is merely an indication that the individual
transaction fits a pattern we have observed in the past to have a higher
risk of failure.

Although your credit card has already been confirmed and your account is
perfectly in order, the system has stopped your payment. Unfortunately also
some legitimate transactions may be affected by this security measure and
there is really nothing we can do to force the system.

I would advise you not to make any attempts for the next 48 hours. Then try
again to send your payment, if it keeps being blocked it means that payment
does not meet our security requirements and cannot be done within our
system.”

After this one, many other emails followed. Every mail contained a solution, but none of them really worked. So, now I’m stuck. Would like to pay the item but can’t.

Did I say, that my ebay and paypal accounts are linked? Items bought on ebay are showing up in the paypal account. But I have issues there too. After trying to remove the item, I couldn’t bring it back any more. The paypal system removed it once and for all, didn’t even asked if I’m sure. Tried un-linking and linking the accounts again…Item shows up on ebay but not on paypal any more. I get the message “We did not find any items that require payment at this time.” on paypals “Pay for ebay items” page. It has a nice link, saying refresh page if you feel that an item is missing from the list, but nothing works.

Nightmare didn’t ended yet, I feel that a new post will come soon.

LE.
Today is 22 January 2010, it’s been 9 days since I tried paying the ebay item for the first time using Paypal.  It’s also the day when the “An unpaid item case” period ended.
Since 18 January I couldn’t contact the seller. Also ebay support started giving me the same speech like in the first day. Paypal support stopped responding.
I believe I tried paying over 100 times for that item, but Paypal refused every transaction. I give away the item.

Today I went to a local computer shop and ordered a new laptop from there. It’s not as fancy as the ebay one, but it comes within the same amount of money and should be a pretty good one (it’s an Acer Aspire 7738g-904g100mn lx.pfu02.058, with 4 GB Memory, Core 2 Quad Q9000 CPU, 17″, Windows 7)

Now, the good news is, that the money I sent to the seller using the “send money” paypal option has been refunded to my bank :)
I wonder if the nightmare ends…I heard stories about paypal…they can do anything to me, I mean they have my card information and everything. I think I will go to the bank and will lower the limit that Paypal can get out of my account. Also, there is another auction where I successfully bought an item, once I receive the item I will close/delete my Paypal account immediately. It just doesn’t worth it.

Posted in Other Stuff | 1 Comment »

Micronets is closed…

Posted by admin on January 2nd, 2010

It was a great time working for Micronets, but as so many things in life, everything comes to an end.

OpenText bought Vignette in May 2009 (Micronets-Vidavee was part of Vignette) and they decided(on July 2009) to close the office in Cluj Napoca. Everybody(around 24 people) was layd off by 30 December 2009. This is so sad, we had a great team and cool products.

We received some severance payment from OpenText (that Romanian laws grant us) but nothing more. There were people in the office who received the value of one salary…I was happy to get severance payment for two months.
The really sad part of the story is how OpenText treated us. More on this on a future post.

I learned a lot, I meet wonderful people(in India, US and UK) I made friends at Micronets and I’m sure life will be better without OpenText :)

We just had Christmas and New Year, right now I don’t have big plans, just trying to rest. I’m thinking to take a freelance position for a while.

Posted in <work place related> | 3 Comments »

Home page changes

Posted by admin on September 17th, 2009

I just updated my personal page, it is under http://kun-janos.ro . Lots of stuff changed :)
I’m thinking to add a new design to the current page, but for now it will present me in a very simple way.  I have a short presentation here, an updated CV and Portfolio page and a new Contact page.

Old pictures from my site are gone, CV has been updated.

Several portfolio items removed as they become old or not existing any more on the web. New portfolio items will be added, waiting for some Vignette products to be released.

Posted in <who I am> | No Comments »

Hiding a tab in the Flex TabNavigator component

Posted by admin on June 22nd, 2009

After searching for a lot of time, I found out that tab navigator tabs in the Flex TabNavigator component can be hided easily by using the following lines:

var tabIndex:int = 1;
customTabNabNavigator.getTabAt(tabIndex).visible = false;//hides the tab
customTabNabNavigator.getTabAt(tabIndex).enabled = false; //don't let the user to choose the tab using the keyboard

Posted in Uncategorized | No Comments »

Cloning Arrays and Cutoms Classes in AS3

Posted by admin on June 18th, 2009

Cloning an array using concat will not clone the Objects contained by the array. Cloning with concat and then modifying one of the object will be modified in both arrays because the array contains references to the same object. That’s why we need to do a deep copy of the array, like in the following function.

 
        /**
         * will do a deep copy of the Object
         */
        public static function deepClone(source:Object):*{
            var myBA:ByteArray = new ByteArray();
            myBA.writeObject(source);
            myBA.position = 0;
            return(myBA.readObject());
        }

The above function will clone the Array and all the objects that are contained, however it has a major disadvantage. Custom Objects contained in the cloned array will lose their class definition and array[i] as CustomClassVO will give null. This is hapening because during the deep copy the objects loose their class association. To prevent this, the following line(s) has to be added just before doing the deep copy:

 
import flash.net.registerClassAlias;
 
registerClassAlias("com.client.vo.CustomClassVO", CustomClassVO);

Now, there is a more easy way to handle deep copy without loosing the custom class definition, just add the following line just before your custom class definition

	[RemoteClass] /*this will help cloning the item and retaining class information*/
	public class CustomClassVO{
 
		public var variableName:String = '';
 
		public var variableValue:Object;
 
		public function CustomClassVO(pVariableName:String = '', pVariableValue:Object = null){
			variableName = pVariableName;
			variableValue = pVariableValue;
		}
	}

Noticed the [RemoteClass] ? It does all the job, now copying an array of CustomClassVO’s using the deepClone() is simple.

Posted in <Flash>, <Flex> | No Comments »

My New Digital Camera

Posted by admin on May 25th, 2009

About 5 years ago I bought my first digital camera, it was a HP M305, 3.2 MP, poor video and audio quality. 2 weeks ago the camera started to shut down suddenly. Yes, it was time to get a new digital camera. After thinking, googleing and reading a tons of reviews I choosed a compact digital camera, the Canon Powershot SX1 IS. It has a 10MP CCD sensor, shoots 4 frames per second, can record 320×240, 640×480 and 1920×1080(Full HD) videos with great quality and has a 20X optical zoom.

canon_sx1_is_main2_450pix

I already shot about 400 images and 10 videos, I’m excited about the great quality the camera provides. I think, this camera is one of the best cameras on the market at this time in the compact cameras section.

Posted in <free time> | No Comments »

My name is…

Posted by admin on March 16th, 2009

I just realized, I posted on a few areas but I didn’t introduce myself yet. Yes, computer scientists are human, they forget like everybody else.

My name is Kun Janos Levente, born in 1981 jul 08, living in Cluj Napoca, Romania, Europe.
Here is the link to my homepage and to my Curriculum Vitae,  you can take a look at my latest work(that I’m allowed to publish of course) also you can see a few pictures of me on my Hi5 page.
Of course, nothing is updated, I’m just to busy working on great stuff in the office, sometimes at home too.

Posted in <who I am> | No Comments »

Flex Camp Timisoara

Posted by admin on March 16th, 2009

I’m just back from Adobe Flex Camp Timisoara organized by Adobe Romania http://myadobe.ro/2009/02/19/flex-camp-timisoara-its-a-go/

I went to Timisoara (from Cluj Napoca, 350 km) by train (with Anca(Flash) and Bianca(Flash/Flex) my coworkers, Andrei(Bainca’s husband) and Amalia(my girlfriend)), didn’t sleep for about 48 hours at all, but it all worth it.  The evangelists from Adobe Romania(Mihai Corlan, Miti Pricope and Cornel Creanga) made a really cool presentation, all the stuff they were speaking about I already know from blogs and the adobe labs page http://labs.adobe.com/

I asked the adobe people about bugs (see my post Flex Bugs) and what’s the reason they are not looking at community raised bugs on their Jira. They sad, they are looking, but there are so many community raised bugs, that they can’t take a look at every of them and most of the time they can’t reproduce it.  They also sad, the bugs are prioritized and they are looking first at the bugs that have the bigger impact. We can increase community bugs priority by voting them.

Now that Timisoara Flex Camp is over, I just can’t wait Adobe to come in Cluj Napoca too.

flexcamp1

flexcamp2

Posted in <Flex> | No Comments »

Flex Image Resize Produces Poor Quality Images

Posted by admin on March 9th, 2009

Flash/Flex/AIR produces a poor quality(pixelated) image when you load a larger image and try to re size it in the player to a much smaller size.
I searched the web and found this post http://www.cafesilencio.net/blog/bitmapdata-resize-quality-in-flex-and-air, tried the code but I didn’t see any improvements on the image quality.
It seams that Flash player doesn’t use a bilinear/bicubic interpolation algorithm to resize images, probably that’s why the produced image is so bad.
I came up with a solution, it seams that if you first apply a Blur effect on the image, then resize it, the produced image will appear much nicer. Of course the amount of Blur has to be calculated, otherwise we will end up with a poor quality image…again.
Check out the image before/after my solution, also you can try out the solution here resize1 (don’t forget to check the “Apply Blur” check box to see my re size solution)
Here is the code for resize images using blur.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	creationComplete="applyEffects()">
 
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import mx.core.UIComponent;
 
			[Bindable] private var blurQualityDP:ArrayCollection = new ArrayCollection([{label: 'Low', value: BitmapFilterQuality.LOW}, 
																						{label: 'Medium', value: BitmapFilterQuality.MEDIUM},
																						{label: 'High', value: BitmapFilterQuality.HIGH}
																							]);
 
			public static function getUIComponentBitmapData( target:UIComponent ):BitmapData {
				var bd:BitmapData = new BitmapData( target.width, target.height, true, 0 );
				var m:Matrix = new Matrix();
 
				bd.draw( target, m, null, null, null, true );
				return bd;
			}
 
			private function applyEffects():void {
				var w:int = widthSlider.value;
				var ratio:Number = w / originalImage.width;
				var h:int = originalImage.height * ratio;
 
				if (applyBlur.selected){
					var blurXValue:Number = Math.max(1, originalImage.width / w) * 1.25;
					var blurYValue:Number = Math.max(1, originalImage.height / h) * 1.25;
 
					var blurFilter:BlurFilter = new BlurFilter(blurXValue, blurYValue, int(blurQuality.selectedItem.value));
					originalImage.filters = [blurFilter];
				} else {
					originalImage.filters = [];
 
				}
				var bd:BitmapData = getUIComponentBitmapData(originalImage);
 
 
				var rbd:BitmapData = resizeImageBD(bd, w, h);
				img1.source = new Bitmap(rbd, PixelSnapping.AUTO, true);
			}
 
 
			public static function resizeImageBD( bitmapData:BitmapData, width:Number, height:Number ):BitmapData {
				var newBitmapData:BitmapData	= new BitmapData( width, height, true, 0x000000 );
				var matrix:Matrix				= new Matrix();
				matrix.identity();
				matrix.createBox( width / bitmapData.width, height / bitmapData.height );
				newBitmapData.draw( bitmapData, matrix, null, null, null, true );
				return newBitmapData;
			}
 
		]]>
	</mx:Script>
	<mx:VBox>
 
		<mx:HBox>
			<mx:Label text="Image Width" />
			<mx:HSlider id="widthSlider" 
				value="300" minimum="0" maximum="1600" 
				width="800" 
				change="applyEffects()" liveDragging="true"
				snapInterval="5"
				dataTipPrecision="0"/>
			<mx:CheckBox id="applyBlur" label="Apply Blur" change="applyEffects()"/>
 
			<mx:ComboBox id="blurQuality" dataProvider="{blurQualityDP}" change="applyEffects()"/>
		</mx:HBox>
 
		<mx:Label text="Image Width: {widthSlider.value}" />
 
		<mx:Canvas>
 
			<mx:Image id="originalImage" source="@Embed(source='test7.jpg')"
				x="100" y="100"/>
 
			<mx:Image id="img1" 
				/>
 
		</mx:Canvas>
	</mx:VBox>
 
</mx:Application>

Posted in <Flex> | 2 Comments »