PDA

View Full Version : IF ? = Show animation


Dracil
02-02-2010, 11:43 AM
Hello, iam a newbie at actionscript, but iam well oriented in php.

Now what iam looking to do is a flash movie that shows diffrent animation depending on $variables on the page given through php.

Is there an easy way to simply do this in action script:

If $var = "Play Animation1"
{
gotoAndPlay(150)

}

?

Thanks in advance

the binary
02-02-2010, 01:05 PM
its nearly correct..
but you have to compare instead of assign ..


if (yourVar == 'Play_Animation1') {
// doSomething();
}

Dracil
02-02-2010, 01:32 PM
Ok so lets say i have this:

?php

$var1 = "move left";
$var2 = "move right";
?>

And now i want my flash application to read the vars without having to print it out on the rwebpage as <? echo "var1 = $var1" ?> .. Because i want this vars to be hidden from the users, i only want the flash application to see it .. not so people can just look in the source and se the values.. how do i do that ? can flash interact with php without showing the users?

Dracil
02-02-2010, 01:45 PM
what about if i grab stuff from my mysql database ? then it shud be hidden.

timmetoe
02-03-2010, 06:36 AM
You can import the echo's into Flash.

But there might be an easier way if we know what its for so could you tell us a little more?

Dracil
02-03-2010, 07:11 PM
It will randomly show diffrent movies, för example.

I have a flash application, with a set of maybe 50 diffrent scenes with diffrent happenings. And depending on what the php tells it to play it does.


The php will randomly select diffrent kind of scenes, it could tell the flash to play either 1 up to 50 diffrent scenes. for example:

an output from the php would look like this(echo):
Play Scene 1
Play Scene 35
Play Scene 5
Play Scene 49

And this would be totally random.

And the flash needs to be able to read all these scenes and play them one after the other.

One way might be to just make the php echo inside the object:

Scene1 = Play Scene 1
Scene2 = Play Scene 35
Scene3 = Play Scene 5
Scene4 = Play Scene 49

However that will be visible for the user if they just take a look in the source.

Also how would i make the flash pickup a randoom number of scene play? i mean if id have a total of 5 scenes i could just make:

If Scene1 == Play Scene 1
{

}
Elseif Scene1 == Play Scene 35

and so on, but when its 50 scenes (wich i must have) i feel this is the wrong way to do it since it would take ages..

Any tips are welcome!

Thimbletack
02-06-2010, 06:47 PM
well, for simple output in AS2 you use
trace("your message" + aVariable);
If you want a random number you can do something like this:
myNum = Math.random();
The number it generates will be between 0 and 1 so if you want it to be from like 0 to 10 you would have to multiply it by 10 and so on. then you can just use some if statements:
if (myNum <= .2) {
_root.gotoAndStop(32);//goes to frame number in parenthesis
}
does that work for you?

Dracil
02-07-2010, 06:10 PM
Oh maybe my english is bad, you didnt understand my question..

My php file gives random outputs, an exampel would be this:
Scene 8
Scene 5
Scene 17


Now i need a flash code to grab those php outputs and read them into flash,

And if the FIRST value (first scene which is 8 in the example) it should do something.

Maybe the best would be using an array, but how to get a php array into flash?