Can someone explain AIR Native Extensions FREGetContextActionScriptData() and FRESetContextActionScriptData() in more detail? - actionscript-3

I have created an AIR Native Extension wherein, I have created a reusable Loader object on the AS3 side. I then pass this Loader object to the ANE to load whatever loadable file I want to load into the Loader. This works, as expected.
I would like to create the reusable Loader on the C side of the ANE. My understanding is that the FRESetContextActionScriptData() and FREGetContextActionScriptData() functions allows me to create and store AS3 FREObject variables on the C side.
I have been trying to implement these functions on the C side and and unable to wrap my head around how to do so. The Adobe help is insufficient and does not help in any way. I have tried to search for these two words with no success. Can someone throw some light on how these functions are used?
Thanks in advance.

Related

How to do a simple drawing app in Flash?

I am trying to do a simple drawing app in Flash Professional CC. By simple, I just mean something that allows the user to click down and draw and mouseup- stop drawing.
I've been following this tutorial: https://www.youtube.com/watch?v=OXdphAAH1mQ
However, on the line:
... _root._xmouse, _root._ymouse
I get an error which says that it's undefined... I tried mouseX as well, which also didn't work.
I assume it's because I'm using Professional CC so it may be a different version of AS. Does anyone have any tips on how I can get a drawing app working on Prof CC?
_root._xmouse, _root._ymouse It's an AS2. As you could see in Tutorial, he also creates AS2 project. I'm not sure, that you can create AS2 project in Flach CC. As far as I can see, there is no option to create ActionScript 2. Here is AS3 Drawing App tutorial;

Java CS6 How to convert ai to fla + html + swf using a script

I would like some assistance with batch image processing - I need to save an vector ai image to fla+html+swf file formats using a script - What I have done is to open the software and open a folder with these image's in. Please advise how i can write a script to assist with this process as I have alot of images I have to save.
I need to save it in actionscript 3 and actionscript 2, so if there is a script that convert it from actionscript 3 to actionscipt 2 that can be usefull aswell.
Please help :)
If I understand you correctly, you want to be able to put an image found inside an .AI-file (Adobe Illustrator) and automatically place that image into two newly created .FLA-files (one with AS3 set as default programming language and one set with AS2 as the default programming language)?
There is no quick and easy solution for this, it would require a combination of a "main app (python, c#, java or similar)" combined with "JSFL" to do what you want. And in the end that app would probably become very complex.
If you can skip the requirement of each ai-file becoming a unique fla-file you can just import all the images into a newly created FLA-file. But if that's not an option, then you're most definitely out of luck :\

how to I make my flash AS3 game save progress

I have this flash game that I've been working on that works out of the browser, and I'm looking to get it to save it's progress.
I've seen multiple flash games that have accomplished this, and It appears as though they've done this client-side, and I'd like to do the same.
My game consists of 1 mxml file and a number of .as files and I compile it from the command line using flex sdk.
What do I have to do to be able to save save my game's data?
As others have mentioned, SharedObject is the tool you'll use for this.
The basics of this are to initialize a reference to a SharedObject using its static method .getLocal() first:
var mySaveData:SharedObject = SharedObject.getLocal("SomeSaveName");
The String given to this method should not contain spaces.
Once you've done this, you'll be able to use mySaveData.data, which is basically a simple object that you can attach properties to on the fly (it's dynamic):
mySaveData.data.levelsComplete = 2;
Once you've done this, you'll be able to reference that value later on using the same process:
trace( mySaveData.data.levelsComplete );
For simple stuff you can use SharedObject
One way is to use flash's SharedObject to save values in to a 'flash cookie' on the client. Example can be found here: Actionscript 3 saving currentframe location to local hard drive?

Flex Metadata Compiler Extension in FlashDevelop tutorial

I've been googling around for the past 2 hours looking for some simple instructions on how to add my own custom metadata tag in as3 with no success. I'm starting to think that I'm probably not searching for the correct terms.
The Problem
Ultimately, what I want to do is add a custom metadata on a function that takes a function as a parameter and makes sure that the given function has the correct parameters.
I.e. I have the following function:
public function testCallback(callback:Function):void
{
callback("test");
}
and I want to get a compiler error when I call it like this:
public function doNothing():void
{
// doing nothing
}
public function someRandomFunction():void
// ...
testCallback(doNothing);
}
The way I'm thinking of doing this is by having this metadata:
[Callback(paramName="callback",callbackParams="string")]
public function testCallback(callback:Function):void
{
callback("test");
}
The extension would run during compilation and, if the function passed does not contain the correct parameters, a compile-time error will be thrown. I THINK by using flex2.compiler.util.ThreadLocalToolkit.logError(path, line, errorMessage); I can accomplish this.
The Search
I've been googling for a couple of hours now and couldn't find a simple tutorial that could get me started. I found some SDK bug reports (SDK-18718, SDK-26041), an unfinished forum post, a tutorial (?) on how to add a custom metadata in FlexBuilder (I'm using FlashDevelop), a not-so-useful answer in StackOverflow and many many more dead ends.
The Help
So far, as far as I could understand, I will use Java to create the extension and then, using a compiler command, I'll add it into my project. However, I don't know what do I need to get started.
My two main questions are:
A) What do I need to create the extension in Java? (do I need Flex Builder? Eclipse? what libraries do I need in my classpath?)
B) Once I have compiled this into something (a swc?), how do I include this in FlashDevelop in my AS3 Project?
Thanks in advance!
Update
I've been able to create a Java project in eclipse, add the Flex libraries, implement the IMxmlcExtension interface and compile the project into a jar with the correct MANIFEST file. Unfortunately, adding the extra -extension=MyTest.jar in FlashDevelop, did nothing.
In case it is useful, the resulting command line for the compiler was
mxmlc -load-config+=obj\MyProject.xml -debug=true -incremental=true
-swf-version=10 -extension=flex_test.jar -o obj\MyProject634846490611881374
Update 2
Timofei Davydik helped me narrow down the problem. It seems that FlashDevelop is the main problem. Creating an extension and compiling it in command line works. I started a thread in FlashDeveloper's forums. In case you're interested, the thread is: -extension compiler option
Update 3
Pilippe is correct, it seems that the problem comes from the fact that FlashDevelop uses Flex Compiler SHell (fcsh). I am now looking into how can I switch compilers.
Really interesting question. I've done some research. Yes, we can write mxmlc extensions and add some custom functionality. But processing custom metadata is really complicated, and much time is needed debug and explore flex compiler sources. I've created a post in my blog about extensions, you can check it:
http://tim-davydik.blogspot.com/2012/09/flex-compiler-mxmlc-extensions-forcing.html
How to make meta-data tags work in Action Script
Timofei Davydik's wrote a quick and simple tutorial in his blog to answer my question, named Flex compiler mxmlc extensions. Forcing compiler language, and helped me a bunch to track down what is the problem (which is why I'm giving him the bounty). In his post, he is using Flash Builder and not FlashDevelop, which brings us to the answer of the next question:
How to program them using Flash Develop
Unfortunately, as Phillipe pointed out, for AS3 projects, FlashDevelop uses the Flex Compiler SHell (FCSH), which doesn't support meta-data. Since FlashDevelop is open-source, I'll try (and probably fail) to switch the compiler for testing purposes. For anybody else interested in this, I think this forum post is a good start: [ GIFT ] Try new AS3 compiler (ASC 2.0) in flashDevelop 4.x

The definition of base class ByteArrayAsset was not found

I'm using FlashDevelop4.0.0 RC1 to create AS3 library project, in which I want to import Away3D library. I follow this tutorial to set up my FD.
http://www.mclelun.com/blog/2011/08/flashdevelop-stage3d-away3d/
However, FD generate error message when I use ExportSWC4.2 plugin to compile the project, I got error message said that
at away3d\materials\methods\TerrainDiffuseMethod_NormalizeKernel.as(10): The definition of base class ByteArrayAsset was not found
Can anyone help me with that? Thanks!
p.s.
I also have issue like the following link
http://sourceforge.net/tracker/index.php?func=detail&aid=3401191&group_id=252536&atid=1127375
not sure if it's related to my problem.
Are you downloading the zip package from http://away3d.com/download/ or accessing via SVN / GIT?
http://away3d.com/images/uploads/releases/away3d_4_0_110915.zip
Not sure about their GIT, but I found the SVN repo dated.
I did not see ByteArrayAsset anywhere in the inheritance chain within my version:
away3d.materials.methods.TerrainDiffuseMethod
away3d.materials.methods.BasicDiffuseMethod
away3d.materials.methods.LightingMethodBase
away3d.materials.methods.ShadingMethodBase
mx.core.ByteArrayAsset is an Adobe class.
There's a NormalizeSplats Pixel Bender linkage, but I did not see any Normalize Kernel.
I'd recommend grabbing the Broomstick ZIP package - I had no issues building the SWC with Flash Builder targeting Flash Player 11.