The try and catch is... Whoahahahaha.

But this dazzles me:

        var search:RegExp = /.+cannot\saccess\s(.+)\./i ;
        var matches:Array = String(error.message).match (search) ;
                                
        if (matches && matches.length > 1) {
                location = matches[1] ;
        }



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Pedder
Sent: donderdag 12 augustus 2010 15:44
To: Flash Coders List
Subject: Re: [Flashcoders] Getting the url where my Flash movie was embeded

Hello Cor,

this is the code is use and it is working fine for me.

var location:String = "unable to retrieve window.location" ;
                        
try {
        // try to call javascript to get window.location
        location = ExternalInterface.call ("window.location.href.toString")
;
} catch (error:SecurityError) {
        /*
        if Flash vars set like (allowScriptAccess = 'never') or  
(allowNetworking = 'internal')
        catch the SecurityError and extract the window.location url out of  
the error.message
        */
        var search:RegExp = /.+cannot\saccess\s(.+)\./i ;
        var matches:Array = String(error.message).match (search) ;
                                
        if (matches && matches.length > 1) {
                location = matches[1] ;
        }
}

I think it is self explaining but don't hesitate to ask if you got  
question.
Cheers...



Am 12.08.2010 um 14:34 schrieb Cor:

> Can yo ushow how you do this:
>
> So, i now make the call with a try block and parse the error message  
> with a
> regex and get my wanted url.
>
> Regards
> Cor
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of  
> allandt
> bik-elliott (thefieldcomic.com)
> Sent: donderdag 12 augustus 2010 14:09
> To: Flash Coders List
> Subject: Re: [Flashcoders] Getting the url where my Flash movie was  
> embeded
>
> good job mate :)
>
> On 12 August 2010 12:54, Pedder <[email protected]> wrote:
>
>> Ok, thank you for your answers.
>>
>> I tried this on a test system and it worked fine. Then i tried this  
>> on
>> facebook and got a "Security sandbox violation: external interface
> caller".
>> Well, the error message says something like "cannot access
>> http://www.facebook.com..."; So, i now make the call with a try  
>> block and
>> parse the error message with a regex and get my wanted url. Yeah!
>>
>> Thank you!
>> Chris
>>
>>
>> Am 12.08.2010 um 12:30 schrieb allandt bik-elliott  
>> (thefieldcomic.com):
>>
>>
>> or you could do it all from within flash using
>>> var:urlPath:String =
>>> ExternalInterface.call("window.location.href.toString");
>>>
>>>
>>>
>>> On 12 August 2010 11:29, allandt bik-elliott (thefieldcomic.com) <
>>> [email protected]> wrote:
>>>
>>> i think your best bet is to write a javascript function that returns
>>>> window.location.href
>>>> and then use the ExternalInterface class to call that function  
>>>> within
> the
>>>> flash
>>>>
>>>> best
>>>> a
>>>>
>>>> On 12 August 2010 10:51, Pedder <[email protected]> wrote:
>>>>
>>>> Hey all together,
>>>>>
>>>>> i was wondering if i can get the url where my flash movies are  
>>>>> embeded.
>>>>> I
>>>>> have a little widget on my page to which i provide an embed code  
>>>>> to my
>>>>> users
>>>>> so that they can embed my widget anywhere on the internet. But the
>>>>> problem
>>>>> is that i don't know where the widget is embeded.
>>>>> Some guy told me that he embed it on his blog but i can't find  
>>>>> it there
>>>>> and it would be nice if i could have some kind of statistic  
>>>>> where and
>>>>> how
>>>>> often my widget is played. But i wasn't able to get the external  
>>>>> url
>>>>> (where
>>>>> the code for the widget was embeded).
>>>>>
>>>>> I tried _url and root.loaderInfo.url but that only gives me my  
>>>>> own url
>>>>> where the swf file is stored.
>>>>>
>>>>> Any idea? Is there a possiblity to get the url given by some  
>>>>> javascript
>>>>> and document.URL?
>>>>>
>>>>> Thank you for your answers. I hope that there is an answer  
>>>>> because i'm
>>>>> struggling with this for a couple of weeks now.
>>>>>
>>>>> Cheers.
>>>>> Benjamin
>>>>>
>>>>> _______________________________________________
>>>>> Flashcoders mailing list
>>>>> [email protected]
>>>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>> Flashcoders mailing list
>>> [email protected]
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>
>>
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> Geen virus gevonden in het binnenkomende-bericht.
> Gecontroleerd door AVG - www.avg.com
> Versie: 9.0.851 / Virusdatabase: 271.1.1/3063 - datum van uitgifte:  
> 08/10/10
> 20:34:00
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Geen virus gevonden in het binnenkomende-bericht.
Gecontroleerd door AVG - www.avg.com 
Versie: 9.0.851 / Virusdatabase: 271.1.1/3063 - datum van uitgifte: 08/10/10
20:34:00

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to