New way to read my stories (Updated Again!)
Because I hate scrolling on web pages (it really makes me a reluctant online fiction reader) I’ve created a little Flash application for reading stories online (it lets you page back and forth, no scrolling!)
I’ve only hooked up one of my stories (His Island) so far.
How To Use On Your Own Site
If you want a copy of the Flash file, you can download it here. (If you just click the link you get the reader in all its ‘full-screen’ glory.)
Note that there’s no security on this thing. But it’s neat and I’ve only been using Flash for a couple days, so I’m pretty happy with it.
Basically the flash takes input from the HTML page it is on and passes those inputs into a php page on the server. These variables define the title and the text to use. It should be possible to move the flash file to another web server and create your own php file, to use the reader for yourself (though, I haven’t tested this yet)
Here is how to use it:
Method 1 (Simplest) – Copy/Paste
I’ve added a little feature that lets you PASTE any text you want into the thing and read it like a book. Press the small green button and then type or paste your text. Press the big green button and you are now reading your story!
Method 2 MySQL Database
1. Create a MySQL Table called stories with the following columns: title(type=varchar), comments (type = longtype).
2. Create a php file called storyreader.php. (You tell the Flash Reader its location when you invoke the Flash Viewer, see notes at end of this post).
The php file should look something like this:
/* SQL ACCESS */
$username="<username>";
$password="<pass word to database>";
$database="<database name>";
mysql_connect("<host server for database>",$username,$password);
@mysql_select_db($database) or die( "Unable to select database".mysql_error());
$project1 = $_POST['years']; /*this is the Title that has been passed to Flash from the HTML page hosting the Flash file*/
$query="SELECT * FROM stories WHERE Title='".$project1."';";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
/* load from database */
$title = mysql_result($result,0,"Title");
$text = mysql_result($result,0,"Comments");
echo "&returntitle=".$title;
echo "&returntext=".$text;
?>
Method 3 – Just a php file
The main thing to note from the example in Method 2 is that the returntitle and returntext echoes at the end. These are outputting the title and text from the MySQL database to the Flash program.
However, you do not actually need mysql access.
The entire PHP file could be truncated to:
echo "&returntitle=My Great Storyâ;
echo "&returntext=Blah blahâ;
Calling the Flash Story Reader
Okay that’s the basics of the PHP file. Now you need to call the flash program from your html page. You can check out the source of any of my pages, but for convenience you basically do this:
<style>
#flash {
width:550px;
height:700px;
background-color:#333;
border:1px outset #000;
text-align:center;
cursor:pointer;
}
#flash h2 {
font-size:40px;
color:#fff;
margin-top:80px;
}
</style>
<div id="flash"> <h2>Click here to read story</h2> </div>
<script type="text/javascript" src="http://static.flowplayer.org/js/tools/tools.flashembed-1.0.3.min.js"></script>
<script>// script inside the domReady method is executed after page is scriptable
flashembed.domReady(function() {// get flash container and assign click handler for it
document.getElementById("flash").onclick = function() {// when being clicked -> load flash inside "this".
flashembed(this, "http://yourothermind.com/pcode/flash/storyreader.swf", {input: 'His+Island', inputpath:'http://yourothermind.com/pcode/'});
}});
</script>
So you’ll see three variables: the flash file itself and then two inputs. These get passed to the Flash program(story title so it can tell the PHP which row to get from the MySQL database and an input path, the location to the storyreader.php file itself.
The program works by breaking the ‘text’ into pages and holding each page as an element in an array. There’s still some bugs with that, sometimes it pushes punctuation to a subsequent page, et cetera, but in general it seems to do an okay job.
[…] I find reading online uncomfortable, as I’ve discussed in the past — I even went to the length of writing a flash based storyreader, but that only solved part […]