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 :

QR Code generator

You can download the source code (library and generator) from my github:


Tagged , , ,

52 thoughts on “AS3 QR Code Encoder Library

  1. PR Johnny says:

    Any suggestions on how to get this to work in the Flash IDE?
    Thanks in advance.

  2. PR Johnny says:

    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 😉

      • PR Johnny says:

        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.


  3. PR Johnny says:

    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.

  4. PR Johnny says:

    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.

    • 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

  5. noel says:

    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\, 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 In fact, it could be just an error of parameter, or just an error of configuration. Let me know 😉

      • noel says:

        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();
        var img:Bitmap = new Bitmap(qr.bitmapData);



        I did some research and Senocular pointed out some sort of work around.. However, I am not sure how to implement it.

        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 ?

  6. noel says:

    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.

  7. noel says:

    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\, Line 8 1172: Definition spark.primitives:Rect could not be found.

    \org\qrcode\, 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

  8. noel says:

    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.

  9. PR Johnny says:

    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…

  10. noel says:

    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!

  11. jordi says:


    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:




    … but I can’t make it work. Can it be done with your library?

    Thank you and congratulations for a great work!!

  12. Rick says:

    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

  13. mrbbp says:


    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/, ligne 29 1047 : Initialiseur de paramètre inconnu, ou ce n’est pas une constante de compilation.

    Where i fail


    • 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 😉

  14. mrbbp says:

    “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? :°


  15. mrbbp says:

    I’m definitively an hasshole.
    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.
    Hate Adobe and their unfinished software 😦

  16. mrbbp says:

    wich packages in my sourcepath (in as3) not classpath (for as2) [adobe syntax… sorry] ?

  17. RANR says:

    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.


      • Dakular says:

        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 😦

  18. Paul-André Belle-Isle says:

    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).


    Thx in advance for any help you can give me 😉


    Paul-André Belle-Isle

    • Paul-André Belle-Isle says:

      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 😉



  19. Charles says:

    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.

  20. Charles says:

    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.

  21. david says:

    sir you cant trust that how glad i am after visiting this website….:) i was looking for a qr genratore in Flash from last 2months for my college project…i know flash but i have no idea how to run these files on sir will you help me?? ..or guide me to run these file in flash..ill be very glad and thankful to you sir…thank you advance..:):)

  22. Wolfgang Hamann says:

    Hi Jean-Baptiste,

    while I was playing with this fine library, I encountered similar error as Paul-Andre mentioned above. It seems that this code – near line 80
    for(i=0; i<QRSpecs.rsBlockNum2(spec); i++) {
    ecc = this.ecccode.slice(eccPos);
    this.rsblocks.push(new QRRsBlock(dl, this.datacode.slice(dataPos), el, ecc, rs),blockNo);
    is pushing QRRsBlock and Number types alternatingly. At first glance it should work by omitting the blockNo



  23. Ico Dimchev says:

    Hi man; se what I did:
    this is pretty cool AS3 library thank you very much for it!

  24. Ico Dimchev says:

    Here is another experiment made with your library:

    Generate QR code from letters….

  25. Konstantin Demblin says:

    Hi Jean-Baptiste,
    thank you for your great API. Do you have a hint where to start in your code when trying to add special chatacter support (utf-8 etc.)? – I guess you are still busy with more important stuff, right?
    And do you have a recommendation where to start reading in the internet about this issue?
    BR, Konstantin

    • Hi Konstantin,

      Thank for your interest. Actually, I didn’t plan to implement this stuff yet. Sorry I don’t know what could help you. All the source code is available and you can still make a pull request 😉


  26. Dimitris says:

    thanks a lot for this library.

    I’m using it in a project recently for a tickets application but the weird thing is that the qrcodes that are generated from my app aren’t readable from some qrcode readers from iphone that i tried. although they are readable using this qrreader library (

    What’s even weird is that the qrcodes that get generated from your own example in this post are perfectly readable… Just the ones that are generated from my app.

    I followed the code from your example still no luck. what I might be doing wrong?


  27. Tony Downey says:

    Jean Baptise: I found the cause of the error, described by Paul-Andre, Charles, and others: ArrayCollection uses addItemAt(value,int) and Array just uses push(value). You got all but the one (currently) on line 106 or

    The changes are here for your reference:

    Thanks! This lib is so quick to encode!

  28. Nate says:

    I wanted to use this in an air application built using flash cs5, but your library throws a lot of errors. First was the Parameter initializer unknown or is not a compile-time constant errors which I solved by changing the variables to 0 and 2. But now I get 23 duplicate variable errors and one “, Line 97 Warning: 1106: Empty statement found where block of code expected. Did you type ‘;’ accidentally?”

    I was thinking this is just old code that wasn’t kept up but I see you’re still replying to comments. Is there a newer/fresher code out there?

  29. Nate says:

    After looking through everything I updated the code and eliminated the errors. Let me know if you’d like it so the buggy stuff can be replaced.

  30. Hi, Jean-Baptiste PIN.

    First of all, thanks for your great work.

    I’m using your QRCode library in Flash CS5.5 and i’m afraid i’m having the same problem of Noel (previous comments):
    “\org\qrcode\, Line 29 1047: Parameter initializer unknown or is not a compile-time constant.”

    I guess that some kind of appropriate solution may be something like the workaround explained here:

    But i’ve decided to hack your library in the fastest direction, like this:
    “public function QRCode(errorLevel:int = 0, encodeType:int = 2)” in line 29

    Then i got the following error:
    “\org\qrcode\input\, Line 16 1047: Parameter initializer unknown or is not a compile-time constant.”

    So, i did the trick again:
    “public function QRInput(qrversion:int = 0, qrlevel:int = 0)” in line 16

    Then, i got the same two errors, like Noel again:
    “\org\qrcode\, Line 8 1172: Definition spark.primitives:Rect could not be found.
    \org\qrcode\, Line 9 1172: Definition spark.utils:BitmapUtil could not be found.”

    So, i did the final “hack” like this in your (lines 8 and 9);
    “//import spark.primitives.Rect;
    //import spark.utils.BitmapUtil;”

    And your library finally works in Flash CS5.5, but showing a lot of warnings (like in Noel’s case).

    Do you need my example source files to take a look at this issue?

    Thanks again, and regards from Spain.

  31. Piet van der Wal says:

    Great SWC! Thanks very much!

  32. SergeiK says:

    Hi All,

    We are trying to compile this source code .as in Flex Builder 1.5, but it doesn’t working (

    Is anybody knowing some component for offline QR-code generation ready to use in Flex 1.5?

    Many thanks!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: