Tuesday, 25 October 2011

Displaying a Message Box in a Flash Builder 4.5 Mobile application

I am working on a new development article that will be posted late Nov or early December 2011 that discusses how to create a message-based Tablet application using Data Services 4.6. This application will use the Message service and display stock data. The stock data will come from a real financial data provider such as Yahoo Finance as opposed to an XML file.

 The great thing about creating a mobile application by using Flash Builder is that you can write once and then deploy to different Mobile devices including Android devices and iDevice devices, such as an iPad. That is correct -- you can create an application in Flash Builder and then deploy it to an iPad.

The tablet application will consist of three views as shown in the following diagram.

One of the objectives of Scott's Digital Community is to specify tips and tricks that I find useful as I develop applications by using Adobe technology. As I found, creating a pop up message (or Message Box) in a mobile application is not as straightforward as you may think. To begin, a mobile application does not support mx.controls.Alert. As a result, you have to create pop up messages by using another technique.

That other way is by using a fx:Component instance. You can think of a fx:Component as a class. You can create an instance of this class and then use the instance to display messages. The following code represent the fx:Component instance.


<fx:Declarations>
!-- This component represents a popup to show the user a message in a mobile application -->
<fx:Component className="AlertMsg">
    <s:SkinnablePopUpContainer x="70" y="400">
    <s:TitleWindow title="My Message" close="close()">
     <s:VGroup horizontalAlign="center" paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" gap="5" width="100%">
<s:Label text="{localVar}" />
<s:Button label="OK" click="close()"/>
</s:VGroup>
<fx:Script>
<![CDATA[            
// Variable in the renderer scope.
[Bindable] public var localVar:String="";

public function setValue(val:String)
{
this.localVar=val;
}
]]>
</fx:Script>
</s:TitleWindow>
</s:SkinnablePopUpContainer>
</fx:Component>
</fx:Declarations>


Then you can declare an instance of AlertMsg and then call its SetValue method and pass a string that represents the message that you want to display in your pop up message. For example:


//THIS IS HOW YOU SET A POPUP MESSAGE IN A MOBILE APP
var msg:AlertMsg = new AlertMsg();
msg.setValue("Hi There") ; 
msg.open(this, false);


I hope that you find this useful. Stay tuned for more useful information on Scott's Digital Community. 

Monday, 10 October 2011

Welcome to the first Blog of Scott's Digital Community

Hi and welcome to my Blog named Scott's Digital Community. My name is Scott Macdonald and I am a Senior Content Lead at Adobe. I have close to 15 years in the High Tech industry and 8 with Adobe. Among my responsibilities at Adobe are working with the community, writing technical documentation such as ActionScript, Java, .NET, HTML/XML, and so on, and other tasks such as helping out on the on-line forums, etc.

I love to get out and work directly with the community when I get the chance. I just got back from MAX 2011 and I really enjoyed working with those attending the labs and other sessions. I have attended the past 3 years at MAX and have meet a lot of interesting people working with various Adobe products. Speaking of interesting, this was taken at the MAX 2011 party.


Anyhow - my Blog is going to focus on how to use Adobe products to perform specific tasks. The format will range. That is, some topics will be shorter blog items, others will be technical articles, while others will be How To videos. The topics will range in subject matter as well. Some may be how to create a Mobile application for IOS or Android devices that receive data from back ends such as Data Services, while others may be how to programmatically extract data from a PDF form. Some may be tips that I find useful on how to use the CS products such Premire Pro (which is the software that I use to create videos).

If you are interested in a specific subject, email me at scottm@adobe.com and place Scott's Digital Community in the subject line.

For all of my videos that appear on this Blog, the following After Effects intro will be used.

video


Thanks,
Scott