A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: RegExp in Browser

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Posts
    3

    RegExp in Browser

    Hello,

    I have made a flash applet in which a string is checked using the RegExp.exec() method. This works fine when I test it locally, but when I upload it to my website, the RegExp no longer works. Why would this be? :S

    Here is my code:

    Code:
    function comp(e:Event){
        var str:String = e.target.data;
        browser.text += e.target.data;
        var imgRE:RegExp = /<img[^>]+id\s*=\s*['"]([A-Za-z0-9]+)['"][^>]*\/\s*>/g;
        do{
            var exec:Object = imgRE.exec(str);
            if (exec) browser.text = exec[1];
        }while(exec);
    }
    
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, comp);
    loader.load(new URLRequest("Content/home_2.html"));
    It loads an external HTML file and then checks it for img tags. It then takes the "id" parameter of the img tag (as exec[1]) and puts it into a textbox on the stage.

    Thanks for your help - sorry if this is a stupid question!

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    Are you sure the RegExp is failing and not the URLRequest? 'Cause most likely it's a sandbox / security issue. Make sure you've set Security.allowDomain('domain.com') for the site it's on. Sorry if you already knew that and this is dumb, but just to cover all the bases...make sure if you're going from a mac to a linux box that the folder Content is actually spelled with a capital C as you have it in the request... and consider re-coding that request for test purposes to the actual http: address and running the .swf locally to debug it against the online files...
    That's all I can tell you, I don't see any reason why the regExp would fail...

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