| Previous | Next | |
We are working toward creating a development environment for Mac and Windows -- one FLA, two platforms is our mantra. To this end we’ve tried to make our Mac and Windows APIs consistent but there are differences.
In most cases, the differences arise because of differences in the Mac OS and Windows operating systems -- e.g. Mac has a Dock / Windows has a Taskbar and System Tray. In most of these cases, we provide an analogous cross-platform solution with source code so your application can deliver the necessary functionality and user experience with a Windows and Mac flavor. The following items are API differences that you may need to consider before starting cross-platform development.
Windows Taskbar and System Tray vs. the Mac OS X Dock
Alert the User - Flashing the Taskbar and Animating the System Tray and Dock Icons
Menus
Transparency
Handling Differences via Code Branching
File Paths
Extensibility - Plug-ins and Windows COM
Screen Capture
mRegistry Class
In other cases, the differences are the result of our current development cycle and we will add these methods as we go along. Prioritizing our to-do list is effected by user feedback so if you need something send us an email.
Your decision to have a taskbar button, system tray icon or Dock icon will be related to the kind of application you are developing. On Windows, full-blown applications will generally have a taskbar button and not a system tray icon. Full-blown Mac applications will most likely appear in the Mac OS X Dock. If you are developing a lightweight widget or alert application, you will probably choose to show an icon in the Windows system tray and not in the taskbar or Dock.
Check the "Show Application On Taskbar" box if you want your application to appear as a button on the Windows taskbar or include the command mApplication.showOnTaskBar(true); in the first frame of your movie.
Check the "Show Application In System Tray " box if you want your application to appear in the Windows system tray or include the command mApplication.showInSystemTray(true); in the first frame of your movie.
You can change your Windows application's taskbar and system tray appearance anytime during execution using mApplication.showOnTaskBar() and mApplication.showInSystemTray().
Check the "Show Application Menu Bar / Show In Dock" box if you want your application to display a menu bar across the top of the screen when active, and an icon the Dock. The "Show Application Menu Bar / Show In Dock" settings is an initialization settings and cannot be changed during execution.
Download Alert User application to see these methods in action.
On Windows, you can alert your user by animating the application’s system tray icon through the use of the mApplication.setSystemTrayIcon() and mApplication.showInSystemTray() commands. The mApplication.setSystemTrayIcon() command reserves a 16x16 pixel rectangle in your Flash movie for the system tray icon. This rectangle will be used for drawing the system tray icon and will not be rendered as part of the animation itself. The command mApplication.showInSystemTray() shows and hides the icon.
In addition, on Windows, you can flash the application's taskbar button using mApplication.flashTaskBarButton() or the taskbar button of an individual window of a multi-window application using mWindow.flashTaskBarButton().
On Macintosh, use the commands mApplication.bounceDockIcon() and mApplication.setDockIconBadge() to alert the user. The setDockIconBadge enables you to overlay a small text message on the Dock icon, and bounceDockIcon bounces the icon in the Dock when your application is not the front application.
Download Alert User application to see these methods in action.
On Windows, mProjector enables you to customize the right-click and system tray menus of your application.
mProjector Mac enables you to customize a right-click (or cntl-click) menu and create a standard MAC OS X application menu bar and menus. The MAC OS X application menu bar appears across the top of the screen outside the main application window when the application is active. mProjector Windows does not include functionality to add a application menu bar. In general on Windows the application menu bar appears in the main window. This menu can be created in Flash using a menu bar component.
The following sample demonstrates a custom right-click popup menu and menu event handler.
mMenu.removeAllItems();
mMenu.addItem("Minimize");
mMenu.addItem("Restore");
mMenu.addSeparator();
mMenu.addItem("Online Documentation");
mMenu.addItem("Contact Tech Support");
mMenu.addItem("Forum");
mMenu.addItem("Check for Updates");
mMenu.addSeparator();
mMenu.addItem("Visit ScreenTime Media");
mMenu.onCommand = function (menuName, itemName)
{
switch (itemName)
{
case "Minimize":
mWindow.minimize();
break;
case "Restore":
mWindow.restore();
break;
case "Online Documentation":
mSystem.openDocument("http://www.screentime.com/software/mprojector/docs/");
break;
case "Contact Tech Support":
mSystem.openDocument("mailto:support@screentime.com");
break;
case "Forum":
getURL("http://forum.screentime.com");
break;
case "Check for Updates":
mSystem.openDocument("http://www.screentime.com/mprojector/updates/");
break;
case "Visit ScreenTime Media":
mSystem.openDocument("http://www.screentime.com/");
break;
}
} mProjector Macintosh enables you to add menus to the menu bar of your application as well as to the right-click menu (ctrl-click menu). The main menu bar is shown at the top of the screen when your application is active.
mMenu.createMenu("Help");
mMenu.addWebLinkToMenu("Online Documentation", "www.screentime.com/software/mprojector/docs/", "Help");
mMenu.addWebLinkToMenu("Contact Tech Support", "mailto:support@screentime.com", "Help");
mMenu.addWebLinkToMenu("Forum", "forum.screentime.com/", "Help");
mMenu.addSeparator("Help");
mMenu.addItem("Register", "Help");
mMenu.addWebLinkToMenu("Check for Updates", "www.screentime.com/software/mprojector/docs/", "Help");
mMenu.addWebLinkToMenu("Visit ScreenTime", "www.screentime.com/", "Help");
mMenu.addMenuToMenuBar("Help");
mMenu.onCommand = function (menuName, itemName)
{
if (itemName=="Register")
{
//register user
}
}
If menuName is left blank, the menuName defaults to "Right Click Menu" and the Mac and Windows menu commands are the same.
Visit Using mProjector: Menus for more information.
Download the Context Menus sample application to see these methods in action.
The current version of mProjector supports Flash alpha channels and anti-aliasing in "Flash-shaped (windowless)" type windows for BOTH Mac and Windows. On Windows transparent regions may appear as solid black. You can remedy this error by simply setting cacheAsBitmap=true for the target movie clip. Setting _root.cacheAsBitmap = true; in the first frame usually remedies this problem.
Flash alpha channels and anti-aliasing in "Flash-shaped (windowless)" type windows is NOW FULLY SUPPORTED supported on the Macintosh.
In most cases it's best to handle Mac vs. Windows differences with simple code branches. The commands mSystem.isMac() and mSystem.isWindows() can be very helpful in these cases.
A good example of this is found in the implementation of mSystem.chooseFile(). Mac and Windows implement the file type filter differently enough that a common implementation of the filter can get tricky. However, to handle these cases using small code branch to define platform specific filters is easy.
// select a JPG file then set it to be the active wallpaper
if (mSystem.isMac()) {
fileFilter = "jpg";
defaultFileType = "";
} else if (mSystem.isWindows()){
fileFilter = "JPEG Files (*.jpg)|*.jpg";
defaultFileType = "jpg";
}
wallpaperPath = mSystem.chooseFile("Select Wallpaper", "", picturesFolder, fileFilter, defaultFileType, true, false);
mSystem.setActiveWallpaper(wallpaperPath);
mSystem.getPathDelimiter() returns the path delimiter for the current OS. On Windows mSystem.getPathDelimiter() returns "\", on the Mac it returns "/". The example below writes a string to temp.txt file on the Mac or Windows desktop.
var pathDelimiter = mSystem.getPathDelimiter();
var filename:String = mSystem.getSpecialFolder("DESKTOP") + pathDelimiter +"temp.txt";
success = mFile.writeString(fileName, stringToWrite);
mProjector Windows has an expandable architecture. You can add your own functionality by publishing your C++, C#, Delphi, Visual Basic, etc. as a standard COM object, or you can build an mProjector plug-in. mProjector Macintosh is not currently extensible. If you require Mac extensibility, contact us.
Visit Using mProjector: Plug-ins for more information and sample code.
Visit Using mProjector: Windows COM Basics for more information and sample code.
The current screen capture API is uneven in mProjector 3.0 but workable.
On the Mac there is only one way to do a screen grab -- use mApplication.captureScreenToJPG(). To capture the screen on a Mac, first set up a MovieClipLoader object with an onLoadInit callback, call mApplication.captureScreenToJPG() with a file path for the screen grab JPG, then call the MovieClipLoader's loadClip method with the JPG path and the movieclip where you will display the JPG. If you need to capture just a piece of the screen, set the scrollRect property of the movieclip.
Windows can work exactly like the Mac with the exception of needing to call a non-documented function mScreenCapture.captureScreenToJPG() on Windows instead of mApplication.captureScreenToJPG() on the Mac.
The Windows only method mScreenCapture.captureScreenToJPG() is a bit more powerful than the Mac's mScreenCapture.captureScreenToJPG() method as it has optional clipping region parameters so you have the option of not using scrollRect property of the display movie clip.
Visit Using mProjector: Screen Capture for more information.
Download the Screen Capture sample application to see these methods in action.
Mac OS does not have an API analogous to the Windows OS registry, however, because having access to the Windows registry can be very powerful, we decided to include it in mProjector Windows.
Windows uses the registry to store system and application preferences and data that you want to hide from non-power users. Being able to read and write to the registry gives an advanced programmer control of the Windows OS. The only way to access this data is through RegEdit.exe or the Windows registry API.
The Mac uses plist (XML files ) to store system and application preferences. These plist files are similar to the Windows registry but can be read and written to using standard mFile read and write string file commands.
If you need to store application data in a relatively safe place in a cross-platform way, create a folder for your application in the preferences folder and read and write settings file there. The idea of an preferences folder exists on both Mac and Windows. You can get a file path to the user's preferencese folder by calling mSystem.getSpecialFolder("PREFERENCES"); The code below creates a preferences folder for the application and data contained in the application_preferences_str variable to a text file called preferences.txt.
//create prefs folder for application
var applicationPrefsFolder = mSystem.getSpecialFolder("PREFERENCES") + mSystem.getPathDelimiter();
var prefsFolderExists:Boolean = mFile.folderExists(applicationPrefsFolder);
if (!prefsFolderExists) {
prefsFolderExists = mFile.createFolder(applicationPrefsFolder);
}
//write application prefs to prefs file
var applicationPrefsFilePath = applicationPrefsFolder + "preferences.txt";
if (prefsFolderExists) {
mFile.writeString(applicationPrefsFilePath, application_preferences_str);
}
| Questions or Feedback? | Previous | Next |