Haxe - Flash project compiles fine, but won't compile using hxcpp - iphone

In summary, I think my question is this:
How can I force hxcpp to compile haxe code for Flash 8 ?
Here's where I'm at. I'm new to haxe, and am trying to get a sample from here:
http://tilestudio.sourceforge.net/flash/Demo.html
to compile using hxcpp, in my tests to see how haxe compiled apps work on the iphone.
I've gotten other samples to compile fine and put them on the iphone, but when I compile this sample, it complains with things like:
Demo.hx:32: characters 17-53 : Class not found : flash.MovieClip
Demo.hx:42: characters 20-36 : Class not found : flash.Key
Demo.hx:44: characters 43-60 : Class not found : flash.Stage
and as I mentioned, this compiles fine using the following hxml file (flash.hxml):
-swf Demo.swf
-swf-lib DemoRes.swf
-main Demo.hx
-swf-header 480:320:100:808080
but fails as detailed above using this (cpp.hxml):
-main Demo.hx
-lib nme
-lib neash
-swf-lib DemoRes.swf
--remap neko:cpp
--remap flash:neash
-cpp cpp
So I think the problem is that hxcpp is targeting Flash version 9 swf's, and the haxe code is targetting Flash 8. I tried forcing it to accept Flash 8 syntax using "-swf-version 8" but it doesn't work (gives the same errors).

Although Neash is quite complete I am not sure it does map 100% of the Flash API. That said you have for sure a problem with -swf-lib that will not work with Neash; that beacuse it is not possible to embed swf files in other platforms than flash. You have to manage your assets differently.
Maybe in a not so distant future it will be possible to embed even swf resources, but first someone has to write a nice decompiler that transform them for the intended target.

I asked Hugh, the guy behind the hxcpp compiler part of Haxe that's doing all the haxe / iphone / hxcpp stuff, and he basically said that Flash 8 isn't an available target for hxcpp, just Flash 9 and up.... Thanks for the response Hugh!
http://gamehaxe.com/2009/08/17/switched-to-immix-for-internal-garbage-collection/#comment-309

Related

Compiler error when using AlwaysRightInstitute/SwiftSockets

I'm try to write a small game on IOS using socket and I've had a java socket server running with Flash client, but I got complier errors when I add the AlwaysRightInstitute/SwiftSockets source code to my swift project, and I did nothing after doing this
Here is the project structure:
the selected group "ARISockets" is the source code I drag into my project
and here are the errors(Use of unresolved identifier 'ari_fcntIVi'):
It seems that the errors cause by lack of some import file and I found "ari_fcntIVi" in ARISockets/UnixBridge.c,but I'm a really newer to Swift/Objective-C/C (I'm a AS3 developer), so that sucks me :/
I had the same problem with this library.
You need to create a Bridge file similar to "Import Objective-C into Swift" but this is C:
How to call Objective-C code from Swift
The issue was that you just copied over the sources instead of embedding the SwiftSockets framework. The ari_ prefixed functions used to required the bridging header of the SwiftSockets framework.
Having said that, the current SwiftSockets doesn't use bridging headers anymore, and you can directly embed the sources.

I need help on accessing address book in Flash Builder 4.6 - Win 7

Hey guys so I am trying to dev a app for IPhone and am very very stumped right now. I have tried using Contact Editor - ANE (http://extensionsforair.com/extensions/contact-editor/#comment-7488) but I get an error:
VerifyError: Error #1014: Class pl.mllr.extensions.contactEditor::ContactEditor could not be found.
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
I made sure I included the correct file path under the ActionScript Build Path, besides that I don't know what else I can do. I do get the function like ContactsSimpe() function that hints when looking for a function. So I know it is connecting but once I go to compile and test in the flash pro I get this error. Here is some code that may help:
code....
import pl.mllr.extensions.contactEditor.ContactEditor;
public class soscode extends MovieClip {
var contactEditor:ContactEditor;
public function soscode() {
stop();
init();
contactEditor.getContacts();
}
code...
in my project window on left the .swc file for the native extension is in the reference folder. That is about it.
I really need some help on this an if you could give me a hand I would much appreciate it!
David,
Please let me know if you need anything else.
I'm guessing this might be a bit late now, but I've just been having this problem myself, and it was caused by the ANE not being packaged with the app when it's sent to the device / simulator.
Classes within the NE weren't being found at runtime, but were accessible in Flash Builder.
It turned out that by default the .ANE file wasn't copied to the device.
To fix this, change the following project property:
ActionScript Build Packaging -> Apple iOS -> Native Extensions -> Check 'Package' for the ANE
No idea why it wasn't included by default. When you uncheck 'Package' you get a warning telling you that it may cause runtime issues!
Hope this is of use for somebody.

libphonenumber for iOS or objective-c port

My goal is to use libphonenumber, google's phone number handling library for an iPhone project I'm working on.
After downloading it (and many many hours), I complied the C++ version of the library, and it built a number ".a" files and ".dylib" files, of which I assumed I must import into my xCodeProject in order to access those C++ functions.
So I imported "libphonenumber.a" into my project, updated my target, build settings, build phases, and Library Search Paths as needed.
Building the xCode project for Device & Simulator pass, however give me the following warning:
"ld: warning: ignoring file ../XcodeProjects/libphonenumber/build/libphonenumber.dylib, file was built for unsupported file format which is not the architecture being linked (armv7)". (or i386 when compiling for simulator)
I understand from this that I must compile the libphonenumber for the correct i386 and/or armv7 architecture. So I tried to do that, but quickly realized this requires me to also rebuild libphonenumber's 3 dependent libraries as well, for the i386/armv7 architectures in order for libphonenumber's to now properly compile. Eventually, I gave up on that, it started to look like a big mess ahead of me.
After all my trials, I'm left with
3 Questions:
1) How to I compile libphonenumber C++ library for use with i386/armv6/armv7 architectures.
2) When using a c++ library, is my assumption correct? Is it a matter of simply importing the ".a" file that results from the compilation, and just point to it in the header of my xCode project files? What exactly are the steps for including and using c++ libraries and accessing their functions from objective-c inside xCode?
3) I did find LPNKit, an objective-c port for libphonenumber, however it is incomplete. Has anyone heard of it, and had any luck using it? Or does anyone have an objective-c port for libphonenumber that is complete, working, with instructions on how to compile and install it correctly?
Any help or advice on how to get this library working on iOS would be greatly appreciated.
Update:
I ended up using the javascript version of libphonenumber, adding all the files to my bundle, including all referenced javascript libraries and using UIWebview and stringByEvaluatingJavaScriptFromString to run functions. You could also have the UIWebview reference the javascript library online (I just preferred to have everything local as not to depend on an internet connection).
Here is a sample of what I did:
webView_ = [[UIWebView alloc] init];
[webView_ loadHTMLString:
#"<script src='base.js'></script>"
"<script>"
"goog.require('goog.dom');"
"goog.require('goog.json');"
"goog.require('goog.proto2.ObjectSerializer');"
"goog.require('goog.string.StringBuffer');"
"</script>"
"<script src=\"phonemetadata.pb.js\"></script>"
"<script src=\"phonenumber.pb.js\"></script>"
"<script src=\"metadata.js\"></script>"
"<script src=\"phonenumberutil.js\"></script>"
"<script src=\"asyoutypeformatter.js\"></script>"
"<script src=\"normalize.js\"></script>"
baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]]];
NSString *function = [[NSString alloc] initWithFormat: #"phoneNumberParser('%#','%#','')", phoneNumber, ISOCountryCode];
NSLog(#"function is: %#", function);
NSString *result =[webView_ stringByEvaluatingJavaScriptFromString:function];
The result variable gets me the formatted number.
I hope that helps anyone who ran into the same issue I did.
It has been ported by our team.
You can find it https://github.com/me2day/libPhoneNumber-iOS
Just note that libphonenumber Javascript library includes Google's closure library.
So you should consider, wrapping your Javascript call in a Javascript object and then compile it using closure builder in order to get an efficient and light weight script. (closure library before compilation : 18Mb, after compilation 300Kb !)
See above a sample of such a wrapper
goog.provide('sphone.phonenumber');
goog.require('goog.dom');
goog.require('goog.json');
goog.require('goog.proto2.ObjectSerializer');
goog.require('goog.array');
goog.require('goog.proto2.PbLiteSerializer');
goog.require('goog.string');
goog.require('goog.proto2.Message');
goog.require('goog.string.StringBuffer');
goog.require('i18n.phonenumbers.NumberFormat');
goog.require('i18n.phonenumbers.PhoneNumber');
goog.require('i18n.phonenumbers.PhoneNumberUtil');
sphone.phonenumber = function(phoneNumber, regionCode) {
this.getCountryCallCode=phonenumberGetCountryCallCode;
};
function phonenumberGetCountryCallCode(phoneNumber, regionCode) {
var phoneUtil = i18n.phonenumbers.PhoneNumberUtil.getInstance();
var number = phoneUtil.parseAndKeepRawInput(phoneNumber, regionCode);
return number.getCountryCode();
};
// Ensures the symbol will be visible after compiler renaming.
goog.exportSymbol('sphone.phonenumber', sphone.phonenumber);
1) Fix all the errors and re-compile all the dependencies for arm. As you said before.
2) Yes. According to kstenerud’s iOS-Universal-Framework
Using an iOS Framework
iOS frameworks are basically the same as regular dynamic Mac OS X frameworks, except they are statically linked.
To add a framework to your project, simply drag it into your project. When including headers from your framework, remember to use angle bracket syntax rather than quotes.
For example, with framework "MyFramework":
#import <MyFramework/MyClass.h>
This question Importing an external library in xcode - C++ follows like this: Import C++ library, use it, get errors from its dependency on built-in frameworks, import those built-in frameworks, everything works.
3) I would invest in LPNKit instead of fighting your way through option 1. You can both contribute and benefit from LPNKit. GitHub is a wonderful place and the great boost of this over option 1 is that you have another person (or people!) who have the same goal and will all work together to achieve it.

Soundtouch bpm iPhone

I'm trying to integrate a mechanism to calculate the BPM of the song in the iPod library(also on iphone).
Searching on the web I found that the most used and reliable libraries to do this things is soundtouch.Anyone has experience with this library? It is computationally possible to make it run on the iPhone hardware?
I have recently been using the code from the BPMDetect class of the soundtouch library succesfully. Initially compiled it on C++, later on translated the code to C# and lately I've been using the C++ code on an Android app through JNI. I'm not really familiar with development in iOS but I'm almost certain that it is possible what you're trying to do.
The only files you should use from the soundtouch source code are the following:
C++ files
BPMDetect.cpp
FIFOSampleBuffer.cpp
PeakFinder.cpp
Header files
BPMDetect.h
FIFOSampleBuffer.h
FIFOSamplePipe.h
PeakFinder.h
soundtouch_config.h
STTypes.h
At least these are the only ones I had to use to make it work.
The BPMDetect class recieves raw samples through its inputSamples() method, it's capable of calculating a bpm value even when the whole file is not yet loaded into its buffer. I have found that these intermediate values differ from the one obtained once the whole file is loaded, which is more accurate, in my experience.
Hope this helps.
EDIT:
It's a kind of complex process to explain in a comment so I'm going to edit the answer.
The gist of it is that you need your android app to consume native code. In order to do that, you need to compile the files listed above from the soundtouch library with the Android NDK toolset.
That will leave you with native code that will be able to process raw sound data, but you still need to get the data from the sound file, which you can do several ways, I think. The way I was doing it was using the FMOD library for Android, here's a nice example for that: FMOD for Android.
Supposing you declared a method like this in your C code:
void Java_your_package_YourClassName_cPlay(JNIEnv *env, jobject thiz)
{
sound->play();
}
On the Android app you use your native methods in the following way:
public class Sound {
// Native method declaration
private native void cPlay();
public void play()
{
cPlay();
}
}
In order to have a friendlier API to work with you can create wrappers around these function calls.
I put the native C code I was using in a gist here.
Hope this helps.

Flash XFL to iOS/XCODE/Interfacebuilder

I am thinking of starting an ambitious project of writing some type of converter to convert the new Flash CS5 XFL format to some type of iOS readable format for building pages. A lot of what I do convert old Flash course over to native applications. They are usually very simple with some basic animations. Some are more complicated than others, obviously.
1) I recently found the XFL format and was wondering if anyone was doing this type of conversion?
2) Has adobe published this file specs yet? I haven't been able to find them, yet.
3) Is this even possible? Has anyone tried and been unsuccessful or would like to work together on this?
I thought of this and wonder if it is a good idea that we insert the code directly in the flash file. That means the tool is written in ActionScript, for example a utility class called SceneExporter. When you want to export a MovieClip, extends it with SceneExporter and when the Flash file runs, it exports the content of that MovieClip to a objective C code text file. Not professional way, but it should work since we have access to all child elements of that MovieClip.