ActionScript 2.0 :: Getting Value Of Arguments.caller Within A Function?
Feb 18, 2005Is it possible to trace the name of arguments.caller property?
I tried
Code:
trace (arguments.caller.toString());
but that doesn't work.
Is it possible to trace the name of arguments.caller property?
I tried
Code:
trace (arguments.caller.toString());
but that doesn't work.
Is it possible to trace the name of arguments.caller property? I tried Code: trace (arguments.caller.toString()); but that doesn't work.
View 4 Repliesin this case this.name return me root1
i was expecting the name of the function caller witch is a btn dynamicly created on stage (see exemple)
var facebook:SimpleButton = new socialIconFacebook();
addChild(facebook);
facebook.x = 134;
[Code]....
i know i could put the url right there instead but i have a lot of btn who would use that function
I have this code but I cannot work out how to fill in function parameters based on an array and it's length, see line 7
[AS]
import com.robertpenner.easing.Cubic;
MovieClip.prototype.framesTimeout = function(func:Function, frames:Number, args:Array) {
[code]....
Is it possible to call a function and fill in the parameters based on an array and it's length?
If I've got a public function in a class that I know is being called from an object outside the class, is there any way to access either a reference to the calling object or at least the calling object's type from within that function without passing the caller through as a parameter?
View 3 Repliesi have a question i have a primary and secondary function which i want it to be dynamic so i can get the user to enter in six to seven different or as many as required argument parameters for my primary function
[CODE]...
I'm trying to build a class for objects in my prog that can by manipulated in various ways.. I want right clicking them to send them to back, and left clicking, bring them to the front.
ActionScript Code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
[code]....
When I run it, however, I get ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.So something's not lining up, but I'm not sure how to write it so it'll work.
I have tried to grasp this concept, but cannot believe the cluster F that as3 has done with loading a swf and then removing it.Whereas in As2, you would simply loadMovie into a movieClip's instance name. If you wanted it gone, you could simply replace it with something new, or unloadMovie. Simple.Now...to even load a movie in...you have to create variables, create a movie clip, create a loader, then create a url request, then load that url request into the loader, then addchild so that the loader is on the stage? And to remove it, is next to impossible.So here is my code..
function loadMovie (){
var my_mc:MovieClip = new MovieClip();
var my_Loader:Loader = new Loader();[code]....
That code when tested gives me....Error #2025: The supplied DisplayObject must be a child of the caller. When I try to run the removeMovie function.
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?
I have a component that I hand over a function
public var func : Function;
Now the function is a function that has parameters in its signature
public function myFunction(s : String) : void {
doSomething(s);
}
from my component I can call the function with
func.call();
how to invoke the function with its parameters?
I have a movie clip that contains several movie clips, only one of which should be shown at a time. Which one is shown, depends on what buttons the user selects.Having trouble with the syntax for passing the argument in a button to the function that controls the tweening of the clips. (When I hard code the references into the function, it works, so I know the basic function is ok).There's a clip called 'slide1_mc' which contains various MC's to be shown based on user selection (in this case, using 'system' clip as the first one already showing). Here's the code in the parent clip of that item:
Code:
var currSection = slide1_mc.system_mc;
function changeSection(newSection):Void {
TweenLite.to(currSection,.3,{_yscale:200, _xscale:200, _alpha:0});
[code]....
Here's one of serveral buttons that will control the content to be seen:
The code in the button is:
Code:
var changer = slide1_mc.software_mc;
smallButton.onPress = function() {
_parent.changeSection(changer);
};
So - the initial part of my function works so I know my 'external' initializing of "currSection" is working (that clip is zooming/fading out)... but then the clip that I want to fade in isn't doing anything.
I want to add things to the display list, some will have event listeners and some not. Is it possible to make an argument optional so it doesn't throw an error if it's not there when calling the function?
View 2 Repliesi have been playing with the Zend Tutorial - and all works fine... however, stuck on something that i found quite easy in amfphp/as1&2
In AS3 - i am using NetConnection and i want to pass arguments to my php function
The first function i show here works fine....
inMyPhp...
Code: Select allpublic function getTutorials()
{
$result = mysql_query("SELECT * FROM testTable");
$t = array();
[Code].....
I'm having a little problem with how to use the argument sent to a function.I have this:
Code:
_root.onEnterFrame = function() {
setPanning(1);
[code].....
I dont want it like the classic way listenerThumbs.onLoadInit = function(target_mc:MovieClip)But with the Proxy.create class, how do I get the arguments of the moviecliploader? (ex: target_mc, loadedbytes, totalbytes)Now I did it like this, but it has to be different.[code]
View 1 RepliesIn my database i have a field called "live", and i only want to grab entries in a table that have "live" set to "1"
This is what i have tried, but it doesn't work....
InMyPhp...
PHP Code:
public function getTutorialsLive($live)
{
$result = mysql_query("SELECT * FROM testTable WHERE live = '%s';", $live);
[Code]....
lets say I define a function that does a simple trace of the arguments it takes in, now is it possible to have multiple arguments? like sometimes i want to send in a String argument, sometimes a Number, and sometimes an Array.Do I need to create the same function 3 times to accommodate for the 3 different inputs or is there a way I can keep one function but send one of the 3 values.
View 3 RepliesI am creating the columns of a datagrid dynamically at run time and I need to allocate the sort compare function to those columns based on the data type of that column, is there a way I can pass some argument to that compare function which could tell the function what type of column is it going to operate on?
View 1 Repliesif i have function :
function a( param:* , ... args ):void ;
a.length // 1
flash.utils.sdescribeType(a);
//return me informations only about first parameter , nothing about '... args'.
edit: avmplus.describeTypeJSON didnt too. So , is there any other way to check for unlimited arguments than try{} block and push lot of params ?
How to pass boolean arguments to a function[code]On the stage i have all the MC - screenX, alarmsX, criticalX, majorX,warningX, redX, orangeX, greenX.But i get errors:Scene 1, Layer 'Layer 1', Frame 1, Line 171119: Access of possibly undefined property visible through a reference with static type Boolean.for each of the MC.
View 9 RepliesLet's say I have a function that accepts a function and some arguments as parameters. Something like:
ActionScript Code:
function myFunction(func:Function,args:Array):Void{
// do something awesome here
};
How would I go about calling this function with the arguments in args? It's pretty simple to call a function without any arguments, but calling it with them..
As an example:
ActionScript Code:
// I'd like this call
myFunction(trace,["Hello world!"]);
[Code].....
I have four NetStream objects that receive cuepoints from different videos. I'd like to define one function for them all instead of using four inline functions and I'm stuck with syntaxHere's the code:
Code:
ns1.onCuePoint = callCuePoint;
ns2.onCuePoint = callCuePoint;
[code].....
I have a main class that is running an external sub class which loads my data (loads data via flash remoting on a ColdFusion server). No problems loading the data; however, I am trying to run a function from the main class on the sub class function onResult. I do not have problems running functions in the sub class in general, only in the responder result function. Problem: My problem is that I can't pass the main class through the function onResult because I get a error with the arguments.Here's what some of the code look likes:
function init(){
myService2.connect("URLgateway");
var responder:Responder = new Responder(onResult, onFault);
[code].....
Is it possible to wrap a variable-length-arguments function in Actionscript?[code]but it didn't work since sprintf was called with just 1 extra argument, i.e. the Array args.
View 2 Replies[Code]...
I have an object that has all the elements I would want to pass arguments: var args:Object = { 'dog', 11, myArray }; and I want to be able to pass the contents of args to doSomething without making any changes to doSomething (assume it's someone else's function) and I'd like to do it in a way that doesn't assume I will know anything about the contents of args.
For example i have function declared in AS3.0 class:
private function log():void{
// working with arguments directly here
}
I'm calling:
log('some stuff',object,array,etc);
Then i'm calling:
log('ok');
Ofc FlashBuilder throws exception with: type 1137: Incorrect number of arguments. Expected no more than 0
In javascript it's possible. But in AS not, isn't it's ECMA based? Why so strict...
Update
Ok nvm. Created like that atm: log(m1:*=null,m2:*=null,m3:*=null,m4:*=null,m5:*=null):void{}
Is there any way to pass an argument to a function being called by a ContextMenuItem?The effect I want would be what one might expect from this pseudocode:
Code:
var cm = new ContextMenuItem("Start Alt", set_row_style('start_alt_here'), separatorBefore=true, enabled=true, visible=true);
Which obviously doesn't work, or I wouldn't be asking.So far I've tried using the captions as a basis for a switch condition, which works.
Code:
function set_row_style(obj, cm) {
switch (cm.caption) {
case 'start_alt_here' :
...
But I'd rather not use an arbitrary string as part of a function.The only other option I see is using a listener for each ContextMenuItem, then calling the function with its arguments from there.Is there any more direct a way to pass an argument to a function from a ContextMenuItem?
I am having a problem with this code:
ActionScript Code:
public function createEnemys():void {
Levels[1]=[[5,1,1,1], [5,1,1,2]];
Levels[2]=[10,1,1,2];
var i:int;
[Code] .....
And I am getting this error:
ActionScript Code:
1136: Incorrect number of arguments. Expected 4.
I am trying to create 2 different enemie, other having "5,1,1,1" properties and other "5,1,1,2".
I want to have an array, where each value is a function, where each function also has a set of arguments.
What is the correct syntax for setting a value of an array as a function?
Lastly, how do I pass arguments into the array's value?
Code:
var funcA = new Function(a:Number, b:Number){return a + b};
var funcB = new Function(a:Number, b:Number){return a - b};
var funcC = new Function(a:Number, b:Number){return a * b};
[Code].....
I have an array with some values and i want to pass this values to a function arguments.
example
var theArray:Array = new Array("test1","teste2","teste3");
function hello(t:Number,a:Array){
// do something
test(a)
[Code]....