Async extension block


  • Posts: 1
Hi All

This is the first time I've tried to create an extension, so it's more than likely something I'm missing because it's new to me.

I've got an AS library that I need to pass a callback method to, and I want to be able to process the parameter passed to the callback in further blocks.

Looking at the visit URL block, the "site's response" is somehow made available for dragging into nested blocks for processing, I'd like to achieve the same thing in blocks.xml but I'm struggling to work out how.

This i how far I've got:

<block tag="LogEventRequest" spec="LogEventRequest userName %0 ,password %1 and then do... [e:dash] %2 response [e:tag-arrow]" code ="GS.sendWithData(~,function (response:Map):Void{~});" type="wrapper" color="blue" returns="void">
         <text order="0"/>
         <text order="1"/>
         <text order="2"/>

I've found some references to how the visit url block is created by looking in behavious-blocks.lang, but it look like this just contains parts of the spec.

Any help would be appreciated!




  • Posts: 1653
Hello GabrielPage,

Welcome to the forum.

Boy what a first question you have!

Unless you provide more information it is not exactly sure if you are following all the steps.

Maybe I ommit one or two steps as well in trying to help you.

1. Stencyl version depends on location of files, please provide it! (I assume you have 3.1 from now on)
2. For stencyl 3.1 the extension files should go in stencylworks/engine-extension (See for your platform OSX, Windows other posts for exact location C:\users or $HOME)
3. in this engine-extension directory you create the name of your extension-folder
4. In this example I will use the nuggeta extension as an example and you have a folder named nuggeta inside the engine-extensions directory
5. In this directory you have to have some files. From your description you already found the blocks.xml so I assume that you have copy/pasted the files from another location.
6. Important is the .hx file. This is the text file that works together with the blocks.xml
7. I will pick one of the blocks that is a wrapper block just like you are asking:
Code: [Select]

<block tag="NuggetaRequestPropertyList" spec="Nuggeta: Request property list" code="MyNuggeta.requestPropertyList(function AfterGetProperty(){~});" type="wrapper" color="blue" returns="void">
                <CODE_BLOCK order="0"/>
8. It is very important (like I mentioned :) ) to match the code block to a piece of code in your hx file
9. In our case the MyNuggeta reference in the blocks.xml refers to MyNuggeta.hx
10. In this MyNuggeta.hx file we have the code that is referred to by blocks.xml
Code: [Select]
  public static function requestPropertyList(theFunc:Dynamic){
                // do something you need to do .. in our case we get an array of data and we need to wait for the network to deliver it.
                // If you want to see the whole code download and inspect the nuggeta extension
               // When you are done with what you want to prepare we call the call-back function:
               theFunc();  // now the things inside the wrapper block in Stencyl is going to be executed ...

11. You probably know how to make the blocks appear in Stencyl by enabling the extension and restart the game; if not follow instruction on any other extension installation first.

Hope this helps.

Best regards from
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.