0

I have a flash swf file, which implemented a clicktag function (go to some URL), as I need to record how many user click the flash, so is there any ways to execute a javascript function(record userid) before user was redirect to the destination?

Here the clickTag

on (release) {  
    if (clickTAG.substr(0,5) == "http:") {  
        getURL(clickTAG, "_blank");  
    }  
}

javascript function look like:

function regUserid(ID){  
    $.ajax{  
        url:reg.php,  
        cache: false,  
        type: "GET",  
        data: ID 
    }  
}
2
  • 1
    What does your code look like now? Can you show some code? Commented Aug 30, 2013 at 9:54
  • how are those two connected? Commented Aug 30, 2013 at 10:05

1 Answer 1

1

First of all, your AJAX call has some errors in it. It needs to look like:

$.ajax({  
    url: reg.php,  
    cache: false,  
    type: "GET",  
    data: ID 
});

( and ) needed to be added.

http://api.jquery.com/jQuery.ajax/

Second, what I would do is send the user to your own website and add a parameter to the url so you can record the url, and in the JavaScript (or even better, your PHP) function, send them off to the correct website.

So something like:

on (release) {  
    if (clickTAG.substr(0,5) == "http:") {  
        getURL('http://www.yourownurl.com/reg.php?url=' + clickTAG, "_blank");  
    }  
}

And in your reg.php you do something to save the clickTag and use header('location:' . $_GET['url']) to send them to the correct website.

Update:

If you want to use ExternalInterface you can do the following:

on (release) {  
    if (clickTAG.substr(0,5) == "http:") {  
        ExternalInterface.call('regUserid', clickTAG);  
    }  
}

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html That is assuming you want to send the data to your regUserid function. clickTag is the parameter in the function regUserid. If you do this you still need to redirect your user to the right website. So something like document.location.href="http://www.example.com".

Sign up to request clarification or add additional context in comments.

4 Comments

thank for you reply, but I am not going to do only 1 function for javascript, I may need to add some more function in the reg(ID), is there any other suggestion? Thank again!
You could use ExternalInterface.
Thank you very much for your help, how could I achieve the goal? or any example?
Great! As I am new to flash action script, your answer is really helpful!!! So could my code like this? -> ExternalInterface.call('regUserid', clickTag); getURL('http://destination.com',"_blank");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.