ActionScript 3.0 :: Using The 'arguments' Object?
Jan 8, 2012if there's a way to use the 'arguments' object (to get info about a function like: 'arguments.length' etc) outside the function definition code and if yes, so how to that.
View 5 Repliesif there's a way to use the 'arguments' object (to get info about a function like: 'arguments.length' etc) outside the function definition code and if yes, so how to that.
View 5 RepliesI just started using object pooling and I have some problems with passing arguments. I made class "Circle" which needs 3 arguments when instanced and I try to push it into the pool.
[Code]....
I want to pass through configuration arguments to a class. These are all the optional vars that go into configuring the class - and should be able to run in any order.
at the moment i just pass through the optional vars the regular way. Supposing the constuctor was like the following:
private var _reqVar:String;
private var _optVar1:String;
private var _optVar2:String;
[Code].....
assigning the argument to the var of the same key (i know in php to reference a variable name from a key you can use $$key = $value, is there an equivalent in as3?) display an error (using the 'throw' method) for variable names not supported by the class
[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.
Is this possible ? If yes how ?Otherwise what's the alternatives ?
By dynamically I mean using
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
[code].....
I have a "format" method that works in a similar manner to the C# String.Format method, with the following signature:
[Code]...
I have this piece of script, where I want to do a hittest when both the x AND y are not the same (and some other variables) now, that wouldnt be so hard, you think: if (MovieclipA.x!=MovieclipB.x && MovieClipA.y!=MovieclipB.y) but! if i now have a MovieclipC, which is on the same y coordinate as A, but not on the same x coordinate, the hittest wont execute..., as the y coordinates match...
it probably is really simple, but how can i solve this problem?
Code:
function createJustifiedText(name, depth, x, y, width, text, format) {
this.createEmptyMovieClip(name, depth);
[code].....
I need to pass some value, say 'name=john', from html to actionscript.I am now using AC_FL_RunContent as;
AC_FL_RunContent(
"src", "newFile",.... );
here the movie is mensioned as 'newFile'.. how do pass the value 'name=john' to the actionscript code.what I need is something equivalent to "newFile.swf?name=john".
I'm doing a little flash nav bar and I'm trying to have the buttons link to the correct web pages. My code is extensive and I'd rather not post the whole thing in here so I'll try to be as concise as possible.Basically I'm getting this error:1137: Incorrect number of arguments. Expected no more than 1.Everything was running smooth in my script until I added the URL requests here:[code]Is the syntax incorrect or something? Again, everything was fine up until I added those two at for case 0 and case 1.
View 3 RepliesI'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 need to parse the parameters from one function to another as arguments rather than an array.[code]The problem is there that when the wrapping function 'push' has the arguments parsed, on the inside it is an array, meaning that when _array.push is called with the parameters variable, rather than the elements of parameters being pushed on, the entire array gets pushed on making it multi dimensional.I've tried to search for ways to split an array into seperate arguments, and number of arguments needs to be dynamic, so parameters[0], parameters[1] is no good in this case.
View 1 RepliesIs it possible to use javascript to call a method in as3 and pass in an object argument?This would act as a setter in some sense.
View 4 RepliesI 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?
How to sart Adobe Air App with arguments, is it possible, at least with native apps?
View 1 RepliesI'm really new to actionscript so I'm not even sure how to ask this. First off I'm not using any Adobe IDE just notepad with flex as a compiler. What I want to know is how to make a class but make it with arguments and then have that class use those arguments.
The only way I can clarify what I mean is through an example. So for example say I have my main class and a class called square. Now I think (and i could be wrong) I can 'make' a square class in the main class by simply saying new square(); in some function of the main class. But lets say I want this square class to have a x and y value. Would I establish this by saying new square(x,y); in the main class (where x and y are integer values)? If not how so? Also how would I get the square class to read these values? How would I go about getting the square class to draw a square with its center at the x,y given to it in the main class?
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 RepliesIs it possible to pass on arguments.. see simnple code
Code:
proxyFunction = function(theEvent:String){
var alen = arguments.length
[code]......
I am teaching myself AS3 and using FlashDevelop for all of my work (so far so good) and I have hit a snag with passing arguments.What is the best way to pass arguments of one array to another? Ie, I want the Harvester class to have visibility to the Resource class so I can do some iteration.
View 6 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 have a music jukebox, with ten buttons. in the first keyframe, of the main timeline, a put a function that will be used for every button to load the mp3 to play. The problem, is that when i pass the arguments on each button to call the function, the "filme" and "som" arguments are lost.
here is the function:
function carregaSom(filme, som, url, msg1, msg2, tempoComeco){
_root.createEmptyMovieClip(filme, 1)
som=new Sound(filme);
[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].....
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 pass arguments "by reference" instead of "by value". I know it's possible in almost every programming/scripting language I came across until today, but I didn't find any hint for doing it in Actionscript For those who don't know what "by reference" means: If you want to pass a Number to a function, say
Code:
var mynumber:Number = 5;
calculate(mynumber);
and you change the value of the argument inside the function, e.g.
[code]....
then the call to calculate normally does NOT change the value of mynumber because you have passed mynumber "by value", which means the value of mynumber has been copied to the num argument. This means mynumber is 5 all the time.Now sometimes u want to be changing arguments given to a function inside the function, and this is where u will normally use references. Passing mynumber "by reference" would mean that after calling calculate the value of mynumber will be 6...I know complex Objects like MovieClips are passed by reference. But how to do it with simple DataTypes like Number, Boolean etc.?
Is it posible to have predefined arguments in a constructor so if the user doesn't enter one it takes the default value? I tried doing it this way:
[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]....
I must be in space suffering oxygen deprivation because I can not remove this error nor understand why it is occurring."1136: Incorrect number of arguments. Expected 1."
package bna{ import flash.display.Sprite;
public class BNALesson extends Sprite {
public function BNALesson() { var sX:int = 16;
[code]....
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 Replies