PDA

View Full Version : Action Script



ahaynes106
09-16-2005, 08:50 AM
Finally found a Whois script that was incredibly simple to get functioning...THANKS!

One question. On my home page I have a Flash header that has a box to enter a domain name and a dropbox for extensions and of course a GO button. In the Action Script how would I direct it to your script? I would display the results and stuff on non-flash pages, just curious hwow to get the input for the initial search from Flash to your script. B) :)

Patrick
09-24-2005, 09:26 PM
Yes, it can be done.

This involves action script of course (as you noted). Try searching for "flash forms" in a search engine for examples of how to implement this.

Basicly, you just need to have the flash script submit to the whois script in the exact same manner is shown in the <form...> </form> tags of the whois script.

ahaynes106
09-29-2005, 12:56 PM
Ok. I'll play around with it...new to Flash, so it could take me a while :huh:

ahaynes106
11-18-2005, 09:24 AM
Oh well, I am not exeperienced enough with Flash to make this work from my flash header, so I wimped out and used an HTML header to make it work...it loads faster too :)

temp
11-22-2005, 01:10 PM
I've just managed to hack this code to allow searching and results from within Flash. External pages open when you view the whois report, go to the ordering page or visit the queried domain's website.

I've lost some functionality as I only wanted to search for 7 domain types. Other than building the query from Flash, the main changes were made under 'Edit Templates' within the admin section. Namely:

Available Domains
Unavailable Domains
BuyMode Results Page
Whois Report Page

The trickiest thing was pushing the string variable ampersands in and out of Flash, but I got around this using URL Encoded %26 (percent twenty six) in the end.

My Flash text files are dynamic, multiline, html enabled text fields - one with its variable name as 'dom_free' for available domains and one called 'dom_gone' for unavailable ones.

I also has to incorporate the old 'done=0" and "done=1" to tell Flash when the results had been loaded. This was also coded into the template sections.

IMPORTANT! - I've only checked this with FLASH 8 Pro and MX with Actionscript version 2. - it shouldn't be too difficult to adapt this - I did try but my checkboxes went missing :/

Basically it works like this:

Buy Mode should be enabled.

On your stage you have an input text field, in this case, with an instance name of 'dominput'.

You also have some checkboxes with each one's label as a domain extension (without the first dot - com, info, co.uk for example). The instance names of the checkboxes are suff0, suff1, suff2 etc.

You also have a submit button.

You then have 2 dynamic, multiline, html enabled text fields - one with a variable name dom_gone, one with a variable name dom_free.

Finally, you have a dynamic text field with an instance name of doneloading and a variable name of done.

/////

The following code goes in your root timeline and checks for the results coming back:


function domQuery() {
function domcall() {
trace("checking...");
if (_root.doneloading.text != "0" && dom_gone == "working...") {
dom_gone = "";
clearInterval(intervalID);
trace("all available and callback stopped");
}
if (_root.doneloading.text != "0" && dom_free == "working...") {
dom_free = "";
clearInterval(intervalID);
trace("none available and callback stopped");
}
if (_root.doneloading.text != "0") {
clearInterval(intervalID);
trace("some available, some not and callback stopped");
}
}
var intervalID:Number = setInterval(domcall, 200);
}


The button sends a string like this:



on (release) {
domQuery();
done = 0;
dom_gone = "working...";
dom_free = "working...";
page = "WhoisSearch";
domain = this.dominput.text;
if (this.suff0.selected == true) {
ext0 = this.suff0.label;
} else {
ext0 = "";
}
if (this.suff1.selected == true) {
ext1 = this.suff1.label;
} else {
ext1 = "";
}
if (this.suff2.selected == true) {
ext2 = this.suff2.label;
} else {
ext2 = "";
}
if (this.suff3.selected == true) {
ext3 = this.suff3.label;
} else {
ext3 = "";
}
if (this.suff4.selected == true) {
ext4 = this.suff4.label;
} else {
ext4 = "";
}
if (this.suff5.selected == true) {
ext5 = this.suff5.label;
} else {
ext5 = "";
}
if (this.suff6.selected == true) {
ext6 = this.suff6.label;
} else {
ext6 = "";
}
loadVariables("http://www.yourdomain.com/whois/whois.php?anticache="+random(9999999999), "", "POST");
}


Along with this it is posting the contents of an input field called 'domain' and the results from either a tick box, list or whatever that is choosing which domain extensions to look for - these are named ext0, ext1, ext2 etc.

The anticache setting is simply to generate a new, unique request each time.

Your 'Available Domains' template section should read:


dom_free=[repeat]<div>[[domain]].[[ext]]<a href='yourorderingpage.php?domain=[[domain]]%26ext =[[ext]]' target='_blank'><font color="#333333"> || </font><font color="#FF6600">Order Now</font><font color="#333333"> || </font></a><br></div>
[/repeat]

Your 'Unavailable Domains' template section should read:


&dom_gone=[repeat]<div>[[domain]].[[ext]]<a href='http://www.[[domain]].[[ext]]' target='_blank'><font color="#333333"> || </font><font color="#2D83DE">Website</font></a><font color="#333333"> || </font><a href='http://www.yourdomain.com/whois/whois.php?page=WhoisReport%26domain=[[domain]]%26e xt=[[ext]]' target='_blank'><font color="#2D83DE">Whois</font><font color="#333333"> || </font></a><br></div>
[/repeat]

Your Buy Mode Results Page section should read:


done=0&[[availabledomains]]
[[unavailabledomains]]&done=1

!! Make sure you change the references to yourdomain.com and yourorderingpage.php !!

You can download the Flash source files here:

Username = guest
Password = password

Download Link to FLA file (http://public.appsoft.co.uk/Flash_whois_MX.zip)

Good Luck.

Patrick
11-22-2005, 05:17 PM
Wow, that was nice of you to post that, as more than a few have wanted (or needed) this functionality.

Thanks!

ahaynes106
11-23-2005, 07:59 AM
In the words of Patiek - WOW

I look forward to trying it out. Thanks! :D