A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: It works in Flash's Preview... But not when I upload it...?

  1. #1
    Member
    Join Date
    Apr 2009
    Posts
    37

    It works in Flash's Preview... But not when I upload it...?

    Hi all. I'm working on a music visualizer like program. It's just something that I'm playing around with. I found this website: http://www.communitymx.com/content/a...ge=1&cid=8E9A0 for a simple music visualizer, copied the code, put it in my file, and it works when it hit preview. Beautiful. However, when I upload it to my website and view the file from my website, the music visualizer doesn't work and there is nothing but a line, the boxes don't draw. It's really strange, and the code is exactly the same as it is on that site that I linked. Can anyone help? The music loads and plays, and it does draw the line, and everything else about the flash file works, it just doesnt render the boxes that gives it the visualizer look.

    Here's the code, if you don't want to click the link:
    Actionscript Code:
    var url:String = "http://www.helpexamples.com/flash/sound/song3.mp3";  
    var request:URLRequest = new URLRequest(url);  
    var s:Sound = new Sound();  
    s.addEventListener(Event.COMPLETE, completeHandler);  
    s.load(request);  var song:SoundChannel = s.play();  
    song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);  
    var ba:ByteArray = new ByteArray();  

    var gr:Sprite = new Sprite();  
    gr.x = 20;  
    gr.y = 200;  
    addChild(gr);  

    var time:Timer = new Timer(50);  
    time.addEventListener(TimerEvent.TIMER, timerHandler);  
    time.start();  
     
    function completeHandler(event:Event):void {   
      event.target.play();  
    }  

    function soundCompleteHandler(event:Event):void {  
      time.stop();  
    }

    function timerHandler(event:TimerEvent):void {     
      SoundMixer.computeSpectrum(ba, true);    
      var i:int;   
      gr.graphics.clear();     
      gr.graphics.lineStyle(0, 0xFF0000);  
      gr.graphics.beginFill(0xFF0000);     
      gr.graphics.moveTo(0, 0);    
      var w:int = 2;   
      for (i=0; i<512; i+=w) {         
        var t:Number = ba.readFloat();         
        var n:Number = (t * 100);      
        gr.graphics.drawRect(i, 0, w, -n);     
      }  
    }
    Last edited by Xanathalas; 01-13-2011 at 01:25 AM.

  2. #2
    Senior Member
    Join Date
    Jan 2009
    Posts
    208
    I would say its a cross-domain issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center