Using paper.js, project.exportSVG({asString: true}) returns an SVGSVGElement instead of a string. Did I write this code wrong?
Try again with the latest nightly build. This should work now in all situations.
Related
I built sqlcipher with mingw.
I wanted to access sqlite(DB) encrypted in mfc(C++).
So, sqlite3_open () was applied correctly. but, sqlite3_open() did not return a result, so I wanted to use sqlite3_key().
When using sqlite3_key(), sqlite3_key() is not defined.
How do I use sqlite3_key()? Or how do I activate sqlite3_key() function?
sqlite3_open(...) will return a result code. If you are not receiving SQLITE_OK as a result, you may wish to investigate the error code with sqlite3_errcode(...) Alternatively, you might review your build process to make sure everything is compiling properly.
To distinguish between development mode and production mode in react native there is the __DEV__ constant defined, when Debug = True.
Is there a similar constant defined, that lets me know within the code, if the code is running on the device or in the simulator?
Where else could I get this kind of information from.
You can use this package, then just do :
console.log(DeviceInfo.getModel()); // it returns 'Simulator'
Since G. Hamaide's answer was posted, the DeviceInfo package has added the method isEmulator.
DeviceInfo.isEmulator()
there's a caveat here, DeviceInfo.isEmulator() returns a promise, so if you use if(DeviceInfo.isEmulator()), it'll return true even if running on a real device.
Use DeviceInfo.isEmulatorSync() or if(await DeviceInfo.isEmulator()).
I am starting to use Parse and in the documentation it has examples to use the PFObject as an NSDitionary like this:
// Create the post
PFObject *myPost = [PFObject objectWithClassName:#"Post"];
myPost[#"title"] = #"I'm Hungry";
but i am getting a compiler error:
"Expected method to write dictionary element not found on object of type "PFObject"
But if I access the myPost PFObject like this, it works:
[myPost setObject:#"I'm Hungry" forKey:#"title"];
What is the problem?
I though that PFObject could be accesses as a dictionary?
thanks
I would check that you are using the latest version of the Parse SDK. This is new functionality and my guess is you haven't downloaded the SDK since this feature was introduced.
when i try your code at my side it gives me success message. I think you are using old parse library.
Thanks.
Downloading latest XCode should help. Subscript syntax is available from Xcode 4.4+
In AS3 you can pass a constant to the compiler
-define+=CONFIG::DEBUG,true
And use it for conditional compilation like so:
CONFIG::DEBUG {
trace("This only gets compiled when debug is true.");
}
I'm looking for something like #ifndef so I can negate the value of debug and use it to conditionally add release code. The only solution I've found so far was in the conditional compilation documentation at adobe and since my debug and release configurations are mutually exclusive I don't like the idea of having both DEBUG and RELEASE constants.
Also, this format works, but I'm assuming that it's running the check at runtime which is not what I want:
if (CONFIG::DEBUG) {
//debug stuff
}
else {
//release stuff
}
I also considered doing something like this but it's still not the elegant solution I was hoping for:
-define+=CONFIG::DEBUG,true -define+=CONFIG::RELEASE,!CONFIG::DEBUG
Thanks in advance :)
This works fine and will strip out code that won't run:
if (CONFIG::DEBUG) {
//debug stuff
}
else {
//release stuff
}
BUT this will be evaluated at runtime:
if (!CONFIG::DEBUG) {
//release stuff
}
else {
//debug stuff
}
mxmlc apparently can only evaluate a literal Boolean, and not any kind of expression, including a simple not.
Use the if / else construct : the dead code will be removed by the compiler and it will not be tested at runtime. You will have only one version of your code in your swf.
If you are not sure use a decompiler or a dump tool to see what really happens.
http://apparat.googlecode.com/files/dump.zip
http://www.swftools.org/
...
While Patrick's answer fulfills the question's criteria, it does not cover all use cases. If you are in an area of code that allows you to use an if/else statement then this is a good answer. But if you are in a place where you cannot then you will need a better solution. For example, you may want to do something like this to declare a constant in a class:
private var server:String = "http://localhost/mystagingenvironment";
or for a live release:
private var server:String = "http://productionserver.com";
(this is an example and I'm not advocating this as production code).
I use xml configs and use the loadConfig+="myconfig.xml" to do my configuration instead of passing large numbers of command line params. So in the <compiler> section of your xml config:
<define>
<name>CONFIG::debug</name>
<value>false</value>
</define>
<define>
<name>CONFIG::release</name>
<value>!CONFIG::debug</value>
</define>
This works well for all use cases:
CONFIG::debug
{
private var server:String = "http://localhost/mystagingenvironment";
}
CONFIG::release
{
private var server:String = "http://productionserver.com";
}
This has the additional benefit of working consistently across applications. It also does not rely on the 'optimize' flag being true, like Patrick's answer (although I think we can assume that 99.999999% of all swfs have optimize=true, I only set it to false when the optimizer breaks my AS3).
It does have the drawback that it doesn't compile all code paths, just the ones that are included. So if you're not using a build server to create release builds and tell you when things break, be prepared for surprise errors when you do your release build ("But it compiled in debug! Crap, I need this to launch now!").
Just my two cents about Chris Hill's answer (which is the solution I also use regularly): it seems that using the loadConfig+="myconfig.xml" option makes the compiler searching for the myconfig.xml file in the Flex SDK directory whereas the -load-config+=myconfig.xml option makes it searching for the myconfig.xml file in the project's directory, which is the behavior I strongly prefer as you can then easily distribute this file with your project sources...
The following code produces a failed test, not a passing test (as I would expect):
[Test(expects="Error")]
public function someTest():void {
throw Error("this test doesn't pass");
}
In older versions it was [Test(expected='')]
In newer versions we support both expected and expects as this was confusing for many
Make sure you're linking against the release SWC of FlexUnit, or if you're compiling it yourself, make sure you're using --keep-as3-metadata+=Test in the "additional compiler options" box in project properties.
I think the problem may have been that I was using an older version of FlexUnit4. I just upgraded (to 4.0 RC1) and it seems to be working now.