The Space For App Developers

Beyond Plain Old HTML Objects

Adobe LCDS Samples in BlackBerry App World

without comments

Hooray! My Adobe LCDS Samples application was successfully reviewed and accepted in BlackBerry App World! If you have your PlayBook you can install it directly from here.

My experience of publishing to the App World was really straightforward although it took about 8 working days to have my app reviewed and accepted. In advance of that I had to register as a RIM vendor, which took an additional two working days (the good thing is that this registration is free of charge at least for now).

So if you are planning to publish anything to App World be prepared for at least 10 working days for the whole process. I guess this can be a bit annoying for developers, especially those who are used to Android Market instant publishing. I guess with App World the process is more human-centric, so hopefully the end customers receive only high quality and secure apps. With Android Market that may not always be true.

Written by Piotr Walczyszyn

July 20th, 2011 at 3:57 pm

Posted in News

Tagged with , ,

Creating SkinnableContainer skins for Flex mobile apps

with 3 comments

Recently I was looking for an example on how to create a skin that would work with the SkinnableContainer component class in a Flex mobile application. It turned out I couldn’t find any examples available in the wild so I had to dig it out myself. So below is the approach I took, which can also work for others.

The first thing I found out is that there is a SkinnableContainerSkin class in the spark.skins.mobile package that extends MobileSkin class. This is a basic implementation that works out-of-the-box when you use SkinnableContainer in mobile projects. Its only behavior is setting a contentGroup property with a new instance of the Group class and drawing a background rectangle filled with color based on the backgroundColor style.

Now my goal, instead of drawing the background with AS3, was to use a custom FXG file with some rounded corners, simple stroke and gradient. The screenshot below demonstrates what I was looking for:

In order to achieve the example above I extended SkinnableContainerSkin as in the following snippet:

package
{
	import spark.core.SpriteVisualElement;
	import spark.skins.mobile.SkinnableContainerSkin;
 
	public class MySkinnableContainerSkin extends SkinnableContainerSkin
	{
		protected var backgroundClass:Class;
 
		protected var background:SpriteVisualElement;
 
		public function MySkinnableContainerSkin()
		{
			super();
 
			// Here could be a DPI dependent logic, for demo purposes it is not necessary
			backgroundClass = MySkinnableContainerBackground;
		}
 
		override protected function createChildren():void
		{
			// Adding container background
			background = new backgroundClass;
			addChild(background);
 
			// Creating content group instance
			super.createChildren();
		}
 
		override protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
		{
			super.layoutContents(unscaledWidth, unscaledHeight);
 
			// Setting size of background container
			setElementSize(background, unscaledWidth, unscaledHeight);
		}
 
		override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
		{
			// By default SkinnableContainerSkin draws Rect with backgroundColor but this is not
			// required in this case since background is constructed of MySkinnableContainerBackground fxg
		}
	}
}

My FXG file content looked like this:

<?xml version='1.0' encoding='UTF-8'?>
<Graphic xmlns:fc="http://ns.adobe.com/flashcatalyst/2009" xmlns:d="http://ns.adobe.com/fxg/2008/dt" 
		 xmlns="http://ns.adobe.com/fxg/2008" version="2.0"
		 scaleGridLeft="10" scaleGridTop="10" scaleGridRight="90" scaleGridBottom="90">
 
	<Rect radiusX="10" width="100" height="100">
		<fill>
			<LinearGradient rotation="90">
				<GradientEntry alpha="1.0" color="#CCCCCC" ratio="0"/>
				<GradientEntry alpha="1.0" color="#666666" ratio="1"/>
			</LinearGradient>
		</fill>
		<stroke>
			<SolidColorStroke color="#FF0000" weight="2"/>
		</stroke>
	</Rect>
 
</Graphic>

And the way I can use it now in my Flex mobile projects is as follows:

<s:SkinnableContainer left="10" top="10" right="10" bottom="10" skinClass="MySkinnableContainerSkin">
	<s:Label left="10" top="10" right="10" bottom="10">
		<s:text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam eget arcu et nibh vehicula pulvinar sit amet sit amet ligula. Duis a orci at nisi faucibus luctus. Quisque congue vulputate porttitor. Curabitur ac turpis nulla, a malesuada diam. Sed ullamcorper massa ac libero tincidunt vel ultrices odio cursus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce pharetra varius tortor id rutrum. Duis tempor, nisl sit amet scelerisque dignissim, lorem nisl vehicula leo, in auctor dolor turpis at nisl. Quisque bibendum faucibus turpis vitae pulvinar. Sed mollis risus eget turpis molestie laoreet. Aenean metus nulla, vestibulum at egestas quis, aliquet tempus lectus.</s:text>
	</s:Label>
</s:SkinnableContainer>

Written by Piotr Walczyszyn

July 14th, 2011 at 4:03 pm

Posted in Articles,Examples

Tagged with ,

Discover the unknown of Flex 4.5 – MAX session input request

with one comment

During this year’s MAX I will be doing a presentation about things that are very useful but for some reason little known and rarely used in everyday Flex and AS3 development. The name of my session is “Discover the Unknown Flex 4.5”. This session is for you if you wants to learn new Flex/AS3 tips & tricks, check if you really know everything about Flex, and/or share your knowledge with others.

One of my goals is also to let anyone share their own tips & tricks so I’m expecting to initiate a free form discussion during the session. If you will not be attending this year’s MAX, I encourage to send me your input in advance. I will include most interesting proposals in my presentation, of course giving attribution to their authors ;)

You can use this contact form or use comments below to send me your input.

So see you at MAX 2011…

Written by Piotr Walczyszyn

July 13th, 2011 at 5:12 pm

Posted in Events,News

Tagged with , ,

Running LCDS/BlazeDS in the cloud with AWS Elastic Beanstalk

without comments

Very recently I was looking for a simple and affordable solution to host Java-based services for the mobile version of my LCDS Samples application. Unfortunately, with the Java development, life is not as easy as with PHP where you can get affordable hosting that is managed and secured by your hosting provider. The reality is that with Java you usually end up having a VPS or an instance of a dedicated Linux server (of course Windows would work also). This is certainly a very good solution that gives you a lot of flexibility but you have to remember that the tasks of administering and securing your box are usually on your shoulders. Although I have some knowledge of Unix-type systems, to be honest I wouldn’t feel comfortable doing the whole administration on my own.

So after some research and trying out different options I ended up with an AWS Elastic Beanstalk service provided by Amazon (you can see it in action running here). I’m really excited about this service because it provides an instance of Tomcat (both 6.x and 7.x versions are available) hosted and managed on Amazon’s cloud infrastructure. On top of that and out-of-the-box, it provides a load balancer that will automatically launch additional instances if your application encounters the increased load. Also you have full access to your Tomcat logs and you can receive email notifications with the status and health of your running services.  Another important thing is that it is extremely easy to use, especially when you install the AWS Eclipse plugin that can also work well with Eclipse/Flash Builder.

The good thing is that the cost of all this is not really high, the entry level service is just about $35.27 a month, more details about pricing are available here.

Getting started

Follow these steps to get up and running:

  1. Get an account (if  you don’t already have one) with AWS (Amazon Web Services). Once you get an account you can sign up for Elastic Beanstalk via the “Manage Your Account” section.
  2. Configure your IDE environment. By default Flash Builder comes with a standard version of Eclipse that has only the JDT available. I suggest downloading the Eclipse IDE for Java EE Developers and to configure FB with this environment. It will give you additional tools to handle Tomcat instances and Java Web Projects, which you can use when developing for Elastic Beanstalk. Configuring FB with a custom installation of Eclipse is really straightforward. Once you download Eclipse from here and you extract it somewhere to your hard drive, you can go to the folder where you have FB installed and find the Adobe Flash Builder 4.5 Plug-in Utility application located in the utilities folder. In my case it is here “/Applications/Adobe Flash Builder 4.5/utilities/Adobe Flash Builder 4.5 Plug-in Utility.app” but it all depends where you have your FB installation and also on what OS you are on. Run this application and it will guide you with a few simple steps through the whole Flash Builder – Eclipse integration process.
  3. Install the AWS Eclipse plugin. This can be done directly from Eclipse. Just go to the Help -> Install New Software menu and enter the following update site URL: http://aws.amazon.com/eclipse
  4. Create a new AWS Java Web Project. After a successful install of the AWS plugin you will have an option to create new AWS projects. Use the wizard available from the top bar of Eclipse (with an AWS icon on it) to create a New AWS Java Web Project. First you will need to enter a project name, and credentials like Access Key ID and Secret Access Key. These values are generated when you sign up for an AWS account and you can copy them from the Security Credentials section of your AWS account.
    You can select the Basic Java Web Application option (see the screenshot above), this will be enough for the LCDS/BlazeDS scenario. More info about other options is available through this site, with an in-depth video tutorial.
  5. Configure the LCDS/BlazeDS  environment. In order to do that you need to, copy all necessary jars into the WebContent/WEB-INF/lib folder of the newly created project. In my case I used a turnkey installation of LCDS and I just copied jars from the lcds-samples application and also jars from tomcat/lib/activemq4.1.1, tomcat/lib/jotm2.0.10 and tomcat/lib/lcds (this wouldn’t be necessary for BlazeDS but for LCDS it was required to make the DataServices and Messaging work properly). Next you will also need to copy all configuration files from the WEB-INF/flex folder and the web.xml that has all necessary LCDS/BlazeDS servlets/listeners configured. The important thing to note here is that by default the AWS Elastic Beanstalk service enables only port 80 and HTTP channels; in order to enable other ports that could be required for RTMP channels you can modify the AWS EC2 Security group settings (but that is a topic for another blog post and I will not cover it here). Another solution you have is to stick to the default settings and to configure LCDS services to use only HTTP channels; this is actually what I did for my lcds.riaspace.comservice.    One last thing I had to do to make the LCDS function properly was to create a WebContent/META-INF/context.xml file in which I defined the transaction configuration as in the following snippet:
    <?xml version="1.0" encoding="UTF-8"?>
    <Context reloadable="true">
      <Transaction factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
    </Context>
  6. Deploy your application to the cloud. Once you have the configuration completed and all the services built you can deploy your application directly from Eclipse. Just right-click on the project and select the Amazon Web Services -> Deploy to AWS Elastic Beanstalk… option. Another wizard will pop up that will ask you to specify names for your application and environment.Next you will need to select the server type, which would be AWS Elastic Beanstalk for Tomcat 6 (you also have the option to deploy to Tomcat 7 instances).
    At last you will be able to specify the CNAME of your server (you can assign your own domain name in the DNS configuration, that is actually what I used to get the default lcds-samples.elasticbeanstalk.com configured as lcds.riaspace.com). Another valuable option here is to enter your email address, which will receive notifications of any changes to the service’s state and health.

    Now you are ready to click the Finish button and it will start uploading and configuring your application in the cloud. Be aware that this process may take several minutes the first time. Once it is done you will be able to access your services via the following URL: http://yourcname.elasticbeanstalk.com. To redeploy any changes made to your services you just need to follow this last step all over again.

Written by Piotr Walczyszyn

July 11th, 2011 at 2:47 pm

Posted in Articles,Examples

Tagged with , , , , , ,

Ported LCDS Samples in Android Market

with 2 comments

You may remember one of my previous posts about LCDS Messaging on tablet devices, well I went further with porting these demos and this time I brought also: CRM, Inventory Management and Notes to tablets. Not only I ported these but I also published it to Android Market for anyone to give it a try.

The app that has all the demos is called “Adobe LCDS Samples” and is available here (be aware that I applied market filter to restrict it only to tablets, I managed to do this with <supports-screens /> Android specific tag in *-app.xml).

The hosted LCDS Samples service is located here and you may use it to play around with those samples (the service is thanks to Greg Wilson fellow Adobe Evangelist). UPDATE 2011-07-04: I moved the service to AWS Elastic Beanstalk serivce (blog post about will come soon) and it is now hosted here. The one I really like the most is a Dashboard app because it is easy to use and it shows nicely/visually the real-time capabilities of LiveCycle Data Services (LCDS).

Samples source code is available here in GitHub.

Below you can see few screenshots of the application running on my Motorola XOOM:



Written by Piotr Walczyszyn

June 6th, 2011 at 3:21 pm

Posted in Examples

Tagged with , , ,

iOS style buttons in Flex 4.5 mobile applications

with 5 comments

Ever wondered how you can make Flex 4.5 ActionBar buttons look like native buttons on iOS? This is actually very simple to achieve, what you need are just a few lines of CSS code. Checkout the snippet below:

/* CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
 
@media(os-platform:"IOS")
{
	s|ActionBar
	{
		defaultButtonAppearance:beveled;
	}
 
	.backButton
	{
		skinClass:ClassReference("spark.skins.mobile.BeveledBackButtonSkin");
	}
}

As you can see in the code above I also used CSS media queries to have the proper style and skin class applied only when running on iOS devices. Below you can see the end result:

The code that implements the view above is as simple as this:

 
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
		xmlns:s="library://ns.adobe.com/flex/spark" 
		title="iOS buttons">
 
	<s:navigationContent>
		<s:Button label="Back" styleName="backButton"/>
	</s:navigationContent>
 
	<s:actionContent>
		<s:Button label="Button"/>
	</s:actionContent>
 
</s:View>

Written by Piotr Walczyszyn

May 27th, 2011 at 3:29 pm

Posted in Examples

Tagged with , , ,

LCDS Messaging on tablet devices

with 4 comments

Recently I wanted to try the LiveCycle Data Services (LCDS) messaging feature on tablet devices. LCDS is a platform that lets you easily integrate Flash/Flex/AIR RIAs with JEE back ends, giving your applications full real-time capabilities on the web.

In order to run my tests I ported one of the LCDS demo apps that is included in the package to Flex 4.5 and published it to Motorola XOOM (running Android 3.1), BlackBerry PlayBook and the iPad. You can watch the results in the video below.



Written by Piotr Walczyszyn

May 17th, 2011 at 3:10 pm

Posted in Examples,Recording

Tagged with , , ,

OAuth authorization with Flash and Flex apps

with 11 comments

Below you will find links to my two video tutorials about OAuth authorization with Flash and Flex apps:

1) Introduction to OAuth for secure user and application authorization

2) OAuth in Adobe AIR applications built with Flash or Flex

You can also download example code from here.

Written by Piotr Walczyszyn

May 16th, 2011 at 12:03 pm

Posted in Articles,Examples,Recording

Tagged with , , ,

Packaging AIR application for iOS devices with ADT command and ANT script

with 26 comments

As you may know AIR 2.6 SDK was released yesterday. It brings a lot of improvements especially for iOS devices (you can find the release information here). Now if you already have a certificate and provisioning profile from Apple and want to try out your existing code to deploy on an iOS device you can use the following ADT command:

[AIR_SDK_HOME]/bin/adt -package -target ipa-test -provisioning-profile [MOBILE_PROVISION_FILE_PATH] -storetype pkcs12 -keystore [CERTIFICATE_FILE_PATH] ./MyApplication.ipa ./bin-debug/MyApplication-app.xml -C ./bin-debug MyApplication.swf -C ./bin-debug assets

Of course, replace the capitalized blocks with your appropriate paths, and then execute it from the root folder of your AIR application project. It will package the app SWF file and any accompanying assets from the bin-debug folder. Bear in mind that this is not a final build ready to be published to the App Store. In order to do that you want to package a release build from the bin-release folder and also use ipa-app-store target parameter instead of ipa-test. UPDATE: Flash Builder may overwrite an application ID in -app.xml with a “.debug” suffix; you should remove it prior to packaging. The ID should match the one registered with your mobile provisioning.

You can achieve the same thing with the following ANT script:

<?xml version="1.0" ?>
<project>
    <!-- SDK properties -->
    <property name="SDK_HOME" value="PATH TO AIR SDK"/>
    <property name="ADT.JAR" value="${SDK_HOME}/lib/adt.jar"/>
 
    <!-- Project properties -->
    <property name="APP_NAME" value="MyApplication"/>
    <property name="APP_ROOT_DIR" value="."/>
    <property name="BUILD_DIR" location="${APP_ROOT_DIR}/bin-debug"/>
    <property name="APP_ROOT_FILE" value="${APP_NAME}.swf"/>
    <property name="APP_DESCRIPTOR" value="${APP_NAME}-app.xml"/>
    <property name="IPA_NAME" value="${APP_NAME}.ipa"/>
    <property name="STORETYPE" value="pkcs12"/>
    <property name="KEYSTORE" value="PATH TO YOUR CERTIFICATE"/>
    <property name="STOREPASS" value="CERTIFICATE PASSWORD"/>
    <property name="PROVISIONING_PROFILE" value="PATH TO PROVISIONING PROFILE FILE"/>
 
    <target name="package">
        <java jar="${ADT.JAR}" fork="true" failonerror="true">
            <arg value="-package"/>
            <arg value="-target"/>
            <arg value="ipa-test"/>
            <arg value="-provisioning-profile"/>
            <arg value="${PROVISIONING_PROFILE}"/>
            <arg value="-storetype"/>
            <arg value="${STORETYPE}"/>
            <arg value="-keystore"/>
            <arg value="${KEYSTORE}"/>
            <arg value="-storepass"/>
            <arg value="${STOREPASS}"/>
            <arg value="${APP_ROOT_DIR}/${IPA_NAME}"/>
            <arg value="${BUILD_DIR}/${APP_DESCRIPTOR}"/>
            <arg value="-C"/>
            <arg value="${BUILD_DIR}"/>
            <arg value="${APP_ROOT_FILE}"/>
            <arg value="-C"/>
            <arg value="${BUILD_DIR}"/>
            <arg value="assets"/>
        </java>
    </target>
 
</project>

Written by Piotr Walczyszyn

March 22nd, 2011 at 2:52 pm

Posted in Examples

Tagged with , , ,

Slide effect with ViewStack and state transitions

with 4 comments

In this post I want to explain how the slide effect can be applied to application views. My goal is to do it in a declarative way as much as possible and to use default Flex components. I will demonstrate two possible solutions, one using the ViewStack component and other using Flex states and transitions.

You may wonder why I put that much effort into the slide effect. Ok, I know this isn’t anything revolutionary and this type of user experience is quite common, but I think recently it has become even more popular. This is due to the fact that it is almost a standard type of view transition effect on mobile devices. Now why not try to bring some of the coolness of mobile interactions also to the desktop world?

Using the ViewStack component

In my previous post about the as3viewnavigator library I briefly mentioned a ViewStack component and its inability to display two views at the same time. The consequence of this is also an inability to have a slide effect similar to the one in ViewNavigator. It’s not that the slide effect is not possible at all but you can’t have two views slide together. The only available option in the default ViewStack implementation is to have one view slide out and when its hide effect finishes, to have second view slide in. This is demonstrated in the example below.


This movie requires Flash Player 10


The implementation of this example is really very simple and you can see it below:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" 
			   width="300" height="300" 
			   viewSourceURL="srcview/index.html"
			   backgroundColor="#F0F0F0">
 
	<fx:Declarations>
		<s:Move id="view1ShowEffect" xFrom="{-stack.width}" xTo="0" />
		<s:Move id="view1HideEffect" xFrom="0" xTo="{-stack.width}" />
		<s:Move id="view2ShowEffect" xFrom="{stack.width}" xTo="0" />
		<s:Move id="view2HideEffect" xFrom="0" xTo="{stack.width}" />
	</fx:Declarations>
 
	<mx:ViewStack id="stack" left="10" top="10" right="10" bottom="10">
 
		<s:NavigatorContent id="view1" hideEffect="{view1HideEffect}" 
							showEffect="{view1ShowEffect}">
			<s:Button label="Show View 2" click="stack.selectedChild = view2" 
					  verticalCenter="0" horizontalCenter="0" />
		</s:NavigatorContent>
 
		<s:NavigatorContent id="view2" hideEffect="{view2HideEffect}" 
							showEffect="{view2ShowEffect}">
			<s:Button label="Show View 1" click="stack.selectedChild = view1" 
					  verticalCenter="0" horizontalCenter="0" />
		</s:NavigatorContent>
 
	</mx:ViewStack>
 
</s:Application>

Using Flex states and transitions

Now with the states and transitions example I wanted to raise the bar a little bit. Still the goal was to slide the views but the first thing I wanted was to slide them at the same time, and second I wanted my target states to have only one view at a time. You may say this is not possible. Well not exactly. What if I introduced an additional state that was only used during the transition and it included both views for that short period of time? Check out the example below:


This movie requires Flash Player 10


In the following code snippet you can see that I declared two additional states: slideToView1State and slideToView2State. These states will actually serve when slide effects are applied. Also when you want to switch, for example to state view2State you would set the application’s currentState property to slideToView2State. When the transition from view1State to slideToView2State is finished the effectEnd event will be handled and it automatically changes the state to view2State.

Another interesting thing to note here is that the slide states are grouped in a slideStates state group and the two views don’t have to explicitly be included in slideToView1State and slideToView2State states.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" 
			   width="300" height="300" 
			   viewSourceURL="http://riaspace.com/examples/ViewSlideTransitions/srcview/index.html"
			   backgroundColor="#F0F0F0">
 
	<s:states>
		<s:State name="view1State" />
		<s:State name="slideToView2State" stateGroups="slideStates" />
		<s:State name="view2State" />
		<s:State name="slideToView1State" stateGroups="slideStates" />
	</s:states>
 
	<s:transitions>
		<s:Transition fromState="view1State" toState="slideToView2State">
			<s:Parallel effectEnd="currentState = 'view2State'">
				<s:children>
					<s:Move id="hideView1Effect" 
							target="{view1}" xTo="{-view1.width}" />
					<s:Move id="viewShow2Effect" 
							target="{view2}" xFrom="{view2.width}" xTo="0" />
				</s:children>
			</s:Parallel>
		</s:Transition>
		<s:Transition fromState="view2State" toState="slideToView1State">
			<s:Parallel effectEnd="currentState = 'view1State'">
				<s:children>
					<s:Move id="showView1Effect" 
							target="{view1}" xFrom="{-view1.width}" xTo="0" />
					<s:Move id="hideView2Effect" 
							target="{view2}" xTo="{view2.width}" />
				</s:children>
			</s:Parallel>
		</s:Transition>
	</s:transitions>
 
	<s:Group id="view1" includeIn="view1State, slideStates" 
			 width="100%" height="100%">
		<s:Button id="btnView1" label="Slide To View 2"
				  click="currentState = 'slideToView2State'"
				  horizontalCenter="0" verticalCenter="0" />
	</s:Group>
 
	<s:Group id="view2" includeIn="view2State, slideStates" 
			 width="100%" height="100%">
		<s:Button id="btnView2" label="Show View 1"
				  click="currentState = 'slideToView1State'"
				  horizontalCenter="0" verticalCenter="0" />
	</s:Group>
 
</s:Application>

Written by Piotr Walczyszyn

March 4th, 2011 at 1:34 pm

Posted in Examples

Tagged with