Jump to content

Combine flash and php.


thatisme

Recommended Posts

I'm thinking about buying this flash-application; http://www.adriantnt.com/products/rating_system/

Since the flash-programmer couldn't answer make question, I ask it here insted. Is it possible to combine this flash-application to a php-scipt to "rank" different votings in a list (ex. 1 to 8) where the highest amount of stars get on the top, and so on.. ?

And if there are a way to do this.. where can I find such a script that is easy to use and "combine"?

I'm pretty new on php..
Link to comment
Share on other sites

Ummm lemme dig up some flash scripts...

aha found one!

[code]
on (release) {
theiname = iname.text;
theisubject= isubject.text;
theiemail = iemail.text;
theicomment = icomment.text;
submit.enabled = false;
cancel.enabled = false;
email_error.text = "";
subject_error.text = "";
comment_error.text = "";
name_error.text = "";
name.textColor = 0x000000;
email.textColor = 0x000000;
subject.textColor = 0x000000;
comment.textColor = 0x000000;
iname.borderColor = 0x000000;
isubject.borderColor = 0x000000;
icomment.borderColor = 0x000000;
result.text = "Working...";
method = "flash";
if(!alphaonly(iname.text)) {
name_error.text = "Please, letters and spaces only";
name_error.borderColor = 0xFF0000;
result.text = "";
name.textColor = 0xFF0000;
name.enabled = false;
result.text = "errors";
} else if(!alphaonly(isubject.text, "1", ".!?")) {
subject_error.text = "Please, letters, spaces and '.!?' only";
subject_error.borderColor = 0xFF0000;
result.text = "";
subject.textColor = 0xFF0000;
submit.enabled = false;
} else if(!emailcheck(iemail.text)) {
email_error.text = "Please enter a valid e-mail address";
email_error.borderColor = 0xFF0000;
result.text = "";
email.textColor = 0xFF0000;
submit.enabled = false;
} else if(icomment.length < 16) {
comment_error.text = "Must be 16-1024 characters";
comment_error.borderColor = 0xFF0000;
result.text = "";
comment.textColor = 0xFF0000;
submit.enabled = false;
}
else { //start php and what not

loadVariables("act.php",this,"POST");

this.error  ? this.error = null : null;
this.success = null;
this.onData = function()
{
theerror = this.error;
if(this.error != "" || this.error != NULL || this.error != "null") {
result.text = theerror;
}
if(this.success == "y") {
nextFrame();

}

//result.text = this.error + this.success;
}
}
submit.enabled = true;
cancel.enabled = true;
}
[/code]

And this is act.php

[code=php:0]
<?
if($_POST['method'] == "flash") {
$output = "error=1&reason=" . urlencode("Unknown error reason");
$to = 'me@me.com';
$subject = $_POST['theisubject'];

$message = $_POST['theicomment']."\n\n";
$additionalHeaders = "From: {$_POST['theiname']}<{$_POST['theiemail']}>\n";
$additionalHeaders .= "Subject: test\n";
$additionalHeaders .= 'Reply-To: '.$_POST['theiemail'];

if(@mail($to, $subject, $message, $additionalHeaders)) {
$output = "success=y";
}
else {
$output = "error=1&reason=" . urlencode("There was an error with the server.  Please try later.");
}
echo $output;
}
?>
[/code]

Basically what happens is the actionscript checks for the errors as much as it can (I include a file ot do regexp with since it is not currently integrated with flash) and then if there is no error flash catches it passes it to add.php via the POST variable.

What happens is loadVariables("act.php",this,"POST"); passes all the variables to act.php via post and returns the output from act.php to this.  For example if you loaded the vars and act outputted "name=corbin" and then you echoed this.name it would say corbin.

I'm not sure if this makes sense, and you're probably better off with a flash-php tutorial, but I tried lol.
Link to comment
Share on other sites

actually corbin that sums it up pretty well, but then agian i'm a flash developer so thats all pretty simple stuff.... /shrug

if you are looking to learn flash check out nerdbooks.com and get yourself a visual quick start guide to flash, and a visual quick start quide to action script. the visual quick start series of books is the greatest thing since slice bread, and while you're at it get the vqsg to php. all three books wil cost you about 45-50 dollars from nerdbooks.com there store is down the street from my house, so i have a crap load of their books.
Link to comment
Share on other sites

Hello.

// I am the one that sells the product.

Since I am a flash developer myself (not php developer), the php part of this product was made by someone else so I cannot make such updates that require additional php coding, this is why I suggested to the user that he should ask here about such php modifications.

Here are some details about how it words, maybe someone knows how it should be done.
The rating system is a swf file that sends and loads data by a php file in background, the flash file sends an id (photo1, photo2) ot the php file and the php file returns the rating score (1..5) and flash file shows the stars (1..5).

I think this could be done by adding php script inside the html code of same page, send the id of all items to be rated to the php file and record the answers then display the swf files in the right order according to the answers received.

[code]<?php

$my_ids = array ('photo1','photo2','photo3');
$my_scores = array ();

send the id 'photo1' to the php (by GET I think) and record the answer (score 1..5);
send the id 'photo2' to the php (by GET I think) and record the answer (score 1..5);
send the id 'photo3' to the php (by GET I think) and record the answer (score 1..5);

Display the html code to show all swf files in the order according to the scores received above.

?>[/code]

That should be a way to do it but I don't know if is possible without the product code and since is commercial product I cannot post he files for download.
Link to comment
Share on other sites

OK so you're trying to make a flash script that lists the top rated X entries or entries descending or something like that?

I'm what I would call a 'Flash novice,' but I would make a flash file with a blank text area (or well it formatted so the text area(s) could be populated with text later) and then I would get info from a php file.  The php file would do something like "SELECT * FROM table ORDER BY rating DESC" and then it would output it to the flash script.  The flash script would loop through it populating names and making links to it and saying the rating and so on...

If you're not pulling it from a database that could make things a lot harder...  Also, I may be wrong about what you're even trying to do lol...
Link to comment
Share on other sites

The system doesn't use a database. It saves to plain file.
Maybe is not such a good idea to use my rating system in this case.

Or if you want to use it then easiest way would be to talk to a php developer after you have the rating system so that person can see the code and chose best solution.
When a php developer sees the system it should be easy for him to do the additional code that sorts the swf files inside html code.
What I had in mind is a php script that orders the html code for displaying each swf file in correct order.
Link to comment
Share on other sites

Hmm... I've red what you guys have said, but it dosen't make much sense to me...

Is it possible in some way to rank them?

"I can try to write a PHP script if one of you two can tell me what format the ratings are kept in."

That would be great... adrianTNT?
Link to comment
Share on other sites

Basically what the php script would do would be:

Read the file that contains the ratings into an array;
Sort the array by average rating descending;
output the html in the correct order to have each ranking script with the highest rankings at the top of the page and so on...
Link to comment
Share on other sites

Corbin, the plain file is stored as _id_of_item_to_be_rated.dat and there is a .dat file for each item id to be rated.
An example of database file woudl be: video1.dat and its contents is like this:

3|68.117.115.182
5|34.117.115.122

that is user's vote (1..5) | user's ip.

now maybe the script can do this....
get an array of IDs from the user (items to be rated, e.g video1,video2,video3) and from same directory as the php file read the dat file for each one of them, calculate the average (1 to 5) then print them in the right order, this print will later be the display of the swf file.

video1 score 5
video2 score 3
video3 score 1

Do I make sense ?
Link to comment
Share on other sites

I did like adrian said and it lists the files in ascending numeric order.  On rank2.php it makes php files with X swf things per file.

I'll attach the files, but unless you understand them I suggest not messing with them until I explain them tomorrow (head ache and it's 1:30AM here >.<).

Basically they're like mini template based through sprintf if that makes any sense...

Live copy running at http://corbin.no-ip.org/rank/

And no the script isn't stuck on 3's lol... I used phps random function to generate numbers 1-5 and of course that average would be 2.5 which would round to 3...

[attachment deleted by admin]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.