Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set Action based on Value from txt File.

Posted on 2003-10-24
8
Medium Priority
?
226 Views
Last Modified: 2012-05-04
I want to make a drum rotate based on value that will get from txt file.

Lets say if value in TXT file is 0. Drum will not roate.
If value in TXT file is 1 drum will rotate.

TXT would reside in same folder.

And also, how can I get a new values in Flash Movie every few seconds. So if I have a Flash movie that reads a TXT file, and I change that TXT file, I want FLASH to check for TXT and update itself in real time.

Thanks in Advance.

Valentin
0
Comment
Question by:valentin_v
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 5

Accepted Solution

by:
Calron earned 375 total points
ID: 9614382
I don't quite get it, you want the fla to change according to the text file or do you want to have a movieclip whose behavior changes depending on the value of the text file?

On how to load a text file have a look at this tutorial:

http://www.flashkit.com/tutorials/Actionscripting/Basic/Reading_-Brett_Ta-139/index.php 


Then to change the behavior of a movieclip you will need two things in th emovieclip:

let's say frames 1 - 10 contain the animation you want to show if the text contains 0
frames 11-20 contain the animation for text file containin 1

you need to add either stop(); or gotoAndPlay(1) in frame 10 depending whether you want the animationrepeated or just shown once. Same for the second animation.
Then in the first fram e add somehting like this:

Load the txt file and set the variable animationsetting according to the value you read.
if (this.animationsetting == 1) gotoAndPlay(11);  // this checks if the variable animationsetting is set to 1 and if so plays that animation

0
 

Author Comment

by:valentin_v
ID: 9616201
Basically I loaded a txt file with variable &run

Statement is

if (run == 1)  gotoAndPlay(11);  
else
if (run == 0)  gotoAndPlay(2);  

And it works, I put 1 as value, it will play rest as wanted.
If I put 0 it will not go beyond frame 1

For this to work when changing variable value, I need to restart movie every time.

I want while movie is working to check if variable has changed from 0 or 1. If it did, it will go to frame 11. Basically REAL TIME checking if variable &run changed.
0
 
LVL 5

Expert Comment

by:Calron
ID: 9616260
If you want it to do the runtime check you have to realod the textfile. So you have to call the load command again to refress the run parameter. That way it should work at runtime.
The parameter only changes when the text file is reloaded with a different value in it.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:valentin_v
ID: 9616645
I got it to work on local computer, but when I put it on server, it will not load variable again.

I have put load variable at the end to load it with a new value, but on server will not repond. Variable that is loaded with movie will stay.

0
 
LVL 5

Expert Comment

by:Calron
ID: 9616884
On a server you will run into the problem of the files being cached. So it could be that the cached file is being reloaded. To get around this you might have to add some random number. I am not sure if this works with txt files, but this is what I did when loading values from a php file:

load("myphp.php?num=" + random(10000));

It should probably work for text files as well and that way the file should be reloaded every time.
0
 

Author Comment

by:valentin_v
ID: 9618515
I have created run.php and tried
load("run.php?num=" + random(10000)); at the end of movie to load it , and still it will not pick up new value.

run.php content:
<?php
echo ("&run=0");
?>

or

<?php
echo ("&run=1");
?>

Other value in movie

if (run == 1)  gotoAndPlay(11);  
else
if (run == 0)  gotoAndPlay(2);  

I guess its only caching of files because if I close brower and load it again, animation will change, it I just click on Refresh will not.

Is there another way to prevent caching
0
 
LVL 5

Expert Comment

by:Calron
ID: 9618905
Have a look at these two PAQ's they discuss the same problem and use pretty much the same solution:

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20538312.html
http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20540541.html
0
 

Author Comment

by:valentin_v
ID: 9626842
Got it

loadVariablesNum("run.txt?nocache=" + new Date().getTime(),0);

Thanks for help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

730 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