Recently I’ve had a number of people asking me to put up an example of a WidgetFactory 6 widget. At least I think it was a number of people. It could have been the same person through a number of different channels. Whoever you are and in whatever quantity I wish to thank you and provide you with a gift. Here for you all now, whether you requested it or not, is a free to download widget with all its code begging to be investigated.
Click Here to Download the WidgetFactory 6 Example
I’ve included a .fla file that you can use to publish the widget. However you can use any program you wish to compile the widget. Except Word. Because Word doesn’t compile .swf files. Come to think of it you couldn’t use PowerPoint either… or Outlook, or Captivate, or Firefox, or Windows Task Manager, or Steam, or iTunes, or Intelli-J Idea- Wait no, you can use Intelli-J idea to compile it.
Okay, let’s try that again. You can use ANY Flash IDE to publish the widget example, you just have to make sure that WidgetFactory is already installed in that IDE. If you’re using Flash, then click here to read a tutorial on setting up WidgetFactory.
In other news I’m going to be easing up on the blog posts for a bit because… Wait… No I should probably write a devoted blog post about that… I’ll be right back.
PS: One of the people who originally requested an example wanted to know how to build a pause/play/fastforward button with a widget. For that person, please have a look at the TestInteractiveRuntimeMode class. In there I have coded two buttons, one to report the Interactive Widget’s success criteria and one to report its failure criteria. To change the button’s functionality to pause or play the movie for say… the success button, go to its click event handler (the onSuccess function) and delete the code in there. You can pause and play the movie the same way as you would in Advanced Actions, by changing a Captivate Variable. For example, if you wanted to pause the movie you’d write this in the onSuccess function:
1 | cpVariables.rdcmndPause = 1; |
For a list of other Captivate Variables you can use to control the Captivate Movie, please take a look at this post here (look under the variables named ‘rdcmnd’).



Hello,
Can you help me understand why the setSuccess() and setFailure() lines wont work in the following code?
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import widgetfactory.InteractiveWidget;
public class DragDrop extends InteractiveWidget
{
public var target:MovieClip;
private var originalX:Number;
private var originalY:Number;
public function DragDrop()
{
originalX = this.x;
originalY = this.y;
this.addEventListener(MouseEvent.MOUSE_DOWN, drag);
}
function drag(event:MouseEvent):void
{
this.startDrag();
this.parent.addChild(this);
this.addEventListener(MouseEvent.MOUSE_UP, drop);
}
function drop(event:MouseEvent):void
{
this.stopDrag();
this.removeEventListener(MouseEvent.MOUSE_UP, drop);
//this.addEventListener(Event.ADDED_TO_STAGE, drop);
if(this.hitTestObject(target))
{
this.visible = false;
trace(“correct”);
setSuccess();
}
else
{
this.x = originalX;
this.y = originalY;
trace(“wrong”);
setFailure();
}
}
}
}
I am getting the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at widgetfactory::InteractiveWidget/setSuccess()
Thanks a lot,
John
Hi John,
Do you get this error when you test your movie as published from Flash? Or does it also happen inside the published Captivate movie?
Tristan,
Thanks for the reply Tristan. I get it when I publish in Flash. I’ve tried inserting the widget into Captivate anyway but it does not recognize correct or incorrect.
The error you’re seeing in Flash is because you’re trying to call setSuccess() and setFailure() before these features become available. You should only call these methods when the widget is present in the published Captivate movie.
I’d suggest taking a read through some of the more articles under the basic category.
I’d suggest taking a look at this article on Template Methods: http://www.infosemantics.com.au/widgetking/2010/08/top-5-of-widgetfactory-5-template-methods-2/
If you cut your code from the DragAndDrop function and put it in the enterRuntime() Template Method, then you can be sure that setSuccess() and setFailure() will only ever be called when the widget is in the published movie.
As for Captivate not recognizing success and failure in the published movie, I guess this must be because the widget is not getting to that part of the code. It’s hard to say why, because I’m guessing you’ve got a Flash project attached to this code. So I can’t really tell what this ‘target’ variable is doing.
Try pulling the setSuccess() up to a point in the code where you do see it being executed in Captivate.
I hope that will give you some stuff to play around with.
Tristan,
You are correct that I have a Flash project attached to the code. The project is a simple drag and drop to two different bins which are the targets. There is also some code inside the flash movie which assigns the targets.
I’ve created another widget that is similar to this one using the setSuccess/setFailure and it works perfectly so I’m confused as to why this one doesn’t work the same way.
I’ll look through that article and try out the template method suggestion and see what I find out.
Thank you for the help,
John
Hey Tristan,
I’m not having any luck. I’ve gone through your template and interactive widget tutorials but I’m no closer to understanding why the setSuccess is not working. Do you have any other suggestions?
Thanks,
John
This class that you have here. Is it the document class for the whole Flash Project or is it attached to a symbol placed inside the project?
If you don’t know what a document class is, read through step five of this article: http://www.infosemantics.com.au/widgetking/2010/11/building-widgets-in-flash/
The InteractiveWidget class will only work if it’s used at the document class level. It won’t work if it’s attached to a symbol.
Tristan,
That’s the issue. Thank’s a lot. I should be able to figure something out.
John
Awesome. Thanks for letting me know