Easy to embed, webcam based barcode scanner in flash.
Lately I have received quite a lot of emails about my barcode scanner. Most of these emails are by people requesting a ready to use version of the scanner. Apparently flash components are not so easy to use as I want them to be.
Therefore for anyone who wants to just put a working scanner on there website I suggest just using the following code:
As you might have noticed it loads the flash file from barcodepedia. The reason for this is that barcodepedia’s scanner will always be updated, such you do not have to update your files manually when a new version is released.
To controle the scanner it supports the following flashvars
- baseUrl - When a barcode is recognized the url specified here will be requested with the barcode attached.
- e1 - Error message given to the user when unsupported version of flash is found.
- e2 - Error message given to the user when no webcam is found.
- e2 - Error message given to the user when user disallows access to the webcam.
The below example and the above code both does a google search for the barcode, when one is scanned.
Example scanner
on February 12th, 2007 at 10:42 pm
thanks a lot for sharing this. I have often wanted something like this but haven’t really known where to start! Thank you very much.
on February 16th, 2007 at 2:58 pm
spooky, I just wondered about something like this in the last few days! Thanks very much for sharing :-)
on June 11th, 2007 at 2:07 pm
Hey, I get the idea, but how does it work?
on October 3rd, 2007 at 1:38 am
Hi, i tested it with Flash Lite 2.1 ( http://labs.adobe.com/wiki/index.php/Flash_Lite_2.1_Authoring)
on my Windows Mobile Smartphone with built in Webcam but i got a error that Flash 8 Content is not supported , and the code may be corrupted.
Using that Flash on my mobile would be very nice. ;-)
regards Oliver
on February 28th, 2008 at 2:02 am
I tried to use this but it just shows “loading” when it sees a barcode and doesn’t go to the site that I want it to go to.
on February 29th, 2008 at 3:37 pm
This app does not work! It only works on the barcodepedia site. Using it anywhere else including this site is not possible. If I copy the swf file to my own server, it automatically redirects to barcodepedia.
on March 4th, 2008 at 3:34 pm
Great, thanks!
Unfortunately, it does not seem to work here (Safari 3 browser or Camino), when a barcode is directed the flash app stays on “loading” but does not redirect me. Really odd, I can’t trace the root of this problem. Even tried copying as much as possible from barcodepedia itself:
http://www.dwizzy.nl/x/thingpedia.html
same result
on April 1st, 2008 at 3:50 pm
This is a great idea, Thanks for sharing! Do you have any resources for code that would enable me to DRAW barcodes (from a number) using either MAC or the iPhone SDK?
on April 24th, 2008 at 4:57 am
This doesn’t work with Flash 9. Apparently 9 doesn’t allow cross-domain redirects. The only solution I’ve found so far is downgrading to version 8.
on May 8th, 2008 at 3:20 am
Hey It works on my site but when it scans something it just says loading and does not do a Google search. Maybe you know how to remedy this? It does the same thing to me on this blog entry.
on May 10th, 2008 at 7:19 pm
OK, maybe I’m stupid, but how do you control where the baseUrl gets loaded? I tried reading the source, but I’m not a flash developer and can’t use the .fla file. When I try to scan a code on this page, the control shows “Loading” and seems to hang. When I scan over at barcodepedia.com, the content loads adjacent to the flash components. I tried reading the page source, but the DIVs are laid out funkily. Do I need something besides the EMBED tag? Thanks!
on May 18th, 2008 at 9:06 pm
I can embed it but when i scan the barcode it doesnt’t redirect me anywhere. Even the code copied directly from the barcodepidia website doesn’t work.
Can you email me back if you know of a fix please :D
on June 10th, 2008 at 8:03 pm
Hi, I tried your code, and somehow after scanning it will just displays “Loading” without actually going to google search… :(
on July 5th, 2008 at 8:52 am
Hello,
Thanks for this but I can’t get it to work. The camera comes up fine, but it doesnt read any barcode I try. I’ve tried it at various positions and black all around the bar code. How do you know if its working ? thanks.
on August 18th, 2008 at 10:12 am
The Flash application stuck after a code bar has been scanner (on Loading), i’m using firefox 3, there is any problems ?
on November 8th, 2008 at 10:31 pm
I can’t seem to get this to work. It works fine on the barcodepedia website but when it scans on here it says loading but doesnt do anything. Shouldnt it load up google?
on November 9th, 2008 at 12:56 am
I was just playing with this, and I can’t get it to recognize any UPC barcodes from books. Is there some reason for that?
on November 28th, 2008 at 10:52 am
can you give me the logic how you made it?
on January 6th, 2009 at 12:40 am
I got very excited about this - but when I tried it locally I got the same as I get here… it reads the bar code- says LOADING and simply sits there, LOADING. Locally I even changed the address to a local one - no difference, just sits there saying LOADING - in both FF3 and IE7
on January 10th, 2009 at 2:48 pm
Hi Im interested in this awesome app, Im trying to get the output to fill a form field but no success.
I also realize that the embed code works in Firefox 3.0.4 but not in IE7
Im very interested in some feedback, thank you for sharing this flash
on January 24th, 2009 at 6:25 pm
The scanner seems to work fine, but due to some cross-site-scripting restrictions (I guess) it needs to be run off my own site. Couldn’t read variables (the javascript refresh) on my home machine, though it worked great on my work machine.
So I downloaded the source files - but how do I edit and compile .swc files? What program to use? I have no experience with Flash whatsoever, but it can’t be that hard, if I only find out what tools to use?
on March 8th, 2009 at 2:03 pm
How do you use the barcode scanner on a Logitech Quickcam webcam?
on April 3rd, 2009 at 12:44 pm
To get the downloadable Version from barcodepedia.com working, add something like:
getURL(_level0.baseUrl + e, “_blank”);
in the Layer 1 / Frame 1 - Actionscript where the trace command is.
You will have to enable cross-site redirects in the Flash Player’s user settings for it to work. If you want to reuse the running movie to open various sites, comment out the stop() in Layer 2 / Frame 2
on April 15th, 2009 at 9:12 pm
It dosn’t work on my Site, the same Prob than Kedare
On Barcodepedia.com it works fine, why?
Here is my test-code:
abc
on April 15th, 2009 at 9:18 pm
?xml version=”1.0″ encoding=”UTF-8″ ?
!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”
html xmlns=”http://www.w3.org/1999/xhtml”
head
title abc /title
/head
body
EMBED src=”http://en.barcodepedia.com/swf/scanner.swf” flashvars=”baseUrl=http://www.google.com/search?q=&e1=Flash+8+required.&e2=No+webcam+found.&e3=Access+to+webcam+disallowed+by+user.” width=”320″ height=”240″
/body
/html
on May 4th, 2009 at 3:27 pm
This problem can be rectified by hosting the flash file on the server where it redirects although when you do this the flash file redirects you to barcodepedia. Could this be changed so that it doesn’t and may be make it so the text in the lower right links to barcodepedia???
on June 2nd, 2009 at 4:40 pm
Hi Chris,
Is it possible for you read QR (2D) barcodes from your code.
Also how much OCR can this do.Do we need to hold the object very close to webcam. I am looking for applications like reading snippets of newspapers etc.
Please write to me.
Thanks
Srini
on September 15th, 2009 at 10:27 pm
What is the reason that the ’scannerdemo.fla’ document (in barcodecomponent1.0.zip) is a ‘Compiled Clip’? So I cannot edit this ‘Library’ in Adobe Flash CS3 Professional.