ActionScript 3.0 :: Fasting A String As A Function?

Jan 26, 2009

First post, frequent lurker. I'm wondering if it's possible to cast a string as a function in AS3, for example

var foo:String='myFunctionName';
var dynamicFunction:Function;
// pseudoCode (this used to be done with eval() in ancient versions of AS).
dynamicFunction=Function(foo);
dynamicallyCreatedMovieClip.addEventListener(Mouse Event.ROLL_OVER,dynamicFunction)

View 2 Replies


Similar Posts:


String :: Use Objects.function If Objectsname Is Taken From String?

Feb 6, 2012

I was wondering if this concept is doable:

Scenario:
4 areas on 1 stage which are quite similar (eg webcamconference, each area has the same functions)

Buttonobjects are numbered(eg area 1 has playbutton1,mutebutton1,namebutton1,namelabel1, etc)

every area gets a close-Button which closes/shuts down the area.(close1,close2,close3...)i want to archive the following:

if(close1.isPressed){
function invisall(1);
}[code]....

this should do the trick via dynamic Nr at the end of each default button(eg playbutton)
but ofc

"playbutton1"._visible=false;

doesnt work because playbutton1 is still a String.how can i take the String as a Buttonname /ButtonObject? do i need to write an new function? this would destroy the purpose of less code. for now i will split the area into frames that i put on the stage.

View 2 Replies

AS3 :: Use The Function Type In (var F:Function) For A Method F(s:String)?

Nov 19, 2009

i have a class that has something like this

public class Foo {
public var f:Function;
public void method(s:String)
{

[code]...

so i need to assign to the f a function that takes an argument f(s), something like

myFoo.f = thefunction
function(s:String)

how to do all this, so it will work correctly?

View 3 Replies

ActionScript 3.0 :: Function Name To String

Jun 24, 2010

Is there a good way to get the name of a function in as3 in a String or as a String. I have seen sneaky ways by forcing an Error call and stack trace, but that is not what I am look for.

View 5 Replies

IDE :: Cast String As Function

May 15, 2009

I want to have a loader function that passes the loaded data to the correct function. So I can do this:[code]Is there any way to type the second variable to avoid the clumsy switch routine, like so:Function (sendTo) ();

View 2 Replies

IDE :: Call A Function From A String?

Oct 28, 2009

Is it possible to call a function from a string? such as if I passed the name of a function to this function, is there a command to convert the string to a function call? :

function CallSpecific(passedFunctionName:String)

I used String, but it was just a guess...

View 9 Replies

IDE :: Pass A String To A Function And Use Its Value As The Variable Name?

Dec 21, 2009

Is there any way that you can pass a string to a function and use its value as the variable name you wish to change. For example.

Code:
var text:String = "Goodbye World";
function myfunction ( varToChange)
{
varToChange = "Hello World";
}
myfunction("text")

View 2 Replies

ActionScript 3.0 :: Xml String.search Function

Feb 16, 2011

I'm trying to create a simple xml search function that searches an xml file for a string, and if that string is found in the xml, display the node which contains that string in a text box.I have the simple search function working, but what I can't do is return the specific node. Right now, the function is returning all the xml data instead. If someone could take a look and possibly lend some guidance as to how to return the specific daya, I would be much oblidged. Hope this makes sense, if not, let me know and I'll do my best to clarify.[code]

View 6 Replies

Referencing A PHP String Inside A Function?

Feb 21, 2009

I am currently connecting to a PHP string in actionscript. While I'm having no trouble importing the variables like so:

Code:

this(variable);

I am having trouble referencing the same variable while inside a function:

Code:

_root.ButtonMovie.onRelease = function() {
this(variable);
}

I really need to reference the variable while INSIDE the onRelease function, because I need to apply some actions based on how many times the button has been pressed.

View 2 Replies

ActionScript 3.0 :: Call A Function From A String?

Oct 29, 2009

I have a class that has a timer function built into it. When this timed function is called, I would like to be able to call another function when the timer is finished (which I would do in the TIMER_COMPLETE handler).

If I pass the name of the function to my class function, could I use that string(?) to call the function at the end of my timer?

View 8 Replies

ActionScript 3.0 :: Pass A String As Function?

Oct 7, 2010

How to display the correct digits. For instance, if the answer is 97%, I want the display to show 97, not 11. Please feel free to view the SWF or look at the FLA file to see[code]...

View 5 Replies

ActionScript 2.0 :: Convert String Var To Function()?

Feb 19, 2006

Is there some way to convert a dynamically loaded variable to a function name?Something along the lines of:

Code:
for (i=1; i<menuArray.length; i++) {
var menuSelect = menuArray[i]+"Open";

[code].....

View 8 Replies

ActionScript 2.0 :: String Manipulation In Function

Aug 22, 2006

I'm using a function to call multiple button actions, so I don't have to rewrite code for each button... here's the script:

[Code]...

This is all part of a clip which loads pictures externally... each of the buttons (which are mc's) are named btn0, btn1, etc.

View 14 Replies

ActionScript 2.0 :: Passing String Var Into Function?

Jan 18, 2008

im making a function that limmits text to a specified number... only problem is i cant seem to pass in the text var that contains the text

Code:
var textF1:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam neque purus, aliquam sed, sagittis tincidunt, adipiscing ac, urna. Ut libero urna, nonummy sodalesxxx";

[Code]....

View 1 Replies

ActionScript 2.0 :: Run A Function On String All At The Same Time?

Apr 27, 2008

I have an online app that allows a user to select as many strings as they want from a dynamic textbox, then run a function on them. Can you do that without a for loop so that it runs the function on them all at once?

View 4 Replies

AS :: IDE - Pass A String To A Function And Use Its Value As The Variable Name

Mar 18, 2009

Is there any way that you can pass a string to a function and use its value as the variable name you wish to change. For example.

[Code]...

View 1 Replies

IDE :: Download Function In String And Execute It?

Apr 24, 2009

I would like to download a function as a string from my server into a Flash swf-document on the computer of a customer. So this download would be executed client-side. Then I would like to 'execute' the string, just as I do with the 'eval'-function in php/javascript.The important thing here is that the function is not stored client-side on the harddisk (like the swf-document) and that the function only remains in the computer memory.

View 12 Replies

ActionScript 3.0 :: Simple Pad String Function?

May 29, 2011

I thought I would share a simple pad string function I created briefly... I know that there may be other similar functions already out there but I decided to make it anyway. It's basically a ripped off as3 version of the str_pad() php function.

Examples:
trace(stringUtils.stringPadLeft('7',4,'0','left')) ; // Traces 0007
trace(utils.stringPadLeft('whatever',2,'~','left') ); // Traces whatever
trace(utils.stringPadLeft('hi',20,'-','left')); //Trace ------------------hi

[code]....

View 2 Replies

ActionScript 3.0 :: String To Mathematical Function Parser?

Jun 13, 2009

Does anyone know of a parser for math functions?

Basically, I want to be able ot take a string such as:

(x + (x - 3)/2 * 4)^2

and compute the answer. Before I make the parser on my own, I thought I'd check to see if anyone has something similar already made.

View 1 Replies

Actionscript :: Can't Add A New Function To String Class Via Prototype

Aug 10, 2010

[code]causes this error with mtasc compiler:type error String has no field myFunction it must be possible to add new functions to a class via prototype.is there any configuration i can do for mtasc to be able to compile this code?

View 1 Replies

C# :: Using Regex To Alter A String (based On Function)?

Nov 2, 2010

I have some ActionScript code that splits a string using Regular Expression and lets me add content at the split location.

// AS3 Code
function formatTweetText(tweet:String ):String
{

[code]....

View 4 Replies

Flash :: Call String Or Integer From Another Function?

Oct 16, 2011

I've got different functions in actionscript 3, one function generates random numbers each time there's a button click. But with another button I want to call the random number which is generated at that moment. I have to call the random number from another function then, but these are two different functions so it just considers it as an undefined property.

[Code]...

But I can't call randomnummer1 because it's inside another function. So I get the property undefined error.

View 2 Replies

ActionScript 3.0 :: Access The Value Of A Variable Of Which Only Have The Name As String In A Function

Dec 29, 2009

my goal is to keep my output window organized so i can follow all my traces more easily. so i wrote a couple of custom functions to achieve that. one of them would be: to more easily trace the following variable for example

[Code]....

View 6 Replies

ActionScript 3.0 :: String Function Removes Formatting?

Sep 6, 2011

ok so i have this function basically it adds text to a given position in a textfield. it adds the text in the correct position but the problem is that it is screwing with the formatting i've applied to the textfield.

here is my code:

ActionScript Code:
txt.text = "hello world";
// adds text at the character index specified and returns the new string.
function addText(txt:TextField, txtToAdd:String, index:Number):String{

[Code].....

i also have a function which deletes but that isn't important right now. i was trying to avoid using html text but at this point i'd willing to give virtually anything a try.

View 9 Replies

ActionScript 2.0 :: Flash CS3 - Convert String To Function Name

Oct 1, 2008

I am using AS 2 in Flash CS3 and XML. I have the function named in the XML file which I would like to be called via a rotating banner. However I can't seem to convert the string (read via the XML file) to convert to the function name. a trace reveals that the correct string is being called: _parent._parent._parent.loadFunction. urls[count] is the array that stores the function name. Here is the script:

[Code]...

View 4 Replies

ActionScript 3.0 :: Search String Function - Get The Int Returned

Jun 7, 2009

I need to be able to get the int returned on this. If I serach for any letter as a string I get the search function working right. If I run it like it is below I get back 0, which I should get 3.

[Code]...

View 3 Replies

ActionScript 3.0 :: Flash Running Function From A String?

May 25, 2010

If I have the name of the function I want to run in a string called function_name and the params I want to pass to the function in another string called function_params, how would I could this to go in a button with the following code:

mc.button1.addEventListener(MouseEvent.MOUSE_DOWN, button1_handler);
function button1_handler(Event:MouseEvent):void {
// Dont know what to put here

[code].....

View 1 Replies

ActionScript 3.0 :: Call Static Function From String Name?

Jan 29, 2011

I'm wondering if its possible in flash to be able to call a static class function via its name as a string. I know for you're usual case you can do this to call the function 'func'

Code:
this["func"]();
func():void
{
trace("I'm a function");
}

However I'm wanting to do this from another static function and in a static function you obviously can't use the 'this' keyword. I've tried just omitting it, or replacing it with the class name but neither work.

View 2 Replies

ActionScript 2.0 :: Call A Function From A Concatenated String?

Mar 11, 2011

I'm using the Gaia Framework to develop a website, I'm still getting used to it but it's been great so far. There's a part in a page class where I want to call certain functions to initialize some effects on every deeplink. I'm doing good, but I need to call a function through concatenating some strings. Please have a look at some code of my class and read the comments for a better understanding:

Code:
private function FUNC_que():Void{
SEC_que.b1._width = 0
stringTyper(SEC_que.t1, st1, 15, 8)
var ts2 = new TextShuffle(SEC_que.t2, st2,SEC_que.b1);

[code]....

View 2 Replies

ActionScript 3.0 :: Using String To Define Function And Variable (?)

Nov 16, 2011

I'm trying to make children of a tile and put them in their respective locations. To do that, I need to know what kind of tile is to be created, but if I just use my old method:[code]I will have to use a chunk of code like this for every single imaginable tile. Obviously, that is not efficient! So I'm trying to optimize it by having what tile type is to be posted saved in a string, then using the string to refer to what child is to be created, something like below:[code]how to make the above code work. Surely, there is a way to do this?

View 14 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved