0

Is it possible to escape from XML, to ActionScript 3 code? Take a look at the following:

<keyFrame name="myKey" delay="100ms" function="{function():void{soundCommand.execute()}}"></keyFrame>

where the

function():void{soundCommand.execute()}

part has to be interpreted as ActionScript 3. So ideally, if I query the function attribute of the keyFrame tag, I should get a reference to the function.

Any ideas? Thanks in advance!

PS: No Flex is allowed. :)

1 Answer 1

2

ActionScript's eval statement is very, very simple compared to the standard JS, so just interpreting that statement with eval won't work.

Instead of specifying an anonymous function there it would be easier to just give a function name. You could then just look up that function on the appropriate object and run it like this:

function foo():void {
    trace("run foo!");
}

var testXML:XML = <keyFrame name="myKey" delay="100ms" function="foo"></keyFrame>;

this[testXML.@function]();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.