Preloading issue flash CS4 with AS3

hello Guys,

i am a flash developer and recently start working with cs4 with as3
i am really new with the AS3 but a master in as2.

i am having problem with preloading action script. I’m using AS3.
the script runs perfectly in flash environment (simulate download progress in software). but when i integrate my flash object in html page and upload it, its not working in browser. movie get stop and nothing happen further
below is my code. please anyone help me?

addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event)
{
var bytestotal = stage.loaderInfo.bytesTotal;
var bytesloaded = stage.loaderInfo.bytesLoaded;
var percent = Math.round(bytesloaded * 100/bytestotal);
this.preloaderMC.loader.loader.gotoAndPlay(percent);
this.preloaderMC.loader.loaderR.gotoAndPlay(percent);

     if (bytesloaded == bytestotal)
  {      
  gotoAndPlay(2);
  removeEventListener(Event.ENTER_FRAME, loading);
 
  }
  }
  stop();