Jump to content

Adobe Flash - Calling convention for AS 3.0 functions


photo

Recommended Posts

Calling Action Script 3.0 (the current version) functions from Unigine script does not appear to work. Older versions work.






flash = new WidgetFlash(engine.getGui(),swfpath);

if (flash == NULL) {
    log.message("Failed to load [%s]\n",swfpath);
    return NULL;
}

log.message("Loaded SWF [%s]\n",swfpath);
engine.gui.addChild(flash,GUI_ALIGN_OVERLAP | GUI_ALIGN_BACKGROUND);

flash.play();

flash.runFunction("test_function");

log.message("Height = [%d]\n",flash.getFlashHeight());

The issue seems to me to be focussed around the new code layout in Flash CC / AS3.0. The new way is to have a "package {}" wrapper around an AS class, for example the AS code that I'm trying to call is below;



package two {

import flash.display.MovieClip;


  public class two extends MovieClip {

    public function two() {
        // constructor code
        trace("constructor");
    }

    public function test_function() {
        trace("test_function called");
        //Engine.logError("Test!");
    }

 }

}

The error message given is

FlashContext::runFunction(): can't find "test_function" function

I have also tried calling it as;

test_function()
two.test_function
two.test_function()

It is important to get this version of Flash / Actionscript working as Adobe do not sell or support the older versions any more.

Link to comment
×
×
  • Create New...