AS3 QR Code Encoder Library
That was a project I want to do for a while. And finally is not really perfect but is a beginning.. it working not too bad and you can really create a qr code with all you know about it (Tel, SMS, link, vCard …).
It’s an adaptation of the famous qrencode lib from Kentaro Fukuchi. I found the ZXing project and I tried to generate a qrcode with it, but was not good and not readable as well.
I have create a demo application :
You can download the source code (library and generator) from my github:
http://github.com/jbpin/as3-qrcode-encoder
Enjoy.

Any suggestions on how to get this to work in the Flash IDE?
Thanks in advance.
Thanks for your time in recoding this library to AS3. I have been having problems with my QR Code e-learning app getting server responses from Google Charts when deployed online. Would be really sweet to be able to generate a QRC locally. Is it possible to adapt this to work in the Flash IDE? Thanks again for your efforts…
Hi Johnny,
Thanks you for your comments..
Could you explain me your problem and what is flash IDE.. Sorry but I don’t understand your request. If I can help you, that will be with pleasure
Hope all is well after the earthquake.
I work primarily in the Flash CS5 authoring enviroment as opposed to the Flex authoring enviroment. Your AS3 source references mx libraries which are unavailble in the Flash CS5 tool. ArrayCollection,for example, throws a 1046 error at compile time. My basic question – is there an easy way to adapt your classes for a non-Flex authoring tool(Flash CS5)? Thanks for your time…
Hi Johnny,
All is ok around Wellington thanks you
Regarding the library, I just update it today to support Flash. In fact, you are right, MX package is not accessible in Flash and I modified the code. You can now use the library with both, Flash and Flex. I added an example for Flash in the readme file.
Just remember, is a alpha build, is working for lot of QRCode but if you play with the error level and too much data, you could have some surprise… Let me know if I can do something else to improve it, currently I don’t have many time for my personal project, as you can see on my blog… no new post for a while.
Thanks,
Jb
Thank you so much Jean-Baptiste PIN – that worked beautifully! I will let you know when I get my app deployed online and you can view my usage of your class. I am glad to hear you were not affected by the earthquake. Thank you once again.
Jean-Baptiste,
Here is a link to my blog post regarding my QR Code application. I used your AS3 class in the “create” section. Thanks again for making your QR Code encoder library available. http://www.pj-i.com/Blog/?p=1123
Hi Johnny,
Thanks for the link and for the foot note, it’s a really cool applications. I used my iphone for testing during the development phase and I can recommand you MAAD qr for iphone it’s a really good application
Hope you enjoy it
Cheers. JB
Hello. Thanks for sharing this QRCode Generator. I am having a few problems with implementation however… I am using it on Flash CS5, not flashbuilder…. is that an issue? I keep on getting the error below. Please help.
thanks!
\org\qrcode\QRCode.as, Line 31 1047: Parameter initializer unknown or is not a compile-time constant.
Hi Noel. Thanks for your comment and your interest. In fact, I can’t understand your error without see your code and your environment sets. Did you include every files on your project or just QRCode.as? In fact, it could be just an error of parameter, or just an error of configuration. Let me know
I was implementing it into a project and had the issue but I decided to see if I can replicate the issue from a fresh file.
(flash 10, CS5, AS3)
Within the new flash file I copied your example code below from github.
import flash.display.Sprite;
import org.qrcode.QRCode;
import flash.display.Bitmap;
var sp:Sprite = new Sprite();
var qr:QRCode = new QRCode();
qr.encode(“TEST”);
var img:Bitmap = new Bitmap(qr.bitmapData);
sp.addChild(img);
addChild(sp);
I did some research and Senocular pointed out some sort of work around.. However, I am not sure how to implement it.
http://www.senocular.com/?entry=791
Thanks again.
The response is in your answer.. look
“Compiling with ASC directly gives you control over the order of the classes being compiled. When compiling a SWF with something like Adobe Flash Professional, that tool controls the order, sending it to ASC in the background. Logic dictates this order – logic heavily dependant on a dependency analysis of the classes that are to be compiled. This analysis determines what classes are required to be compiled before others. This is done for namespace definitions as well for class inheritance, where superclass definitions need to exist before their subclasses.”
So, have you insert in your class path the package org.qrcode.enum ?
do you mean like below?
import org.qrcode.enum.*;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.utils.Dictionary;
Still having the same error.
Got passed the error, but I had to modify some of your classes… using the examples provided by senocular. (I made your classes extentions of dictionary… not sure if that is correct though) But getting a new set of errors.
\org\qrcode\QRImage.as, Line 8 1172: Definition spark.primitives:Rect could not be found.
\org\qrcode\QRImage.as, Line 9 1172: Definition spark.utils:BitmapUtil could not be found.
Am I using the right library or am I using the Flex 4 library?
thanks again for all the help
Ok… sorry for all the comments.
I basically commented out the imports
//import spark.primitives.Rect;
//import spark.utils.BitmapUtil;
It is working… however I have a ton of warnings for duplicate definitions. Is this expected? I think I will go ahead and use it anyway since none of the errors are show stoppers.
If you have time please let me know if the warnings are expected… again… thanks a lot for sharing your QRCode encoder.
Sounds like you are using the Flex library with its mx / spark component framework. JP-Bins rewrote a Flash CS5 compatible version that I had success with – you may to try that version…
I couldn’t find the CS5 compatible version.
I got rid of all the warnings. It seems that there are a lot of redeclaration of values… for example
var i:Number and var j:Number are declared several times in the same class.
I fixed those and I no longer have errors. spark doesn’t seem to be used… anyway got it working… thanks!
Size¿?
Hi! I’m trying to use your library on a flash animation and it works awesome!!
I’m trying to resize/scale the object to make a bigger QR by something like:
sp.width:100;
OR
sp.scaleX:120;
… but I can’t make it work. Can it be done with your library?
Thank you and congratulations for a great work!!
Hi Jordi,
To resize the content you can use the transformation matrix of your object.
Thanks to using the library.
Jb
We are done. How do you like it?
http://www.qrplanet.com/clock/
I love it
And thank you for the link.
do know hove to encode qrcode in vc++(mfc)?if you know or if you know free samples or library it would be a big help…
thanks in advance
No Rick, sorry I don’t know
But you can use Flex or Flash
Hello,
I’ve tried the exemple with Flash CS5, but I’ve got the same previously error
in french:
/Users/ercho/Documents/boulots/projet friction/org/qrcode/QRCode.as, ligne 29 1047 : Initialiseur de paramètre inconnu, ou ce n’est pas une constante de compilation.
Where i fail
regards
Hi Eric,
You got an error in french due to you use a french OS to compile your code. Did you import all the packages on your classpath ? Sometimes, this error happen when there is a misconfiguration of your classpath and the compiler can’t find the enum package. It looks like the same problem of Noel.
Let me know
“Did you import all the packages on your classpath ?”
Huuuuuuuue, Houlaaaaaaaa, kekidit ?
Sorry, i do not understand what you mean by this short and really frustrating sentence !
Im’ coding with Flash cause Flash is for “Stupid Graphic Designer” with an hungry of code…but never touch to this esoteric part of the prefs…
an exemple may be? :°
regards
sure
http://help.adobe.com/en_US/flash/cs/using/WS3e7c64e37a1d85e1e229110db38dec34-7fa4a.html#WSB1F410E6-F7BD-443a-97E7-13DE866CA732
I’m definitively an hasshole.
Sorry
I do not understand. too much parameters, and my english level doesn’t help.
It’s certainly a super Class, but enable to configure properly.
grrrrrrrr
Hate Adobe and their unfinished software
wich packages in my sourcepath (in as3) not classpath (for as2) [adobe syntax... sorry] ?
Hi,
i notice that the QR code doesn’t work with the following language:
Hebrew, Arabic, Russian , Chinese.
there is a way to change the code in order that it will support the above language.
i appreciate if you can guide me.
Hi,
Yes I think you got true. I don’t know if the qrcode specs handle this question and unfortunately I don’t have time to work on this. You can easly change the code who is available on github. There is normally a way to encode Kanji/Kana so maybe you can adapt it.
Regards,
Jb
Thank you for this excellent library, and I wish it would support other character set someday. I tried to modify your code, but I failed, it’s too difficult
i got a strange error.. it’s working.. then i add one character. and it’s not anymore.. i add 2-3 more and it work!!!! i just don’t get it as it work with your demo and flex ( i use FLASH cs5 ). Maybe it’s in the change for array collections ? here the error :
ReferenceError: Error #1069: Property data not found on Number and there is no default value.
at org.qrcode.encode::QRRawCode/getCode()
And that is the String of text i try to encode (it’s just random character lol).
test;fjasdkl;fjlsda;fjsdkjjkjlkj;lkjljkkljlkj;llkj;lkjl;kjljlkjljk;lkjlkjkljlklkjlkkjljlkjjlkjfytfdyfyffjhgfhjlfkhgfhjhgfitfyftest;fjasdkl;fjlsda;fjsdkjjkjlkj;lkjljkkljlkj;llkj;lkjl;kjljlkjljktehjhhjkkjhkjhjkhkhgfhjffhjgffty7fjgffyitfhkgft
Thx in advance for any help you can give me
Regards,
Paul-André Belle-Isle
Just to tell you that i took your last version with ArrayCollection and added framework.swc to my flash and it’s working fine now.. so it’s really a problem with your change in array in the function getCode
Regards,
Paul-André
I experienced a similar issue as Paul-Andre Bell-Isle. In my case there was a roughly 571 character limit. If I added more chars than that, it would throw the same error about property data not found on Number.
I reverted back to the Aug 7 2010 version that includes ArrayCollection and it resolved my issue as well. I was using FlashBuilder 4.5 in a pure AS3 AIR project so I had to add a reference to the flex framework.swc as well. I also had localization errors after adding farmework.swc so I had to also add framework_rb.swc from the en-US locale.
Thanks for the neat library.
I also can confirm that this port doesn’t leak memory in AIR 2.6; at least the Aug. 7 2010 version of the swc. I wrote a few tests that generate thousands of codes over several minutes with different random strings of data.
Great work.
Hi man; se what I did:
http://burnandbass.com/qrclock/
http://burnandbass.com/SimpleQRGenerator.swf
this is pretty cool AS3 library thank you very much for it!
Here is another experiment made with your library:
http://burnandbass.com/LettersQR.swf
Generate QR code from letters….