Groups | Blog | Home
all groups > flash actionscript > november 2005 >

flash actionscript : Actionscript phrased as a string.


David Stiller
11/29/2005 4:31:16 PM
Michael,

[quoted text, click to view]

No.

[quoted text, click to view]

That you can do, but you have to write you functions to be dependent on
variables. You can load all the variables you want from a text file or XML.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

David Stiller
11/29/2005 5:08:56 PM
Michael,

[quoted text, click to view]

Them's the breaks, though.

[quoted text, click to view]

That would certainly do it, but are you planning to if/else your way
through the whole API?

What's your goal here, in the end? I know you want to control a SWF via
external files, but ... well, why? Once a SWF is compiled, it's compiled.
I'm not knocking ya, just trying to understand what your goal is.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Michael Gioffredi
11/29/2005 9:23:28 PM
Is there any way to run an actionscript that is phrased as a string? Such as:

killTurkey = "trace('killed turkey');";

The reason I ask is that I would like to be able to control the actions of the
movie from an external text file or xml file.

NSurveyor
11/29/2005 9:32:19 PM
Michael Gioffredi
11/29/2005 9:47:38 PM
That's what I thought. The problem is making different interface elements and I
have no way of anticipating exactly every kind of action I will want to call.
Instead of saying something like:

In the text file:

action = ?gotoAndStop()?;
frame = ?2?;

Then in flash have a function that checks what action what said:

function doAction ()
{
if (action == ?gotoAndStop()?)
{
gotoAndStop(frame);
} else if (action == ?getURL?)
{
//get URL
} yada yada
}

Is this the best way?

NSurveyor
11/29/2005 9:49:38 PM
If you are using a texfield for a link (HTML enabled), you could use asfunction:

NSurveyor
11/29/2005 11:07:56 PM
You're welcome. But just to let you know... it has drawbacks:

1. You can only pass strings into the function, for example, you can't pass an
Object to the "function string" using callAsFunc.

2. The "parameters" cannot contain "," as it is used to seperate all the
parameters.
Michael Gioffredi
11/29/2005 11:17:45 PM
Jeckyl
11/30/2005 12:00:00 AM
if you have

action = "play"

say

then you can use

this[action]();

and that will call the function indirectly by name
--
Jeckyl

AddThis Social Bookmark Button