Wireless barcode scanner and AS3

Hi

im having a bit of an issue, as i am new to Action Script 3 so im not sure how i can go about this incoming byte issue.
i have a barcode scanner shield connected to one of my arduino unos which also has a xbee connected to it, it also has a extra switch which will be used to send a byte of 5 over. I then have another arduino uno connected to the computer which also has a xbee connected to it. i will paste the code below the scanner is the sender and the other uno is the receiver.

Sender :

const int BeeperPin = 11;      // piezo beeper pin
byte serialin; // Serial data read in
byte linefeed=0; // for appending a linfeed so each barcode is on a new line
const int buttonPin = 8;

int buttonState = 0; 
  
void setup() // standard arduino setup initializing loop
{
  pinMode(BeeperPin, OUTPUT);   // initialize Beeper output
  tone(BeeperPin,2500,50); // beep at 2.5kHz for 20ms    
  delay(100);
  tone(BeeperPin,2500,50); // beep at 2.5kHz for 20ms    
  pinMode(buttonPin, INPUT);
  Serial.begin(9600); // initialize the serial communication to 9600 baud
 
}

// Note that the barcode is aimed and triggered by a hardware switch
void loop() // standard arduino loop
{
  
  buttonState = digitalRead(buttonPin);
  
  while (Serial.available()) {   // check for data from barcode scanner
    serialin = Serial.read(); // read in barcode character at 9600 baud
   Serial.write(serialin);
    delay(10);
    linefeed = 1; // set so that whole barcode has a linefeed appended
  }
  
  if (linefeed>0) { // barcode has been full received
    linefeed = 0;
    tone(BeeperPin,2000,20); // beep at 2.5kHz for 20ms    
    
  }
  
   if (buttonState == HIGH) {    
    // turn LED on:    
    Serial.print(5);
  delay(1000);  
  } 
  
}

Receiver:

char msg; //contains the message from arduino sender
const int led = 13; //led at pin 13
void setup() {
Serial.begin(9600);//Remember that the baud must be the same on both arduinos
pinMode(led,OUTPUT);
}
void loop() {
while(Serial.available() > 0) {
           msg=Serial.read();
           Serial.write(msg);
delay(10);
}
}

im not sure if it will be a issue with my code but i thought i will add it in. i have the wireless set up working where the two uno’s can communicate. the main issue i am havin is with the AS3 code i will paste the code below

AS3 :

import flash.events.*;
import flash.net.Socket;
import flash.utils.ByteArray;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequestMethod;



var bytes:ByteArray = new ByteArray();
//var ary:Array = new Array();
var bar_grab:Array = new Array();

trace("__AS3 Example__");
var socket:Socket = new Socket("localhost",5331);
socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);





function socketDataHandler(event:ProgressEvent):void
{
 
var str:String = String(socket.readUTFBytes(socket.bytesAvailable));

trace(str);

 
}

this is the code iam using to connect to the serproxy and retrieve the incoming byte from the sender,and the problem is as the bytes come in they are read one at a time instead of being stored

i have attached an image to the post to show you the output iam getting however the desired result would be

SF-F8-001

so if anyone can help me that would be great i am aware of using an array to store the data but i have tried many different ways but with no success

thank you