Schemaphic Systems Blog

Sharing experiences in Flash, Flex and AIR

Urgent Local Guide – “Find Me A…” – My First Android Application

leave a comment »

Your local travel guide. On visiting a new place, we like to enjoy much with a hassle-free trip. But in case you are in a problem and would like to know where to go for solving it nearby you, this app will try to assist you.

Find Me A… allows you to search for any thing right from doctors, hospitals, police, pharmacy, Banks, ATMs and many others that you might be desperately looking for in the new town.

So why go about asking people when you have Find Me A… with you as your travel necessity assistant and also when the apps is FREE, bingo!.

You may change the radius of search from the settings option; the range for radius selection is 1 to 10 kilometers (1000 – 10000 meters).

You can add the contact to your list, get road direction, call directly and even view details of the location.

Hope it acts as a guide while you are traveling.

Kindly post your reviews after using the apps, it will be my pleasure to address valid problems and work on them to make the apps more usable.

Check out Find Me A… on Google Play! https://play.google.com/store/apps/details?id=com.te.findmea.activities

Find Me A... - A Travel Guide Android Apps

Find Me A… – A Travel Guide Android Apps

Written by Deepanjan Das

May 15, 2012 at 9:15 PM

A Story of an Office-going Ant

with 3 comments

Once upon a time Mr. Ant used to work in an office. Every day, as soon as Ant reached the office, he used to get engaged with work without wasting time. He enjoyed doing so and remained cheerful as always and happy. This in turn lead to good production level.

The CEO, Mr. Lion was surprised to see the dedication of Ant and felt very happy within him. One day he thought, if Mr. Ant by himself can do such good work, he will be excelling more in performance under proper supervision. So the boss appointed Mr. Beetle as supervisor. Beetle was experienced and famous for supervising and had the capability of writing good reports.

Happy with the new opportunity, Beetle immediately introduced the time-sheet and attendance process which was lacking till then. With the increasing number of thought plans, Beetle himself unable to handle, appointed Mr. Spider as his personal secretary, whose work is to take notes from Beetle and organize them in good visual format for reports. Spider was also responsible for managing phone calls for Beetle.

Seeing the Reports, Lion appreciated much and asked Beetle to provide graphical reports on production and trend analysis, which Lion can display in the next Board meeting. Based on the new requirements, Beetle processed an order for purchasing a computer and a laser printer, and appointed Mr. Fly in charge of the IT department.

Meanwhile, Ant, who used to do a lot of work delightfully earlier, now had to spend more time in meetings and paper works. In turn Ant started losing the enthusiasm for work and the cheerfulness he had started to diminish slowly.

Lion looking into the work pressure of Beetle, thought that it would be wise to have a manager to control the whole department where Mr. Ant worked and appointed Mr. Cockroach. Cockroach in his new office was surprised to see the uncomfortable infrastructure in the department and hence ordered purchasing of ergonomic chair for himself and a good carpet for his cabin.

Along with that Cockroach also got his PA from the previous company to his new one and gave emphasis on Budget Control and Strategic Optimization Plan.

Surprisingly the Department in which the Ant worked, no one seemed to enjoy work anymore and where no more cheerful. At this juncture, Cockroach explained to Lion that a Climatic Study has become necessary for improving production.

Based on the analysis Lion found that the production level has gone down in the Ant’s department by considerable amount. So Lion hired a part-time consultant Mr. Owl to provide a solution to the problem.

Mr. Owl is a leading consultant in the world and is famous for providing solutions for increasing production.

Owl took three months to analyze and finally prepared a report of multiple pages broken up into modular sections. In short the analysis stated that the department was over-staffed.

Based on the report, Lion along with Cockroach call on a meeting and took an immediate decision to sack Mr. Ant due to lack in motivation and negative attitude in work.

Written by Deepanjan Das

February 1, 2012 at 1:38 PM

Posted in General

Tagged with

Extract Bitmap from a MovieClip

leave a comment »

A code snippet to extract Bitmap from a MovieClip object:

/**
* This returns a Bitmap representation of an area
* of a DIsplayObject from the application.
*
* @param source the DisplayObject whose Bitmap is to be generated
* @param area the rectangular part of the DisplayObject to be considered
* for image creation. The default value is <code>null</code> which denotes

the whole image.
*
* @return A bitmap representation of the DisplayObject maked by a

Rectangular area
*/
static public function getImage( source:DisplayObject, area:Rectangle = null

):Bitmap
{
var bitmapData:BitmapData;
var matrix:Matrix;

if ( area != null ) {

matrix = new Matrix( 1, 0, 0, 1 , Math.abs( area.x ) ,

Math.abs( area.y ) );

if ( area.width > 0 && area.height > 0 )
bitmapData = new BitmapData( area.width, area.height,

true, 0x0 );
else
bitmapData = new BitmapData( source.width,

source.height, true, 0x0 );
} else {

bitmapData = new BitmapData( source.width , source.height ,

true, 0x0 );
}

bitmapData.draw( source, matrix, null, null, area, true );

var bitmap:Bitmap = new Bitmap( bitmapData );
return bitmap;
}

Written by Deepanjan Das

November 30, 2011 at 12:52 PM

Posted in ActionScript3.0, Flash, Flex

Proportionate scaling of MovieClips

leave a comment »

There have been few instances where I had to resize a MovieClip maintaining the ascpect ratio. And every now and then I had to make temporary codes as was unable to locate where I wrote the last time. So guys I have now shared it here so that I atleast do not get lost:

static public function scaleMaintainAspectRatio( object:DisplayObject, targetWidth:Number, targetHeight:Number ):void
{
var scale:Number = 0;
var objectWidth:Number = object.width;
var objectHeight:Number = object.height;

if( targetWidth == 1 || targetHeight == 1 ){
if( targetWidth == 1 && targetHeight == 1) {
//targetWidth = 1; targetHeight = 1
//do nothing

} else if( targetWidth == 1 ){
//targetWidth = 1; targetHeight > 1
object.height = targetHeight;
scale = objectWidth / objectHeight;
object.width = targetHeight * scale;

} else if( targetHeight == 1 ) {
//targetWidth > 1; targetHeight = 1
object.width = targetWidth;
scale = objectHeight / objectWidth;
object.height = targetWidth * scale;
}

} else {

if( objectHeight > targetHeight || objectWidth > targetWidth){
if( objectWidth > objectHeight ){
scale = targetWidth / objectWidth;
object.width = targetWidth;
object.height = objectHeight * scale;

if( object.height > targetHeight ){
scale = targetHeight / objectHeight;
object.width = objectWidth * scale;
object.height = targetHeight;
}
} else {
scale = targetHeight / objectHeight;
object.width = objectWidth * scale;
object.height = targetHeight;

if( object.width > targetWidth ){
scale = targetWidth / objectWidth;
object.width = targetWidth;
object.height = objectHeight * scale;
}
}
}
}

Written by Deepanjan Das

November 30, 2011 at 12:18 PM

Posted in ActionScript3.0

Global TImer in ActionScript

leave a comment »

With my experience with RIA using actionscript, I have come most applications where multiple timers are required.
As the application grows complex, the more and more timers added does slow up the application performance to lot.

That is where I thought of developing a utility class called GlobalTimer. It is a singleton class and runs only a single timer. So where ever in your application a timer is necessary, just add a timer name to this global timer with other parameters and you are done without hitting the application performance.

This class is a pure actionscript class and hence can be used both for flash, flex and AIR projects.

GlobalTimer.as

package com.te.utilities
{
import flash.events.EventDispatcher;
import flash.events.TimerEvent;
import flash.utils.Dictionary;
import flash.utils.Timer;

public class GlobalTimer extends EventDispatcher
{
public static const EQUALS : String = "equals";
public static const DIFFERENCE_FROM_CURRENT_TIME : String = "differs";
public static const CALL_IN_INTERVALS : String = "intervals";

public static var TIME_INTERVAL : int = 100;
public static var instance : GlobalTimer;

private var timer:Timer;
private var currentDate:Date;
private var currentTime:int;//in milliseconds
private var _running:Boolean = false;

private var timersForCheck:Dictionary;

public function GlobalTimer( enf:SingletonEnforcer )
{
timersForCheck = new Dictionary();

super();
}

public static function getInstance() : GlobalTimer
{
if( instance == null ) instance = new GlobalTimer( new SingletonEnforcer() );
return instance;
}

public function start() : void
{
if( _running )    return;

timer = new Timer( TIME_INTERVAL );
timer.addEventListener(TimerEvent.TIMER, onTimerHandler, false, 0, true );
timer.start();

_running = true;
}

private function onTimerHandler( event:TimerEvent ) : void
{
currentDate = new Date();
currentTime = ( currentDate.getHours() * 60 * 60 ) + ( currentDate.getMinutes() * 60 ) + ( currentDate.getSeconds() );

for each( var prop:* in timersForCheck ){
if( prop != null ){
switch( prop[2] ){
case EQUALS:
if( currentTime == ( prop[0] + prop[1] ) ){
//AUTO UPDATE CHECK
prop[3][ String( prop[4] ) ]();
}
break;

case DIFFERENCE_FROM_CURRENT_TIME:
//IDLE TIME CHECK
if( prop[5] != null ){
prop[3][ String( prop[5] ) ]();
}
if( ( currentTime - prop[0] ) == prop[1] && prop[4] != null ){
prop[3][ String( prop[4] ) ]();
}
break;

default:
//CALL_IN_INTERVALS:
if( ( timer.currentCount - prop[0] ) == prop[1] && prop[5] != null ){
prop[0] = timer.currentCount;
prop[3][ String( prop[5] ) ]();
}
break;
}
}
}
}

public function addTimer( name:String, time:Number, check:String, object:*, functionOnComplete:String=null, functionOnTimer:String=null ) : void
{
//timersForCheck[name] = [   0,      1,    2,     3,            4,                 5        ];
timersForCheck[name] = [ timer.currentCount, time, check, object, functionOnComplete, functionOnTimer ];
}

public function removeTimer( name:String ) : void
{
timersForCheck[name] = null;
}

public function isTimerRunning( name:String ) : Boolean
{
var prop:* = timersForCheck[ name ];
if( prop == null ){
return false;
}
return true;
}

public function getTimerData( name:String ) : Object
{
var prop:* = timersForCheck[ name ];
if( prop == null ){
return null;
}
var data:Object = {};
data.currentTime = ( currentTime - prop[0] );
data.remainingTime = ( prop[1] - data.currentTime );
return data;
}

public function stop() : void
{
if( timer != null ){
timer.stop();
timer.reset();
timer.removeEventListener( TimerEvent.TIMER, onTimerHandler, false );
timer = null;

_running = false;

for each( var prop:* in timersForCheck ){
if( prop != null ){
prop = null;
}
}
timersForCheck = null;
timersForCheck = new Dictionary();
}
}

public function get running() : Boolean
{
return _running;
}

protected function reset():void
{
stop();
}
}
}
internal class SingletonEnforcer{}

In the application use the following code:

//Code to be used in your application
private var globalTimer:GlobalTimer;

globalTimer = GlobalTimer.getInstance();
if( !globalTimer.running ){
globalTimer.start();//starts timer
}

//checks if the timer is already running
if ( !globalTimer.isTimerRunning( "game_timer" ) ) {
globalTimer.addTimer( "game_timer", _asuraThrowWeaponInterval, GlobalTimer.CALL_IN_INTERVALS, this, null, "onIntervalEventHandler" );
}

globalTimer.removeTimer( "game_timer" );//removes/clears the particular timer
globalTimer.stop();//stops all the timers

Written by Deepanjan Das

November 22, 2011 at 1:22 PM

Layout mirroring in Flex4

with 3 comments

Today I came across a strange problem (mostly due to lack of knowledge in LayoutDirection.as).
I had a mx.controls.VideoDisplay component in a class which extends Sprite in Flex4.
Now when I add the videoDisplay to the container, I found that the video did not show up, but the sound was playing in behind, which suggests that the visual elements are not added.
After a long search I found that I was just trying to add a UIComponent to a Sprite which is not at all possible. And I am sure some of the developers like me also faces the same problem for the first time (though a silly mistake).
So I added spark.core.SpriteVisualElement and added the video to it and it started showing.

Now the actual stuff, to my surprise the video was showing flipped. After much pondering over net and studying the UIComponent class I came to know about the LayoutDirection class, by which any UIComponent and IVisualElement can be flipped. A detailed explanation of the same can be found here.

Here is the code snippet I used.

import mx.controls.VideoDisplay;
import mx.events.VideoEvent;
import spark.core.SpriteVisualElement;
import mx.core.LayoutDirection;

var container:SpriteVisualElement = new SpriteVisualElement();
var fPlayer:VideoDisplay = new VideoDisplay();
fPlayer.maintainAspectRatio = true;
fPlayer.width = 600;
fPlayer.height = 400;
fPlayer.layoutDirection = LayoutDirection.LTR;
container.addChild( fPlayer);

Written by Deepanjan Das

March 17, 2011 at 10:30 AM

Posted in ActionScript3.0

2010 in review

leave a comment »

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

This blog was viewed about 5,200 times in 2010.

In 2010, there were 43 new posts!

The busiest day of the year was September 23rd with 94 views. The most popular post that day was Augmented Reality using FLARToolkit – restrict unnecessary model jumping.

Where did they come from?

The top referring sites in 2010 were words.transmote.com, forums.adobe.com, experts-exchange.com, blog.papervision3d.org, and slashingtongue.com.

Some visitors came searching, mostly for flartoolkit+problema camara, flex datechooser skin, flex datechooser, and as2 dispatchevent.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

Augmented Reality using FLARToolkit – restrict unnecessary model jumping July 2010
5 comments

2

Skinning DateChooser in Flex June 2010
2 comments

3

Tips & Tricks for improving AS3.0 performance May 2010

4

Truncate text in TextArea/TextField June 2010
1 comment

5

Quick customize FLVPlayback captioning July 2010
2 comments

Written by Deepanjan Das

March 9, 2011 at 8:32 AM

Posted in General

Follow

Get every new post delivered to your Inbox.