Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Pull random line from text file using flash.

Posted on 2006-05-10
6
Medium Priority
?
353 Views
Last Modified: 2013-11-18
I'm absolultly clueless when it comes to flash. All I need is a simple way to have a flash animation pull 1 random line of text from a text file.

Example:
'quotes.txt':
Quote1
Quote2
Quote3

On page load, the flash file would pull one of those lines from 'quotes.txt', at random, and display it. And stay static untill the page was refreshed. I'm thinking this must be simple to do, but I'm clueless as how to do it. If someone can either help me out in how to set this up, or provide a template that I could edit [font/etc], I'd be much appreciateive.

Thanks,
They

[Yes, I know it'd be much easier to use javascript/php/anythingelse, but this particular situation I need it to be in the form of a flash movie.]
0
Comment
Question by:iamthey
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:rockymagee
ID: 16651760
Take a look at this tutorial:

http://www.flashkit.com/tutorials/Actionscripting/Creating-Bjern_Po-608/index.php

Here it is in javascript (may be able to recreate it in the action window within Flash:
<script language="javascript">
var quote = Math.floor(Math.random()*3);
quote = quote + 1;
switch (quote)
{
case 1:
  document.write("Quote 1")
  break
case 2:
 document.write("Quote 2")
  break
case 3:
  document.write("Quote 3")
  break
default:
  document.write("Default Qoute")
  break
}
</script>
0
 

Author Comment

by:iamthey
ID: 16651961
I can do it easily with PHP [Although I am a PHP noob as well] as such:

<?
/* No Comment. */
$randd="randd.txt";
$randd=file("$randd");
$display=rand(0, sizeof($randd)-1);
echo $randd[$display];

?>

[Sorta borrowed from a a friend. ;]

But then it pulls just one line at a time

I just have that in 'ran.php' oh my server here: http://me.thegroupofthey.com/ran.php And some random quotes [with formatting, I was toying around]

If there was some way I could just use a flash file to call that page, then that'd be prefect. Any ideas?

[[Thanks for the Tut rockymagee]]

Thanks,
They
0
 
LVL 6

Accepted Solution

by:
rockymagee earned 580 total points
ID: 16652063
Hope you do not mind the tutorials:  I think this may be the one you are looking for:

http://www.fwzone.net/ShowDetail.asp?NewsId=842
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 

Author Comment

by:iamthey
ID: 16652205
I belive that might do what I want, but how do I load it into a flash string?

[Flash file located at http://me.thegroupofthey.com/quote.swf ; php at /quotes.php ; quotes at quotes.txt  ]
0
 

Author Comment

by:iamthey
ID: 16652256
Hah, nevermind. I used their source, and my php script and figured it out. You sir, win. Thanks for all your help. I'm upping the points by 20 before accepting.

Thanks again.
0
 

Author Comment

by:iamthey
ID: 16652262
[Points up]
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question