Todo: Documentation for MyPlugin
In order to use MyPlugin, you must first load the plugin at the top of your script
using the LoadPlugin method like this:
app.LoadPlugin( "MyPlugin" );
Then you can create an instance of the plugin object when you need it like this:
plg = app.CreateObject( "MyPlugin" );
Examples:
Example - Get Version
app.LoadPlugin( "MyPlugin" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
btn = app.CreateButton( "Press Me" );
btn.SetOnTouch( CallPlugin );
lay.AddChild( btn );
plg = app.CreateMyPlugin();
app.AddLayout( lay );
}
function CallPlugin()
{
alert( plg.GetVersion() );
}
Example - Test Callback
app.LoadPlugin( "MyPlugin" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
btn = app.CreateButton( "Press Me" );
btn.SetOnTouch( CallPlugin );
lay.AddChild( btn );
plg = app.CreateMyPlugin();
plg.SetOnMyReply( OnMyReply );
app.AddLayout( lay );
}
function CallPlugin()
{
plg.MyFunc( "hello", 21, true );
}
function OnMyReply( txt, num, bool )
{
alert( "txt=" + txt + " num=" + num + " bool=" + bool );
}
Example - Send Image Data
app.LoadPlugin( "MyPlugin" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
img = app.CreateImage( "/Sys/Img/Hello.png", 0.2, -1 );
lay.AddChild( img );
btn = app.CreateButton( "Save Image" );
btn.SetOnTouch( CallPlugin );
lay.AddChild( btn );
plg = app.CreateMyPlugin();
app.AddLayout( lay );
}
function CallPlugin()
{
var ret = plg.SaveMyImage( img );
app.ShowPopup( ret );
}
Example - Modify Image
app.LoadPlugin( "MyPlugin" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
img = app.CreateImage( "/Sys/Img/Hello.png", 0.6, -1 );
lay.AddChild( img );
btn = app.CreateButton( "Write On Image" );
btn.SetOnTouch( CallPlugin );
lay.AddChild( btn );
plg = app.CreateMyPlugin();
app.AddLayout( lay );
}
function CallPlugin()
{
plg.ModifyMyImage( img, "Hello" );
}
Example - Custom Control
app.LoadPlugin( "MyPlugin" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
plg = app.CreateMyPlugin();
btn = plg.CreateMyButton( "Hello", 0.4, 0.2 );
lay.AddChild( btn );
app.AddLayout( lay );
}