Developers > Learning Center > FAQ


Tips and Tricks

Remember to keep these tips in mind when working with our API:

  • Generally try to avoid root level stage access in your actionscript - When in AIR desktop mode (user copies widget to AIR desktop), the owner of the stage lies in a different security sandbox than the widget itself. Accessing the stage object directly in this context will result in a security error being thrown. If you have diabled syndication to AIR desktop, than this does not apply. If necessary, put the stage references inside of try/catch statements.
  • If your widget manipulates the Stage object, there may be sizing issues and/or display issues on the web or desktop widget destinations. Avoid modifying the Stage during runtime to avoid these issues.
  • If your widget uses root global variables or expects to be the top-most movieclip/canvas, there may be issues when rendering the widget.
  • If you are using the new document class feature of AS3 and not using the yourminis widget api (No code changes features), then you will need to declare your class as dynamic or create a public var widget; variable in your class definition.
  • Flash Actionscript 3.0 is required for non-coding wrapped widgets.
  • All relative URLs need to be changed to absolute URLs (since the flash file will be hosted on the yourminis.com domain). If you are loading images, xml files, apis, etc... using relative URLs, when the widget is uploaded to yourminis, the widget will break.
  • If your widget accesses resources on other domains, those domains need to allow access from "*.yourminis.com" in a crossdomain.xml file.
  • Make sure to store any settings you want to save across sessions / copies using the widget.getSetting and widget.setSetting APIs.
  • Any flashvars used by your widget must be manually URLencoded and appended to the "custom flashvars" section of the yourminis widget publish screen (during add or edit).
  • If creating a swf from a document class, move all of your constructor code into an addedToStage function and model your widget API code similar to the example below:

    public class Test extends MovieClip {
       public var widget;

       public function Test() {
          addEventListener(Event.ADDED_TO_STAGE,onAddedToStage)
       }

       private function onAddedToStage(evt:Event):void {
          //constructor code
          addEventListener("widget-loaded",onWidgetLoaded);
       }

       private function onWidgetLoaded(evt:Event) {
          //widget variable ready to use
       }
    }
  • If creating a draggable object within your widget, use event.stopImmediatePropagation() within the mousedown event, or set widget.chrome.draggable = false. This will prevent the widget from dragging along with your draggable object.
  • If you want to hide the default chrome, use widget.chrome.enabled = false;
  • Make sure the widget chrome is sized to the size of your widget, even if it is disabled. In your onWidgetLoaded function, widget.initWidget(width,height,color)
  • If you want to create your own copy button, widget.syndication.openSyndication() to open the back panel and widget.syndication.buttonMode = 0 to hide the default copy button.
  • If you ever have a question - do not hesitate to use the Developer Network. We will try to respond to your questions as fast as possible.

FAQ

Here are some commonly asked questions and answers regarding the yourminis API:

  • Q: How do I detect the platform (facebook, iGoogle, Netvibes, etc.) in which the the instance of the widget is running?
  • A: The following code will probably help you: if (widget.social.socialType!="none")
    {
    //show social stuff
    }

    If you wanted social network specific functionality, you could do

    switch(widget.social.socialType)
    {
    case "bebo":
    //bebo specific
    break;

    case "facebook":
    //facebook specific
    break;

    case "opensocial":
    //open social
    break;

    case "none":
    //no social context
    break;
    }

    A full tutorial on our social platform can be found here.
  • Q: How do I save a setting in a widget without that setting getting carried over after someone copies the widget?
  • A: Use two underscores ('__') before the setting name, for example 'widget.setSetting("__mycolor",0xFF0000)'