Tools for building Pocket PC Flash applications

Daily Newsletters

Sign up to ZDNet UK's daily newsletter.

Flash remoting
Flash remoting is one of the main methods used for connecting Flash applications to Web backends. It allows Flash applications to send and receive data to Web services regardless of the server side technology (.NET, ColdFusion, J2EE, etc.). Flash remoting replaces the use of sending XML files back and forth and having to parse them manually. Once Flash remoting support is installed on your application server, you are all set.

For this application, I will connect to a ColdFusion Web service designed to accept a blog (Weblog) entry from a flash application on a pocket PC device. Since this application is merely a learning project, there isn't a great deal of security or robustness within the Web service or the app.

The next example shows the basic code needed to connect to an outside resource with Flash remoting. First, you establish your gateway, and then connect to it. Once connected to your gateway, that connection is available to the entire swf file for as long as that file is open. Once you've established the connection, you access your Web service (in my case http://website/blog/uploader.cfc is the ColdFusion component that makes up my Web service). You'll notice I don't use the ( / ) when providing the path to the blog/uploader Web service. Web service calls use dot notation where each ( / ) is replaced with a ( . ).

Lastly, you pass your data to the Web service just like any local function in your application.
NetServices.setDefaultGatewayUrl
("http://wwwmysite.com/flashservices/gateway");
gatewayConnection = NetServices.createGatewayConnection();
Myservice = gatewayConnection.getService("blog.uploader" , this);

Myservice.UpdateBlog({subject:blogTitle, CatSelect:blogCategory, newentry:blogBody,
entrydate:blogDate, passcode:"XXXX"});

ColdFusion components are a different article but the gist of this Web service is a database query that inserts the passed variables to the database and returns a status message.

Flash form elements
Flash form elements are specially built components for Flash to use in Pocket PC applications to help keep file sizes to a minimum. Using these elements, you have access to all of the standard form elements: drop-down lists, text boxes, radio and check boxes, etc. The Flash Device UI components are part of the Flash for Pocket PC Developer Kit available for free from Macromedia.

There's a variety of UI components available in the kit, though you're in no way limited to just these components. You can use any of the Flash form element components that come with Flash MX, but they can adversely affect the file size of your Flash application and its usability on the Pocket PC platform.

The real work starts now
The bulk of the work in this application takes place in the SubmitBlog() function (Listing A). SubmitBlog() takes the form data from the front end and either submits it via Web service to the blog site or, if the device isn't connected, stores it for later upload. Because the shared object contains an array, you can store multiple entries, holding each one until a network connection is established.

The function starts by creating two arrays; they'll be the working data stores. I create a date/time variable that will help the offline posts show the date they were recorded. (This is not implemented yet; work in progress, 'ya know). Next, I check to see if the Pocket PC device is connected to a network. This is done elsewhere, setting the ConnectStatus variable earlier in the application.

That Flash remoting connection I established earlier is used here. I could establish the connection within the SubmitBlog() function; as far as I know, there's no performance impact either way. The actual submitting to the server is pretty unremarkable, a single call to UpdateBlog. The last step of the update is to display a status message to the user so that he knows the update was successful. One thing to note, this message is displayed no matter what the status of the update. Flash remoting provides functionality to return results from the Web service, but this application doesn't utilize that functionality yet.

Now, let's assume that the Pocket PC device is not connected to any network, you're in the car or on a plane, or in the supermarket -- the SubmitBlog() function moves over to storage mode. You start by taking the data stored in the shared object and putting it into one of the local temp arrays. This preserves any entries that might be in the shared object already. Then you populate the other temp array with the form data for the new entry. Finally, you push the new entry array to the array containing the existing shared object data, then put it all back in to the Shared object.

One last bit of code
The last bit of code for the application is the auto upload feature. When the application loads, it checks to see if it is connected to a network and that there are blog entries to upload. If so, it resubmits them to the SubmitBlog() function.
var ArLen = MyBlog.data.Blog.length
if (ConnectStatus == "Online" && ArLen >= 1)
{
for (var i = 0; i < ArLen; i++)
{
Data2Submit = MyBlog.data.Blog.pop();
//trace(i + " " + Data2Submit + "--- Length: " + Data2Submit.length);
SubmitBlog(Data2Submit[0], Data2Submit[1], Data2Submit[2], Data2Submit[3]);
//trace("blogTitle: " + Data2Submit[0]);
//trace("blogCategory: " + Data2Submit[1]);
//trace("blogBody: " + Data2Submit[2]);
//trace("blogDate: " + Data2Submit[3]);
//trace("-----------------------------");
ResultStatus = "Stored Entries have been uploaded.";
}
}

Whenever the blog entry application is loaded, the code above pops each entry out of the shared object and submits it for upload. It loops as many times as there are entries to be uploaded.

This application is pretty simple -- not very robust or secure, but that's okay. It's just a beginner application, to get you started on the road to Pocket PC Flash applications. A more advanced example of the application would include using the result() function provided by Flash remoting to handle errors and confirm completions of the process. And security would be more than a four-character passcode sent along with the data. But it's a starting point for building your own Pocket PC Flash applications.

Post your comment

In order to post a comment you need to be registered and logged in.

You can also log in with Facebook. Log in or create your ZDNet UK account below

  • Login

Will not be displayed with your comment

By signing up for this service, you indicate that you agree to our Terms and Conditions and have read and understood our Privacy Policy. Questions about membership? Find the answers in the Community FAQ

Get ZDNet UK's daily newsletter

Enter your email address to sign up

ZDNet UK Live

bordero

ike fuelband is great for every healthminded person ! to work out! theres this website called textme4free.com that you can use to text anywhere in...

7 hours ago by bordero on Nike's FuelBand wristband gamifies exercise
BrownieBoy

> I'm told it's somewhat annoying when people have their Macs stolen > and Apple stores treat the thief as the owner, but there you go. Ouch,...

9 hours ago by BrownieBoy on AMD Ultrathins to challenge Intel Ultrabooks
Moley

@kevinmchapman. OK, I acknowledge that 'most' was a gratuitous throwaway comment as an afterthought and too presumptuous. As to proof, as you...

14 hours ago by Moley on A tale of two distros: Ubuntu and Linux Mint
Jack Schofield

@BrownieBoy > Works really well for thieves.... >> Nice attempt to deflect the argument by tossing in a point that's totally >> irrelevant, even...

15 hours ago by Jack Schofield on AMD Ultrathins to challenge Intel Ultrabooks
raskolnikof

fantastic that the so called piracy bills have been withdrawn. however, these anti-democracy supporters are still in the shadows so lets be alert...

16 hours ago by raskolnikof on SOPA, Protect IP support wavers in face of online protest
Tony Douglas

Please God no; teach them anything you like - thinking rationally, the uses and misuses of data, what data is and what it's not - but leave the...

18 hours ago by Tony Douglas via Facebook on Kids are the future. Teach ’em to code.
BrownieBoy

@Jack, > Works really well for thieves.... Nice attempt to deflect the argument by tossing in a point that's totally irrelevant, even it were...

1 day ago by BrownieBoy on AMD Ultrathins to challenge Intel Ultrabooks
bootlegger

Make that 13 people now - I got refused today at Manchester airport. I thought I was up to date on this legislation - I knew of the EU ruling from...

1 day ago by bootlegger on UK airport body scans will not be opt out
tinycg

Don't forget to check out apps like GoodReader or SlideShark either, they're indispensible for people on the go in presentation situations. Best...

2 days ago by tinycg on Four top iPad apps for people on the move
TerryRK

Well it seems there is something a number of us agree on. Why is the Ubuntu Unity launcher so ugly? I thought perhaps it was something to do with...

2 days ago by TerryRK on A tale of two distros: Ubuntu and Linux Mint
Freebies202

Duplicate comments are not made intentionally. Its very good to know that now you are keeping check on this problem because sometimes a commenter...

2 days ago by Freebies202 on Microsoft fixes blog comments, speeds up blogs with open source
kevinmchapman

"the very significant number of users" and "many (most) of us" - you have no evidence for these statements. It is a fact that most users are saying...

3 days ago by kevinmchapman on A tale of two distros: Ubuntu and Linux Mint
Marg Menzies Harrison

Another grammar faux pas is the improper use of "you". When sitting down down in a restaurant, for example, I get cringe when the waitress...

3 days ago by Marg Menzies Harrison via Facebook on 10 flagrant grammar mistakes that make you look stupid
zdnetukuser

And NOW, folks, for Canonical's next trick... Kubuntu is late. Here's a pencil. Draw your own conclusions. cf.:...

3 days ago by zdnetukuser on Linux Minterface
Moley

@kevinmchapman. The discussion here reflects the very significant number of users who really do like the traditional menu system and who wish to...

3 days ago by Moley on A tale of two distros: Ubuntu and Linux Mint
kevinmchapman

Er, no... It is an efficient means of finding the application/file/setting you need in one place. The icons are a simply a fallback for when you...

3 days ago by kevinmchapman on A tale of two distros: Ubuntu and Linux Mint
TerryRK

Isn't the provision of a text based search an admission by the developers that the mass of icons approach does not work? I don't need to use a...

3 days ago by TerryRK on A tale of two distros: Ubuntu and Linux Mint
kevinmchapman

"Unity and GNOME 3 both abandon the old text-based cascading menus in favour of a graphical icon-driven system." Point truly missed. Both use a...

3 days ago by kevinmchapman on A tale of two distros: Ubuntu and Linux Mint
TerryRK

whs001 - Thank you, I'm glad you liked the article. I absolutely agree with you on your first point. I should perhaps have made it clearer that...

3 days ago by TerryRK on A tale of two distros: Ubuntu and Linux Mint
Dennis Nilsson

If we allow corporate interest to dictate the way our government circumvents due process against foreign entities then we should accept the same...

3 days ago by Dennis Nilsson via Facebook on ACTA stumbles in Germany

Latest in Application Development