📜 ⬆️ ⬇️

Windows Vista Sidebar as a platform for flash desktop applications?

Now, the question of choosing a platform for desktop applications (in particular, flash / flex-applications) is quite acute. Adobe released Apollo for this, given that sooner or later all flash / flex developers will port their desktop applications to it. To be honest, I agree with that.

But suddenly, I had a question - is it possible to use Windows Vista as a platform, in particular, its new Sidebar component and use all its power. And the Sidebar platform is really powerful, with a huge number of features and capabilities.

flashearth.jpg
')


Vista sidebar
In Vista, a new element of the interface, Sidebar, which after the installation of the default are the clock, slideshow and news. The main purpose of the Sidebar - quick navigation when performing typical tasks and information flow management, consolidation and obtaining the necessary summary data. On the Sidebar, you can add any other web applications, or gadgets; You can customize the Sidebar, changing its location relative to the sides of the screen; When using multiple monitors, you can specify a specific monitor on which Sidebar should be displayed.

Several questions arose at once:

The complexity of the implementation.
The question disappears, since everything is extremely simple. So Sidebar gadgets are nothing more than a regular archive with plain html and javascript and some set of specific files. True, JavaScript is somewhat extended, i.e. has functions to interact with the operating system.
So, embedding swf files is as easy as adding them to a regular html page. It’s easy to access JavaScript functions — via ExternalInterfaces

If the user does not have the Flash Player, then you can do a regular ExpressInstall.

The issue of distribution.
This question is more complicated. Windows Vista is not yet very popular with users. Sooner or later, most, of course, will switch from XP to Vista, but this is a controversial issue and does not apply to the subject of this article. This article is simply a demonstration of how Vista Sidebar is used as a platform.

For Apollo, the question of distribution is an absolute advantage. But this is all the lyrics. You can simply think about creating desktop applications specifically for Windows Vista, since JavaScript, AJAX, does not have as many features as Flash or Flex. But this is again a moot point.

Implementation.
As an example, I did FlashEarch ( http://www.flashearth.com/ engine). I repeat - this is only a demonstration of the principle.

Sidebar gadget is a regular archive with a .gadget extension.
One of the main components of the gadget is an xml file with all descriptions. For example:

<?xml version="1.0" encoding="utf-8" ?>
<gadget>
<name>Flash Earth</name>
<namespace>shaggysmile.com</namespace>
<version>1.0</version>
<author name="SHAGGYSMILE">
<info url="http://lifeflash.shaggysmile.com" />
</author>
<copyright>2007</copyright>
<description>Flash and Windows Vista Sidebar</description>
<icons>
<icon src="icon.png" mce_src="icon.png" />
</icons>
<hosts>
<host name="sidebar">
<base type="HTML" apiVersion="1.0.0" src="index.html" mce_src="index.html" />
<permissions>full</permissions>
<platform minPlatformVersion="0.3" />
</host>
</hosts>
</gadget>


It makes no sense to describe what is here and how, since everything is clearly visible. If you have questions, see the source or read the documentation .

Then everything is simple. It all depends on your knowledge of JavaScript and ActionScript. If you want to use system functions, then JavaScript will be the main core. The swf file itself is just a visual display. The data in the swf is transmitted via ExternalInterfaces.

For example, a function that returns the percentage of RAM load.

Flash :

import flash.external.*;
Stage.scaleMode = 'noscale';
Stage.align = 'tl'; var isAvailable:Boolean = ExternalInterface.available;
function getMemoryPercentageSize() {
var memoryPercentSize = Number(String(ExternalInterface.call("getMemoryPercentageSize")));
debug_txt.text = Math.floor(memoryPercentSize)+"%";
}
onEnterFrame = getMemoryPercentageSize;


Javascript :

function getMemoryPercentageSize()
{
var oMachine = new machineStatus();
return oMachine.memoryPercentage;
}
function machineStatus()
{
this.CPUCount = System.Machine.CPUs.count;var usageTotal = 0;
for (var i = 0; i < this.CPUCount; i++) {

usageTotal += System.Machine.CPUs.item(i).usagePercentage;this.CPUUsagePercentage = Math.min(Math.max(0, usageTotal / this.CPUCount), 100);
this.totalMemory = System.Machine.totalMemory;
this.availableMemory = System.Machine.availableMemory;if((this.totalMemory > 0) && (this.totalMemory > this.availableMemory))
{
this.memoryPercentage = Math.min(100 - (this.availableMemory / this.totalMemory * 100), 100);
}
else
{
this.memoryPercentage = 0;
}
}


As you can see everything is quite simple. Everything rests, only in your knowledge of JavaScript.
This is the most basic example. In principle, if you do not need all the features of Vista Sidebar and you want to use it only as a container for flash applications, then you don’t need JavaScript. Too long and boring to write about everything. I have already described the basic principles. The rest is reading the documentation and viewing the source. In the source two swf-file. The first is just Flash Earth, the second is a display of the current RAM load.
That's all.

Sources

Source: https://habr.com/ru/post/9054/


All Articles