ActionScript 2.0 :: Passing A Function As An Argument?
Jan 12, 2004
I have a global function that does some stuff with a LoadVars in it.I 90% of the cases, the onLoad reference of the LoadVars is the same, but I sometimes need to do something else when the LoadVars is loaded.Is there a way to pass a function reference to a function so that I could do something like that :
[AS]
_global.function myFunction(maybeFunction)
{
myLoadVars = new LoadVars();
[code]...
View 1 Replies
Similar Posts:
Apr 21, 2010
How do I execute callback functions dynamically by passing a function in as an argument to another function?
Look at this example:
Code:
package {
public class myClass extends MovieClip {
public function myClass(callback) {
[code]....
View 2 Replies
Jan 12, 2004
My question is slightly complicated : I have a global function that does some stuff with a LoadVars in it. I 90% of the cases, the onLoad reference of the LoadVars is the same, but I sometimes need to do something else when the LoadVars is loaded. Is there a way to pass a function reference to a function so that I could do something like that :
[Code]....
View 1 Replies
Sep 29, 2010
Well I want to set up a function that will calculate the x position of where my MovieClip's instance name will go. Here is the code i currently have.
function xBtnPosition(btnName: String, btnXpercentage: Number):String
{
var xFinalPosition: String = -(((btnName.width * btnXpercentage) / btnName.scaleY));
[code].....
View 3 Replies
Sep 8, 2009
I saw a post that touched on this, but I thought it deserved a thread of its own for explicit verification. It seemed that some of the resident geniuses here had given the thumbs-up to passing your whole doc or app class to a function. Please correct me if I'm wrong, as this sounds convenient but I assumed it would cause heart attacks and CPU meltdowns.
EXAMPLE: Say I have an app class that controls my entire game (or slideshow), and it has an ENTER_FRAME scrolling function that's 50 lines long with tons of conditionals so I want to take it out and make it an external file. I pop it into a new .as file but now all my variables are out of scope. I could pass them each individually, but there are so many it's impractical. So my question is: good or bad practice to pass the entire class?
[Code]...
View 4 Replies
Feb 26, 2012
I have a .swf file through which i am passing arguments to .exe file which is basically a C++console application, how is it possible, should i tweak the sourcecode in th application file for it to accept the arguments passed?
View 1 Replies
Sep 28, 2009
I had been trying finding a way to passing more than one arguments using FlashVars. Below is the snippet of HTML code, using this parameter:
HTML Code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,
[code]....
View 3 Replies
Jul 28, 2009
The transition from AS2.0 to 3.0 has been a long and broken trail for me.
Is there a way to pass arguments to a function via addEventListener, like (but unlike) this: timerTurn.addEventListener(TimerEvent.TIMER, moveUnit, "unitname", "unitdirection")
where moveUnit is the function I want triggered, and "unitname"/"unitdirection" are the arguments?
View 1 Replies
Jun 26, 2010
So i have this function
capture_mc.buttonMode = true;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
function captureImage(e:MouseEvent):void {
[code]....
View 2 Replies
Apr 11, 2011
So far, I have a class that creates a Vector object, and pushes data into it:
ActionScript Code:
public var mList:Vector.<cusClass> = new Vector.<cusClass>();
The data is read by a second class like so:
ActionScript Code:
trace(firstClass.mList);
The problem Im having is take that same Vector and passing it into a third class (from the second class) as an argument in a method: ActionScript Code: views.mUpListing(firstClass.mList);
[Code]...
View 2 Replies
Jan 25, 2008
I am using a carousel with items in it...when the user clicks an item in the carousel, I want a new swf to load to _level0 and replace the carousel on the stage...the new swf reads an xml...however the xml should be different for every item on the carousel...is there any way to pass the xml file name to the loadMovie command so the new swf can use it?
View 2 Replies
Apr 21, 2010
I am wondering what is the way of passing and argument to a listener.. doing something like this:
Code:
myThing.addEventListener(Event.COMPLETE, doThis(arg));
function doThis(e:Event, arg:int){
...
}
What is the proper way, i this doesnt really brake the code, it doesnt work either...
View 11 Replies
Aug 7, 2009
I had a class that I was passing a simple argument to like so:
var quiz_1_2:CaseStudyQuiz = new CaseStudyQuiz(2);
addChild(quiz_1_2);
I now would like to use this class for multiple MCs in my library. I thought I could let Flash create a class for each of them and specifying the CaseStudyQuiz class as the Base class. When I do that, I get the following error:
1136: Incorrect number of arguments. Expected 0.
View 12 Replies
Oct 16, 2009
We can pass arguments to flash from javascript like this
fc.callFunction("_root","js_playSong",["Path=songs/song1.mp3 &Album=Jazz"])
where fc is a JSFCommunicator.
But how to pass argument like this
fc.callFunction("_root","js_playSong",["Path=songs/song1.mp3&ArtistPath=http://sample.php?artist_id=24&name=kamal"])
In the above argument the red colored ampersand should not be considered as separator between two variables.
View 1 Replies
Nov 19, 2009
I have one event handler for several object's events. I would like to pass a value through to the function from the event listener:
function chkEmpty(event:Event){
if(event.currentTarget.text==){
thisIsBitIWantToBeAbleChange.text = You haven't entered anything in the box, please try again
hisIsBitIWantToBeAbleChange.setTextFormat(validate_frmt);
}
}
Could I give the event.currentTarget a value that I could test for? So if the value is 1, I effect output1_txt, if 2, output2_txt, etc etc. If so, are there customisable values that I could use that wouldn't do anything to the display object,?
View 8 Replies
Oct 3, 2009
I'm trying to figure out how to set a MovieClip return value by passing a string argument and using that string to define the child of a given movieclip. I'm doing something wrong because I keep getting null traced instead of home_mc.[code]
View 2 Replies
Mar 20, 2010
is any way to get argument for onFinishTween's function ?!
[Code].....
View 5 Replies
Nov 11, 2009
How can I pass a 'set' function as the Function Object argument of another function?eg:
public class IdModel
{
private var _id:String;
[code].....
View 1 Replies
Sep 29, 2011
I want to guess the type of every argument from an anonymous function, something like mapping a class with reflection but just for a function, something like...
public function guessMyArgumentType(f:Function):void {
for each (argument:* in f.arguments) {
trace(typeof(argument));
[code]......
View 1 Replies
Dec 31, 2010
I have an extended MovieClip class that has 10 Boolean properties. There are 6 instances of the clip on the stage. Any of the properties of each instance can be set independent of the same property in other instances, so...
[Code]...
View 2 Replies
Apr 16, 2011
In the code I want to call the function like this _root.onMouseUp=do("xyz"), but the way is not correct.
Code:
function do(abc) {
trace(abc)
}
[Code]....
View 3 Replies
Jul 21, 2009
im trying to pass in an optional argument into a function. The datatype of this needs to be an object... however, im not getting very far. I know i can do this....
[Code]....
View 3 Replies
Nov 19, 2009
I want to add about 10 textBoxes and I want them all to be contained in different variable names. I need to declare them outside the document constructor function because of scope, but how then can I use them in a function? I want something like
[Code]...
View 1 Replies
Dec 29, 2009
So I guess the usual stuff is to have
function listenToEvent(evt: Event){
//stuff
}
[code]......
View 1 Replies
Feb 22, 2005
I want to write a function which has 2 dimensional array as one of its arguments
_global.getList = function ( type:Number, list[]:Array )
This is giving syntax error, if I do
_global.getList = function ( type:Number, list:Array )
Then there is no error, but then, list is now, single dimensional array, which I don't want. Whats the correct syntax to write it as two dimensional array?
View 1 Replies
Mar 14, 2009
I have recently moved from AS2 to AS3 and I am finding the transition fairly easy, however I do have a few questions, some of which may not have been possible with AS2 but I would like to achieve them in AS3
1. Is it possible to pass the name of a class as an argument in a function and then use it to create a new instance. e.g [code]
2. Carrying on from the previous question, if a class can infact be passed, can I specifying a variable type for the argument so that only classes and not instances will be accepted?
3. I have three class files that all inherit some functions and variable from another class called Ship. Is it possible to specifying a variable type so that the variable can only hold instances of classes that are inherited from the Ship class?
View 6 Replies
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
Nov 19, 2009
having some problems understanding how I can bypass function arguments without changing its default value. Here are some examples:
function myFunction ( arg1:Boolean, arg2:String="default string", arg3:Number=3 ):Array{ return new Array (arg1, arg2, arg3);}
trace(myFunction(true, "new string", 5));// true,new string,5
[code].....
View 4 Replies
Jan 21, 2006
im tryng to call a function with a argument in the ContextMenuItem class.[code]It seems that when ever I try to send an argument with the down function, it simpley dont work and without it, it does work
View 1 Replies
May 16, 2009
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var animTween:Tween;
[Code].....
I have figured out the following: Well, as you see the function moveStuff accepts three arguments, namely:
objectdurationeasingWhen easing has a default value, I get an error. But if it doesn't have a default value, then it works fine, the code would look like so then:
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var animTween:Tween;
[Code].....
View 5 Replies