Actionscript 3 :: Default Function Parameter As An Empty Function?

Dec 23, 2009

i have a function that receives a function as a parameter. example:

function foo(bar:Function):void() {};

how can i set a default value for the function to be an empty function so the user will not have to paste a function as a parameter ?

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Class Default Parameter As A Function?

Jun 30, 2009

Is it possible to set up a Class to have a Default Parameter as a new function? An example of Default Parameters:

Code:
function sayHello(somebody:String = world):void {
trace(hello, +somebody);
}

If so, what is the syntax for it?

View 3 Replies

ActionScript 3.0 :: Vector As Function Default Parameter?

Mar 3, 2011

Does anyone know what is the syntax to use for a function's default parameter when it's a Vector? You can easily create a default value for an int or Number or even an Array, but what about a Vector?

View 2 Replies

Flex :: Require A Function Parameter To Be A Static Constant Of The Function's Class?

May 22, 2009

Let's say I have a Custom Event Class, and it has several Event types stored in static Constant:

[Code]...

Is there an easy way to validate that the type passed to the Constructor is one of the Static Constants of the Class, without having to check it against each value?

View 5 Replies

ActionScript 1/2 :: Pass Parameters Along With A Function That Is A Parameter To Another Function?

Sep 3, 2010

I'm having some trouble passing parameters with a function that is itself being passed as a parameter.In my application code I'm instancing that class five times:they are buttons in a menu.In that class, I've got an onRelease handler that does a number of things when a button is released, one of which is to invoke a function that is defined in the application level of the code.My problem is that I don't know how to send the function parameters.In my StandardButton class I have:

class StandardButton extends MovieClip
{
/* define properties */[code]..........

The function is successfully being "sent" to the StandardButton class, but without any parameters.How can I send parameters to the class instance with the way I've got this architected.

View 7 Replies

ActionScript 2.0 :: Call A Custom Function From Another Custom Function's Parameter?

Apr 1, 2008

I want to call a function from another function's parameter but I don't know how and don't know if it is possible.I've considered this as a solution but it didn't worked.

Code:
function myFunc(target_mc:MovieClip, nX:Number, nY:Number, cFunc:Function) {
target_mc._x += nX;
targen_mc._y += nY;
target_mc.onPress = cFunc;

[code]....

View 2 Replies

Call A Function With Event Parameter When Have No Event Parameter To Pass?

Aug 14, 2009

Forgive me for this stupid noob question but I want to call a function (loadList) that originally gets triggered after a mouseevent from another function (addToXML) that does not have an event.

The loadList function takes info from a XML var, sticks it into an array which then gets loaded into a tile list and that is working fine.

The addToXML function when called adds elements to the XML var after which I want to call the first function with the event parameter so it refreshes the items in the tile list.

I know it can do this by creating a new array and loading that into the tile list in the addToXML function, but it be much simpler to just recall the function.

I have tried things like

Code:
addToXML.addEventListener(Event.COMPLETE, loadList);

but all the event constants I have tried give me error messges like "1061: Call to a possibly undefined method addEventListener through a reference with static type Function."

View 3 Replies

AS3 :: See If A Frame Is Empty And If It Is Then Call A Function?

Apr 3, 2011

Would it be possible to see if a frame is empty and if it is then call a function?

View 4 Replies

Flash :: Delegate Function (Function).toString() Prints Function Function() {}?

Nov 1, 2010

I've got a Vector of ViewToActionMap objects, which have following constructor:

public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,

[code].....

View 1 Replies

ActionScript 3.0 :: Getting 4 Parameter Arguments Into A Function From XML?

Jan 1, 2010

I'm designing a game that uses this function;

function moveBars(Bl:Number,Gr:Number,Or:Number,Ye:Number)
{
blueBar_mc.scaleX += Bl;
greenBar_mc.scaleX += Gr;
orangeBar_mc.scaleX += Or;
yellowBar_mc.scaleX += Ye;
}

When moveBars is called, the length of the 4 colored bars change to indicate how the player is doing in different areas of the game, like so; moveBars(.1,-.2,.3,-.1)

My problem; I need to store the moveBars parameter arguments in XML like so;

<myArgs> .1,-.2,.3,-.1 </myArgs>

But I can't find the way to get those 4 numbers into the moveBars parameters from the XML doc. Is there a way to do this?

View 5 Replies

ActionScript 2.0 :: Function Won't Accept A Parameter

Jan 28, 2010

Essentially, I have a function with three parameters, that works fine when I type in the parameter values. The function is tweens(MCname, targX, targY) and it runs properly when I use tweens(btn1, 150, 200) for instance. I need the function to move 6 different movie clips, one at a time, and I am using a variable (Counter) and an if statement to tell the function to run again after one of my tween classes finishes. The code all works, and it will run six times with the same clip if I just type in one of the movie clip's instance names as the MCname parameter.

BUT, if I try to use a variable (BTNname) to serve as the MCname parameter, it will not work, making it so I cannot apply the function to my 6 different movie clips. I put a trace on the MCname parameter, and it returns the correct value (btn1, btn2, btn3, etc) but it is not moving the corresponding movieclips. I've tried a number of different methods, but nothing will work.[code]...

View 2 Replies

ActionScript 3.0 :: Class Name As Function Parameter?

Sep 10, 2009

I wanna pass a class name as a function parameter.In that function I wanna make instances of that class, any1 know how?

View 1 Replies

ActionScript 3.0 :: Pass Function Parameter 'evt'?

Feb 24, 2012

I'm just looking for clarification on the passing of a parameter and why/how it works.

In this example, it looks like you create a parameter to be passed in called 'evt', but I don't see it used anywhere in the function. [code]...

View 9 Replies

ActionScript 3.0 :: Function Gets Null When Put It On A Parameter?

Mar 26, 2012

I'm trying to program a race timer with OOP, and I've been adding more and morefunctionality to its class. Everything had been running well, until I had the idea to put a countdown() function, to make a cool countdown effect. Things got worse when I wanted to make the countdown function to call another function when the countdown effect has finished.The code runs well when I first pass a function parameter from the Main class to the Timer'scountdown() function. The problem begins when I want that function to be past again on other private function of the same class, because this time, the function becomes nullOn the Main class constructor, I 've written the following line:

ActionScript Code:
timer.countdown(5, false, myFunc);
ActionScript Code:

[code].....

View 3 Replies

ActionScript 2.0 :: Set Optional Parameter For A Function?

Jul 17, 2005

lets say i define a function...

function myFunc(para1, para2, para3){
blah.. blah..
}

but i want para3 to be an optional parameter... can i do it..?

example..i will either use myFunc(var1, var2); or myFunc(var1, var2, var3); when calling myFunc function...

View 1 Replies

ActionScript 2.0 :: Sending Function Name Via Parameter

Dec 16, 2006

I am sending a name of a function via parameters to another function. This allows more usage of a single function. However, the button commands work every-so-often. The message appears everytime with no problem.

Code:
_root.msgReveal("This is just a random message. Click the ok button to close.", false, true, false, false, _level0.msgHide(), false);

Code:
function msgReveal(msgString:String, btn1B:Boolean, btn2B:Boolean, btn3B:Boolean, command1:Function, command2:Function, command3:Function) {
msg.messageBox._visible = true;
msg.messageBox.textF.htmlText = msgString;
msg.messageBox.btn1._visible = false;
[Code] .....

View 14 Replies

ActionScript 2.0 :: OnRelease Function With Parameter?

Mar 10, 2008

why this doesn't work:

Code:
listContainer.next.onRelease = advance(1);
listContainer.prev.onRelease = advance(-1);
function advance(d)

[code]....

I know I can reference a function onRelease without any parameters no problem, but what if I want to pass a parameter to the function?

View 5 Replies

ActionScript 2.0 :: Passing A Function As A Parameter?

Apr 25, 2008

I'm trying to do something like this and it doesn't work, but I get no errors.

callback = function(){
//bla bla bla
}

[code]........

View 5 Replies

IDE :: Decode Text Into A Function Parameter?

Aug 22, 2009

Simply said, I want to have an inputtextfield, a button that is linked to the textfield and a dynamic textfield as an display, to display stuff, which comes from the inputtextfield and the button.Then, I want to have items in the actionscript, like item1 = 5, or item1 = 1a, or 1a = item1. Just some code that equals to another code. But for now item1 = 5.For the button that is linked to the input textfield, has to calculate something when pressed and the dynamic textfield will display it. So if I would type in the inputtextfield 5 and press the button, it will be as example multiplied by 2, so the dynamic textfield will show 10.

Still following? The point is, I know how to set something like that up, but what I want is that when I type item1 in the textfield (which equals to 5) and press the button the dynamic text will show 10, because "2 x instance name inputtextfield" (in which intem 1 is typed, which equals 5) should be 10 right? But when I try to do this, the dynamic text will show nothing or some error. but when I type directly in the code "2 x item1" and press the button it will show 10. But I want it to double link, so "2 x (instancename inputtextfield which equals to what is typed in the field, this case: item 1 which equals to 5) and not that it stops to item1, so it will freak.

View 1 Replies

Flex :: Possible To Passing Parameter In Function?

Aug 19, 2004

I have several TextInputs in a certain form which have been assigned id in an incremental order. For example:

<s:TextInput id = "index1"/>
<s:TextInput id = "index2"/>
<s:TextInput id = "index3"/>

[code].....

View 8 Replies

ActionScript 3.0 :: Kill A Function If A InputTextField Is Empty?

Feb 21, 2010

I have a small aplication with two inputTextFields and a button, when the button is pressed it triggers a function that calculates the value in the two text fields, and everything is fine but when the textFileds are empty which is the default value and the button is press I get an error (Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.)how can I detect if the inputTextFileds are empty and some how kill the main function ?

function Name: calculate
Input Text Field 1: partL_txt
Input Text Field 2: partW_txt
Button Name: enterBtn

View 2 Replies

ActionScript 3.0 :: Set A Default Value For An Object In A Function Declaration?

Feb 7, 2009

Lets say I want to call a function with an optional Object, how do I write that?If it was a String or a Number or some simple data type it would be:

Code:
function foo(s:String="Sample String", n:Number=100):void{}

But anything I try with an Object just throws an error. For example...

Code:
function foo(o:Object={x:10, b:10}):void{}

...makes the compiler barf, and so does every other version of this I've tried.

View 2 Replies

ActionScript 3.0 :: Default Value For Array As Function Argument?

Oct 19, 2009

How do I put in an array as a default argument for a function ?eg

Code:
test();
function test(_arr:Array = new Array(0xFF0011,0x112233,0x000000))

[code]....

View 2 Replies

ActionScript 2.0 :: Set Default Values For The Parameters Of A Function?

Aug 12, 2010

How can I set default values for the parameters of a function in AS2? I am trying the common way but it doesn't work...

Code:
private function myFunction (param1:Number = 3,
param2:String = "a string",
param3:Boolean = false, etc ....):Void
{
....
}

View 2 Replies

ActionScript 2.0 :: Function Won't Accept A Variable Parameter?

Oct 22, 2009

For the record I am running Flash CS4, but am using actionscript 2.0 (its just what I know, and I don't feel like learning 3.0)-So I'm making a contact list, and each of the names will be clickable to bring up more information. There's going to be a lot of names, so I'm trying to keep the actionscript concise. The code is shown below in a simplified form, but essentially I have created a variable for the hexadecimal color, and I have created a function which will change the text color of each of the name buttons. This works, I have tested it. But, I don't want to have to tell the function to run for every single name button

(eg. changeColor (option1 , testColor);
changeColor (option2 , testColor);
changeColor (option3 , testColor);
etc..)

SO - I tried to create a for loop that would run the changeColor function for each button without typing it a million times. The one below should run from "option1" to "option5" for instance. I originally tried entering the equation "option" + i as a parameter, but it did not work. So I tried the code below where the for loop creates a variable which is assigned the value option1, option2, etc. as it runs through the loop. I added the trace code, and it is showing me that MCname is holding the correct value. However, the changeColor function still refuses to insert the MCname variable as a parameter. The testColor parameter is a variable, and that will work, so why not the MCname one? I also tried replacing the MCname variable with the name of a button (option1) and it runs fine. I just don't want to type in every single option name for the entire list.Sorry for rambling, but I'm trying to fully explain the situation.. If the code is all correct, why won't the changeColor function accept a variable for the first parameter? Is there a way I can get this to work without having to copy and paste the changeColor(option, Color) code for every button (there could be over 100 options)

CODE:
var testColor:Number = 0x33ff00;
function changeColor(buttonName , myColor:Number){

[code].....

View 5 Replies

ActionScript 3.0 :: Unable To Send A Second (or 3rd) Parameter To A Function?

Oct 18, 2008

I want to be able to send a second (or 3rd) parameter to a function that is called by an event listener, but I can't seem to get it to recognize the parameter - it gives me an error 1067 (implicit coercion of value) when I try the below code.

[Code]...

View 3 Replies

ActionScript 3.0 :: Window Parameter In NavigateToURL Function?

Nov 1, 2008

I have a frame based HTML file in which my SWF is displayed in the left frame.My SWF file has a button that simply,when clicked,displays a HTML file in the "rbottom" frame. Following is the code I used:

var a:String;
function aboutmeClicked(evt:MouseEvent):void {
var targetURL:URLRequest = new URLRequest("resume.htm");
navigateToURL(targetURL, "rbottom");
}
aboutmeB.addEventListener(MouseEvent.CLICK,aboutmeClicked);

Unluckily, when the button is clicked at run-time, the "resume.htm" file is opened in a separate window rather than in the specified frame.

View 8 Replies

ActionScript 3.0 :: Pass Parameter To EventListener Function?

Dec 1, 2010

how to pass parameter to eventListener function.[code]

View 1 Replies

ActionScript 3.0 :: Pass A Parameter To The Constructor Function

Mar 3, 2011

IŽd like to know how could use the Timer class extended.IŽm trying to pass a parameter to the constructor function, so I can use it inside the listener.
 
HereŽs example:
 
[CODE]
package { import flash.utils.Timer import flash.display.DisplayObject public class ChangeColorTimer extends Timer {    public static const CHANGE_COLOR:String = "changeColor";    public var obj:DisplayObject    public function ChangeColorTimer(delay:Number, repeatCount:int, obj:DisplayObject ) {   super(delay, repeatCount)   this.obj = obj   } } }
[/CODE]
 
That was the ChangeColorTimer that extends Timer.Now, IŽd want to know how would I use ChangeColorTimer.I thought it was the same as using Timer.IŽve tried this:
 
[CODE]
public function changeColor(mc:MovieClip):void  {   var colorTransform:ColorTransform = new ColorTransform()   colorTransform.color = 0xEE0000   mc.transform.colorTransform = colorTransform   var changeColorTimer:ChangeColorTimer = new ChangeColorTimer(400, 1, mc)   changeColorTimer.addEventListener(ChangeColorTimer.CHANGE_COLOR, setNormalColorListener)   changeColorTimer.start()     }  private function setNormalColorListener(e:Event):void{   trace("called")        }
[/CODE]
 
I called changeColor, but, I donŽt get "called" in the output from the setNormalColorListener listener.

View 2 Replies

ActionScript 3.0 :: Pass A Reference Parameter In A Function?

Mar 29, 2011

i want to pass by reference so i can use this variable outside the function.
 
What im doing is creating a global variable such as var cont:int; and then in a eventListener like enter_frame (stage.addEventListener..) calling a function called "mover", this function modifies "cont" value and i just want to print this value modified. The issue is i cant pass the value by reference just by const :S. The function is void, but if i change it to return int, its useless because each time i call the function, the value i want to return its created each time with a new value, beacuse i need to declare it so.. I read i can use a var such as Object but i really dont get it (im used to c++ i have to say)

View 3 Replies







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