Widget resources, widgets for download, tutorials and more at widgipedia.com
Popular Tags:

action adventure alfanet apple arcade blog blogs business cars clock dashboard drive flash free fun game games garageband google idvd ilife imovie iphoto islam iweb kpop mac macwidgets mario music news platform play puzzle search searchfree shoot sports strategy thedashboard tvwidgets websearch widget widgetindex widgettv
Log in to Widgipedia
The Widgipedia Forum : The Widgipedia Workshop
A place to host widget tutorials, knowledge, tips & tricks.
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
Ernesto Quezada
Avatar
(IP Logged)
September 02, 2007 11:20AM

messageBuilding desktop widgets with Zinc: Right click
Following the tutorial on Building Flash desktop widgets with Zinc, in this tutorial we will see some actionscript and a bit of {MDM}Script to add some interactivity to our widget.
We will do something very similar to what I've explained before in my post "Building flash web widgets: right click" but this time is desktop oriented thanks to MDM Zinc.

At the moment the only way to close our application is by pressing the "Esc" button and that's not nice and not user friendly at all...
So we will open our flash file, and add the following script:


function closeWidget() {
mdm.Application.exit();
}

var cmMenu:ContextMenu = new ContextMenu();
cmMenu.hideBuiltInItems();
cmMenu.customItems.push(new ContextMenuItem("Close Widget", closeWidget));

this.menu = cmMenu;


There's a function called closeWidget and it has only one line of {MDM}Script that will close our application.
The rest is the usual script necessary to have a right click menu explained before in my post "Building Flash web widgets: Right click" so if you need more explanation please read that post.
We will do the same we did for the web widget and we will add a link to our site and a link to Widgipedia.
Let's update the code:


function closeWidget() {
mdm.Application.exit();
};
function linkToMe():Void {
getURL("http://overloadstudios.blogspot.com/");
}
function linkToDistributor():Void {
getURL("http://www.widgipedia.com");
}
var cmMenu:ContextMenu = new ContextMenu();
cmMenu.hideBuiltInItems();
cmMenu.customItems.push(new ContextMenuItem("Close Widget", closeWidget));
cmMenu.customItems.push(new ContextMenuItem("Built by Overload Studios", linkToMe, true));
cmMenu.customItems.push(new ContextMenuItem("Powered by Widgipedia", linkToDistributor));
this.menu = cmMenu;


Now we have added a link to my blog and a link to Widgipedia and the code is the same as the one on this post except for one thing, the script to add the link to my blog has something new, it says "true" as a final parameter ( "Built by Overload Studios", linkToMe, true ), this "true" means there will be a division line above it to separate the close button to the credits.

If we test the flash movie pressing Ctrl+Enter (command+Enter on Mac) and press down the right button of the mouse, we should see a menu like this one:

http://overloadstudios.co.uk/ewa/closeWid01.gif

of course if we click on "close widget" nothing happens and is because the script to close the widget only works when the application is built with MDM Zinc.
{MDM}Script is perfect to extend flash applications, has hundreds of options and we will add another one just because smiling bouncing smiley

Ok, not just because... instead of the single line to close the application, just in case the user doesn't want to close it and pressed the button by mistake, we will add a "confirm" window so the user can really close the widget or leave it open; to do so, we will update the script changing the closeWidget function as follows:


function closeWidget() {
var Result = mdm.Dialogs.promptModal("You sure you want to close?", "okcancel", "confirm");
if (Result == true) {
mdm.Application.exit();
}
}


We are adding a "confirm window" called Result and has three parameters: the message, the two options available and the window style. To see find out more about the possible options, please check the MDM Zinc documentation.

We don't need to add anything else from the flash side, we can save and close the file if we want to and now we should open Zinc and follow the instructions given in the previous tutorial with the difference that in this case in the "input devices settings" we will change the "right mouse button" setting to Send to Flash instead of the default "Ignored".
Build your widget and you will be able to see something like:

http://overloadstudios.co.uk/ewa/closeWid02.gif

And that's it! our widget is ready to be uploaded to Widgipedia! hot smiley

Please don't forget to check the Zinc documentation and if in case you get stuck in something, visit the MDM Forums as for sure you will get a fast answer.

salut!
-----------

:: Games Garden ::

  
sandrasavira
(IP Logged)
November 20, 2011 08:21PM

messageRe: Building desktop widgets with Zinc: Right click
Where can I put this script? Is the flash or mdmZinc?
Can you give me an example of a simple file?
Thank you .. grinning smiley

  
sandrasavira
(IP Logged)
November 20, 2011 08:23PM

messageRe: Building desktop widgets with Zinc: Right click
Where can I put this script? Is the flash or mdmZinc?
Can you give me an example of a simple file?
Thank you .. : D

  
Ernesto Quezada
Avatar
(IP Logged)
December 07, 2011 11:46AM

messageRe: Building desktop widgets with Zinc: Right click
The script should be in Flash. MDM Zinc only packages the swf and makes it an executable file.
You can download examples from the MDM Zinc website.

Salut!

:: Games Garden ::

  


Sorry, only registered users may post in this forum.
Check out our sister site Dealio for Cyber Monday Deals and Nordstrom Coupons.
This forum powered by Phorum.