Home > Flex, Flex3, Flex4 > AS3 QR Code Encoder Library

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:

http://github.com/jbpin/as3-qrcode-encoder

Enjoy.

Categories: Flex, Flex3, Flex4 Tags: , , ,
  1. PR Johnny
    03/09/2010 at 03:18 | #1

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

  2. PR Johnny
    03/09/2010 at 23:33 | #2

    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…

    • 04/09/2010 at 17:29 | #3

      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
        05/09/2010 at 04:29 | #4

        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…

      • 05/09/2010 at 13:46 | #5

        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

  3. PR Johnny
    06/09/2010 at 03:59 | #6

    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
    09/09/2010 at 10:51 | #7

    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

    • 09/09/2010 at 11:07 | #8

      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. 06/11/2010 at 09:50 | #9

    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.

    • 06/11/2010 at 10:19 | #10

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

      • 06/11/2010 at 11:50 | #11

        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.

      • 06/11/2010 at 15:01 | #12

        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. 09/11/2010 at 01:15 | #13

    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. 09/11/2010 at 06:24 | #14

    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

  8. 09/11/2010 at 06:34 | #15

    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
    10/11/2010 at 01:41 | #16

    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. 12/11/2010 at 06:31 | #17

    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
    31/01/2011 at 01:23 | #18

    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!!

  12. Rick
    09/02/2011 at 18:22 | #22

    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
    15/02/2011 at 06:13 | #24

    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

    • 15/02/2011 at 08:16 | #25

      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
    15/02/2011 at 10:16 | #26

    “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

  15. mrbbp
    15/02/2011 at 10:50 | #28

    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 :(

  16. mrbbp
    15/02/2011 at 10:55 | #29

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

  17. RANR
    30/03/2011 at 22:40 | #30

    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.

    • 01/04/2011 at 00:34 | #31

      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

      • 24/08/2011 at 22:13 | #32

        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
    09/06/2011 at 02:36 | #33

    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

    • Paul-André Belle-Isle
      09/06/2011 at 03:41 | #34

      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é

  19. 19/10/2011 at 05:08 | #35

    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. 19/10/2011 at 06:11 | #36

    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. Ico Dimchev
    06/02/2012 at 10:15 | #37

    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!

  22. Ico Dimchev
    07/02/2012 at 08:16 | #38

    Here is another experiment made with your library:

    http://burnandbass.com/LettersQR.swf

    Generate QR code from letters….

  1. 29/09/2010 at 19:32 | #1

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.