Author Archives: Harit Kothari - Page 2

Flash Player Cache and loading issues

By programming its not possible to clear out flash player and browser cache at a point of time, that too without user’s knowledge.
This, at times creates problem when a third party component, say SWF is loaded. Generally the URL from where SWF is to be loaded remains constant. So Flash Player often caches for browser’s easy experience.

However, if the third party – remote component if again in turn does some activity over network, it gives randomly wrong results  Generally this happens because the loaded component actually resides in cache, at times.

To overcome this, there is a way, not to clear cache, but to make browser and flash player feel as if you are always loading some new component (say SWF) from new location.
This simple trick is achieved by doing something like….
http://haritkothari.wordpress.com/myNewComp.swf?[firstparam=123&secondparam=456]&randomcount=Math.random()*Math.random()

The randomcount query param has no more significance other than make FP feel its another URL request, which is not cached! The stronger you implement dummy param, the less is probable for FP to cache.

This can be easily be used with loader to load remote component, however only care need to take is the dummy parameter should not be such that is interpreted by remote component, otherwise result may go to any extent!!!

This is also not Flash Player or actionscript specific trick, even banking and few other sites implement this in stronger ways to avoid caching, apart from session id!

Royal vacation @ Rajasthan

This Diwali, I went to Rajasthan with family. Only three, very selected destinations were routed – Kumbhalgarh, Chittorgarh, Bassi

Kumbhalgarh has world’s second largest wall – of 36 kilometers length. Lighting on monuments and wall is major attraction.

Night View of fort

Night View of fort

We were fortunate enough to have a night view with beautiful lights on the place for more than 30 minutes. Usually the place is enlightened for about 15 to 20 minutes only.
The reserved accommodation was simple and clean. Food was not upto suitable taste, of course, not bad at all!

Second day and night was planned to be spent at Chittorgarh – city of forts where a bunch of monuments are surrounded in a campus on mountain peak.
There, we compromised over accommodation but got reasonably acceptable. We were dissatisfied for food, what and wherever we had!
However, an evening tour to the fort was fabulous. On entering the campus, we hired a guide, mainly to have glimpse of monuments and to get proper road directions. The fort campus is so vast that a motorized vehicle is merely needed to visit every monument!
Its history had a general element that the Rajaputs, mostly fought in defensive manner!

Carvings on ceiling of Vijay Stambh

Carvings on ceiling of Vijay Stambh

Vijay Stambh

Vijay Stambh

Almost all monuments have unique carvings. The Vijaya Stambh is really a symbol of such high and unique architectural and structural design.
The light & sound show of 52 minutes was really good to visualize history.

The last day and night was just an experiment, and at end has turned to be most memorable place we visited in this trip.
Bassi is a small town, 25 kilometers away from Chittorgarh, on the highway to Kota. Nothing special, nothing great appeared till we reached to our ‘accomodation’. But anything and everything, appeared thereafter had an essence of royal!
The home of the Chundawats – Bassi fort is a unique symbol of hospitality. Just surfing through Internet, for accommodation inquiries for Kumbhalgarh and Chittorgarh, I came across this name, and fascinated by reviews forced to add one more destination to the vacation trip.
They have their own way to welcome guests. Not just that, the uniqueness differs when number of arriving guests increases! Food – quality, quantity & taste was highly upto our expectation.
The palace has very selected number of so called rooms, decorated with choice, rich of wall paintings. The furniture with ancient style carvings is another feather of royal theme.
Candle light dinner in open space in palace campus itself was a rare experience. If I could increase my vacation by one day, I was in mood to be seated on one of the Jharokhas whole night!
The palace campus has a Kalpavriksha – wish fulfilling divine tree, which has holy values in Hinduism, Buddhism and Jainism. The tree and its fruits have unique characteristics – fruit has life of 3000 years and the tree can survive without water for 2 to 3 years, according to Randheer Singh Chundawat & others.

Ranvijay Singh a.k.a. Shaitan Singh

Ranvijay Singh a.k.a. Shaitan Singh

The prince Chundawat – fondly calling self as Shaitansingh Chundawat is a cute boy. He is naughty enough to attract anyone! He too was expressing his freedom – as is studying in a school of Udaipur. And the time of vacation allowed him to move and enjoy inside big campus of the palace!

Upto our surprise, family members of the royal Chundawats spent enough time with us, talking about activities, little bit of history etc. Not just that, family members as if divided into small batches, attended us twice!
Finally, when a time to leave the wonderful place and royal family came, I realized that we stayed in a heritage hotel, by the last bill; of course, reasonable in amount!

I salute such ‘kingdom’ where ‘king’ is down to earth and good enough to maintain respect of ‘servant’!

Pics of visit are available here.

alpha & rotation issue for textArea with htmlText

I had been playing with this for one of a project requirement.

Description of scenario:

  • Embedded fonts ‘Times New Roman’ both, using default font manager (Batik) as well as AFE
  • The application consists of two text area components
  • For 1st textarea, I am setting text using ‘text’ property and setting font family, size and color using setStyle().
  • For second, I am providing text related information via ‘htmlText’ property.
  • Using a slider I should be able to change alpha value of both textArea components.

Behavioral problems:

  • When I change value using slider, the alpha effect is applied and visible for 1st textarea, but in case of second, alpha value gets applied but text has no visible impact of alpha.
  • When I rotate both textArea components using, 1st gets rotated, but not second. In case of both textareas, I am referring and using embedded font only. (font family ‘TNR’ in example)

I expect both textAreas behave identical.

As far as I know and received primary feedback from a famous flexer guy, my code is right. If I consider this, there is definitely a limitation / bug in flex SDK. Hence I suggested a new task in SDK.

Here is a code I had written to simulate the SDK limitation / bug:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
	<mx:Style>
		@font-face
		{
			src: url('/assets/fonts/times-new-roman.ttf');
			fontFamily: "TNR";
			font-weight:normal;
			font-style:normal;

			advancedAntiAliasing: true;
		}
	</mx:Style>
	<mx:Script>
		<![CDATA[
			import mx.events.SliderEvent;

			private function init():void
			{
				basicTxt.text = "This is a sample text!";
			}

			private function onChange(event:SliderEvent):void
			{
				basicTxt.alpha = event.value;
				htmlTxt.alpha = event.value;
			}

			private function doRotate(event:MouseEvent):void
			{
				basicTxt.rotation = 20;
				htmlTxt.rotation = 20;
			}
		]]>
	</mx:Script>
	<mx:VBox width="100%" height="100%">
		<mx:HBox width="70%" height="50%">
			<mx:TextArea id="basicTxt" width="80%" backgroundColor="blue" fontSize="36" height="100%" fontFamily="TNR"/>
			<mx:TextArea id="htmlTxt" width="80%" backgroundColor="blue" height="100%">
			<mx:htmlText>
					<![CDATA[<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="TNR" SIZE="36" COLOR="#000000" LETTERSPACING="0" KERNING="0">This is a sample text!</FONT></P></TEXTFORMAT>]]>
				</mx:htmlText>
			</mx:TextArea>
		</mx:HBox>
		<mx:HSlider minimum="0" maximum="1" value="1" change="onChange(event)" />
		<mx:Button label="Rotate" click="doRotate(event)" />
	</mx:VBox>
</mx:Application>

I will appreciate if anyone can give some ideas / pointers to work around.

Flex Formatter

Flex Builder 3, an eclipse~ IDE for flex and actionscript based project development lacks few primary code indentation and refactoring functionalities by itself.

Searching for some other technical requirement drove me to Flex Formatter, a third party project on source! Cheers, its BSD license! 🙂

This tool is really small but very essential and useful plugin

Flex Formatter tools

Flex Formatter tools

Many times it happens that code is written in hurry to achieve some short term goal. Either some efforts need to invest to refactor and indent the code, or else go for Flex Formatter.

Built in capability to generate ASDoc is also impressive! However, I suppose, all these features, of flex formatter have been covered with Flash Builder 4.

Fantastic trip to Jambughoda

Before quite some time, I had made a plan to visit Jambughoda, along with cousins for the holidays of 15th and 16th August.

I was not well one day before, so was in confusion about the plan. But everything went almost on track and we were on track to Jambughoda, about 190 Kilometers away from Ahmedabad.

Before checking in to the booked palace hotel, we went to Kadaa, a natural dam. This place is close to our destination and provides good stay. But we came to know about the place late, had no booking!

The destination – Jambughoda, is the palace of the Ranas. Apart from historic values, the hotel turned palace is great place with pleasant atmosphere, greenery all around. Basically, the locality too is a part of forest, so is rich of trees, different species of insects!!

A 10 Kilometers place, Jhand Hanuman appears to be a great attraction to devotees. Of course, the way to reach there is roller coaster journey.

We learnt that we should be familiar with local language, of the place to visit. Asking for direction and stay to local public, we could not fetch proper information, because we were going to stay in Raj Darbar!!

Dining experience at the palace hotel was not at all good, or perhaps we expected something great! Of course, by other opinions from past visitor, I can assume that the cook was under training and was experimenting on us!! 😀
We discovered a near by town, Badoli is a good place to eat around.

Proper trained staff and management at the palace hotel can fetch more fame. However, overall hospitality was good. And, stay in forest can perhaps not be better than this.

Selected pics are here.

Flash Player and Text

It’s been very difficult to achieve WUSIWUG in Flex 3 (Flash Player 9) and InDesign Server, at least for Text viz, font family, font size etc. In other words, a character with Arial font and size 12 in flash player will look differently from other non flash applications like text editors, design tools etc, having the same character specification. Therefore it is difficult to achieve the same output what you see in flash player, with InDesign Server and so in output PDF! Albeit, both are Adobe products!!!

Speaking to Serge Jespers about this he accepted that Flash player is built differently. Also, Anand added that the new Text Layout Framework, available with Flex 4, runs with Flash Player 10 has addressed many such issues. It has many changes as compared to traditional TextArea component available with Flex 3.

However, Text Layout Framework is not 100% compatible with Flex 3.2. It is not possible to embed and use font in Flex 3.2 (or 3.3) with TLF. The release notes from adobe clearly mentions this, considering root level change in embedded font structure. My experiment also failed to show an embedded font with TLF under Flex 3.3.

However, a point communicated by Jespers, that the TLF is made with the help of InDesign team is a ray of hope to go forward WUSIWUG. But is long way to migrate from Flex 3 to Flex 4, waiting for Flex 4 to be mature from its beta release.

Flex application & new fonts

A typical requirement was to provide some means so that anyone can upload / add new font(s) and the same can be used by Flex application. The Flex project should not require recompilation process.

Font, as a TTF or FON file cannot be used unless embedded, but that requires recompilation.

Searching around net gave me a way to solve this gave me a reasonable good solution.

Instead of specifying external styles such as <mx:Style source=”assets/styles/fonts.css”/> I used StyleManager.

Any change in fonts.css requires project recompilation to get the change in effect.

So, I compiled fonts.css using mxmlc fonts.css . This compiled CSS to SWF.

Then I loaded fonts at runtime using StyleManager.loadStyleDeclarations(“fonts.swf”, true, true);

And that’s it….! The font(s) inside fonts.swf can be used and that gives the same effect as embedded.

RIA in a new avtar with Flash Builder 4

Adobe Flash Builder, formerly Flex Builder is already out with beta tag at present. Personally, I dislike the renamed brand as Flash Builder. Already, many have misconception that Flash and Flex are similar! The only common point is that both supports ActionScript (ECMA 335), but so what? Application of both suits are totally different. Of course, the SDK brand remains same, Flex SDK version 4, Gumbo.

It is near to Adobe’s Creative Suite family. In Flash Builder 4, you can work with Flash MovieClip, import designs from Catalyst. So is pointer in that direction.

Data centric features are really attractive, be it data binding or data object like Hibrnate in java, representing data as POJO. But, this is limited to CRUD only. Flex 4 has backward compatibility – with halo components!

Features with newer IDE is welcomed, especially network monitor. This eliminates need of httpfox and such third party browser plug-in!

Overall, Flex 4 seems to be reached to the community expectations! 🙂 Here is something more. Tim Buntel says this.

Adobe Flash Builder, formerly Flex Builder is already out with beta tag at present. Personally, I dislike the renamed brand as Flash Builder. Of course, the SDK brand remains same, Flex SDK version 4, Gumbo.

It is near to Adobe’s Creative Suite family. In Flash Builder 4, you can play with Flash MovieClip, import designs from Catalyst. So is that pointer.

Data centric features are really attractive, be it data binding or data object like in Hibrnate with java, representing data as POJO. But, this is limited to CRUD only. Flex 4 has backward compatibility – with halo components (I am yet not sure about the level)!

Features with newer IDE is welcomed, especially network monitor. This eliminates need of httpfox and such third party browser plug-in!

Overall, Flex 4 seems to be reached to the community expectations! 🙂

Moon Mission

This weekend, Saturday night a sudden power failure in our area stopped many activities, but gave me a chance. Moisture in air drove everybody to go on terrace. Suddenly an idea clicked in my mind to have photography experiment on my dad’s Nikon D60 DSLR camera.

Full moon gave another opportunity. Here are few results….

Once again...

Once again...

Moon with co-star, photo taken with improper settings led to the blur photograph.

Not bad

Not bad

Good photo with co-star far away, but acceptable result and concentration.

I felt this photo best – it has a costar visible, rough surface on moon (no Hubble telescope is used! :p), sharpness is at expectedly best level.

Mission accomplished!

Flex (Flash Player) – DPI and input/output

DPI is often confused with screen resolution. Actually when screen resolution changes (in pixel height x width) the DPI rate is not necessarily changed.

In most cases DPI remains same, unless changed intentionally. In simple language, increasing screen resolution will allow more dots to be displayed on screen, by decreasing distance between each dot. Increasing DPI rate of screen but keeping resolution will increase number of dots per inch; by decreasing dot thickness, and that will eventually result into more dots in whole screen, with unchanged resolution.

When image resolution comes into picture, DPI plays role to consider depth of an Image. More the DPIs, better is the image – depth.
Two similar looking image (at its original size) may have different DPIs. The image with higher DPI rate, if zoomed in, will not get blurred or distorted very easily.

DPI is the somewhat similar concept of mega pixel – the camera term.

This term and its effect came into picture when I started input and output to real wprld from Flex application!
Flex application (or flash player) accepts width, height, x, y or such dimension properties in pixels only. The real world deals with inch, foot, centimeter or any such unit.

So where the game is?

Above simple question puzzles many.
widthInch = widthPixels/DPI is the key!

Say you have image with 500 pixels, width in inch will be 500/DPI. So if DPI is 96, then width is 500/96inches.

In case of flash player, DPI rate is 96.
So if I want to display an image in 2 inches width, I need to set image width to 2*96 pixels. This ignores Image (physical image file) and its DPI rate as I am going to display in flash player, not any image editor.

Also, this bug post is strange upto my knowledge. Flash Player’s DPI seems constant, ignoring screen DPI.

%d bloggers like this: