4 Replies Latest reply on Mar 20, 2014 9:05 AM by gargle256

    Event from C++ to AS3




      I'm porting an Alchemy code to FLASCC, and I have one little question :


      How do you convert "AS3_CallS("handleEncodeCanceled", clientObj, oneArray);" to a flascc compatible code ?


      I've looked in the samples and I see nothing identical.

      Thanks for ideas.




        • 1. Re: Event from C++ to AS3

          That just looks like a function/method call to me, thus I'd think the closest equivalent would be call_v() (it's slightly closer than call() as the former like AS3_CallS() takes an AS3 type array of arguments)


          See: http://www.adobe.com/devnet-docs/flascc/docs/capidocs/as3plusplus.html#call_v

          or see also http://blogs.adobe.com/flascc/2012/12/08/operating-on-actionscript-objects-in-c/ which has an example using call()


          Note: If you must take the function name as a string, you will need to call getproperty()/getlex() (depending on whether it's a global function or a method call) to resolve the function name to an AS3 object to give to call_v()

          • 2. Re: Event from C++ to AS3
            gargle256 Level 1



            thanks for your answer, but it not solve.


            In fact, I create a function "encode" which is used asynchronously in AS3 code.

            In Alchemy, ithey use :

            AS3_Val startAsyncEncodeMethod = AS3_FunctionAsync(NULL, startEncode);

            AS3_Val flashObj = AS3_Object("startAsyncEncode:AS3ValType", startAsyncEncodeMethod);

            I would like to have the same way. How I can do it in flascc ?


            Best regards,


            • 3. Re: Event from C++ to AS3
              chg Level 2

              I don't see how the follow up above relates to the original question which was: "...one little question: How do you convert "AS3_CallS("handleEncodeCanceled", clientObj, oneArray);" to a flascc compatible code ?" It seems like the follow up is a different question altogether (it's frustrating to be told the solution was wrong, because it didn't address matters well outside the scope of the original question).


              As far as I know you can't have FlasCC/CrossBridge produce the kind of code you are looking for in your follow up auto-magically (I'm not 100% certain it doesn't exist some where, just that if it does I don't know of it).


              You can use pthreads (you'll have to target FP 11.4+ for this) for true background processing (refer to the Pthreads sample), or if your up to it you could implement the async processing without thread support (eg. if targetting FP 11.3 or earlier) manually the same as you would have to do in AS3 prior to the addition of threading to the Flash Player (use say setInterval() to call a worker function every, say, 50 milliseconds; each time it's called the worker function does a little bit of work on the problem and checks if it's done, if it isn't done it just returns and waits to be re-called by the timer to continue, if it is done it calls clearInterval() then the completion callback function)


              As for how to make a FlasCC/Crossbridge C function callable from AS3 (if this is part of your followup question?!), have a look at "__attribute__((annotate))" here for example: http://bruce-lab.blogspot.com.au/2012/12/migrating-from-alchemy-to-flascc.html

              • 4. Re: Event from C++ to AS3
                gargle256 Level 1



                sorry to frustrate you.


                the aim is to convert the lib hookogg (http://labs.byhook.com/2011/05/03/alchemy-series-part-6-ogg-vorbis-library-source-release/ in Alchemy) into a flascc lib.


                all the compress code is ok, and run perfectly.


                My AS3 program use the lib asynchronously, so I must convert the lib to be a asynchron function. But, I can't find the way in flascc. (In Alchemy, it's done using AS3_FunctionAsync).


                The other way is to fire the "end" event to AS3, but I'm lost too.


                Do you have any idea ?

                using pthread is not the good way, I can't send the event.


                Thanks for your answer.


                Best regards,