ActionScript 3.0 :: Passing An Argument Using AddEventListener?
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
Similar Posts:
Apr 12, 2011
How do I pass arguments using ActionScript's event-listener?I have code, as given below, which creates a label, and I want, when clicked on the label it should pass the toolTip associated with that label. This is what I was trying to do:
public function create_folderpath():void
{
for(var i:int = 0; i < fm_model.absolute_path_ac.length; i++)
[code].....
View 1 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
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
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
Mar 3, 2009
So I have an MC that has 6 labels and 6 buttons all with different names. When you click on a button, it needs to direct you to it's appropriate frame label in the MC. Now, since AS 3.0 has done away with inline functions, how the heck do I code it so I don't have a function with a bunch of if statements inside of it in addition to all of my eventListeners that I have to add to each of my buttons? In AS 2.0, I would have done it like so:
Code:
function movePlayhead(whichOne:String):Void{
this.gotoAndStop(whichOne);
} button1_mc.onRelease = function():Void{
movePlayhead("label1");
};
button2_mc.onRelease = function():Void{
movePlayhead("label2");
};
Etc...
With AS 3.0, you have to add eventListeners to each of your buttons where each eventListener calls a function, but how can I write it so I don't have to write a bunch of if statements inside the function the eventListeners are calling in order to test for which button is being clicked? Like so:
Code:
button1_mc.addEventListener(MouseEvent.CLICK, movePlayHead);
button2_mc.addEventListener(MouseEvent.CLICK, movePlayHead);
button3_mc.addEventListener(MouseEvent.CLICK, movePlayHead);
function movePlayHead(event:MouseEvent):void {
[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
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
Sep 4, 2011
I have 2 methods in a class and 2 properties. The first method fetchXMLData() gets data from an XML file. In the addEventListener method on the urlLoader object, I pass it a listener which tries to set the returned data to the xmlData property. However, it never sets it, and I know the data comes back because I can alert out urlLoader.data using the mx.controls.Alert component.
[Code]....
View 18 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
May 5, 2010
How to pass a value to a function while its calling thru 'Montion_change' or 'Motion_Finish' or ....
here I try to pass a value to "tweenEvent function" while that function called... i m using a private variable inside 'mainfunction' (dont tell create that variable out the function ), i just assigning a string value to that variable. after this, i m starting a tween and when the tween started calling 'tweenFunction' using addEventListener,
Inside 'tweenFunction' function, i try to trace the 'Name' variable which is inside the mainfunction... not working
[Code]....
View 1 Replies
May 5, 2010
How to pass a value to a function while its calling thru 'Montion_change' or 'Motion_Finish' or ....here I try to pass a value to "tweenEvent function" while that function called... i m using a private variable inside 'mainfunction' (dont tell create that variable out the function ), i just assigning a string value to that variable. after this, i m starting a tween and when the tween started calling 'tweenFunction' using addEventListener,
Inside 'tweenFunction' function, i try to trace the 'Name' variable which is inside the mainfunction... not working.Here my code....
import fl.transitions.*;
import fl.transitions.easing.*;
function mainFunction() {[code].....
View 1 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
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
Oct 17, 2009
function test(myI,myX):void {
myI.x = myX;
}
lets say i have an instance name BigWindow so i use test(BigWindow, 100); but it doesnt work,
function test(myX):void {
for(var i = 0,i < 10,i++) {
BigWindow + i.x = myX;
}
}
and i have an instances named from BigWindow1 to BigWindow10.so i use test(100);it doesnt work too.what's the correct way of doing this two?
View 2 Replies
Jul 30, 2011
I've got all the major peices of my project but I need a steering wheel! I'm not sure how to enable the functionality of the app. Let me try to explain: I have 2 working getTimer timers in 2 class files. One is a 15 minute countdown timer. The other is a timer to call animations, but (here's the problem)i have 4 different sets of animations to call based on the users button selection. They are added to the stage with
ActionScript Code:
var countdown:CountDown = new CountDown(time_txt);//where time_txt is a TextField on the stage
addChild(countdown);
var Alerts:sniperAlerts = new sniperAlerts();
addChild(Alerts);
They kinda have to be called to the stage in this manner because I have some buttons that alter the time on the fly based on the Alerts and countdown var. I tried having 4 different alert files, but you can't declare them all as the Alerts var if you use different frames. In addition you can't repeatedly call the countdown timer as the same var because of namespace. I wish I knew how to make menu_mc to pass an argument to the stage that selects which animation set the alerts timer will process. Here's the alert timer with 1 set of animations to call:
[Code]...
View 0 Replies
Mar 17, 2009
What I want to do is to remove an item from the array targetArray when the tween hitFade has finished. I added a MOTION_FINISH event to the hitFade tween which calls the spliceTarget function. I wanted to send an argument to the function indicating the targetArray index to splice, but apparently I'm not allowed to send any argument.
how do I send the targetArray index (i) along to the spliceTarget function?
I'm guessing that I could put i into a global variable and use that in the spliceTarget function, but that seems kind of roundabout.
Code:
var hitFade:Tween = new Tween(targetArray[i], "alpha", Strong.easeOut, targetArray[i].alpha, 0, 1, true);
hitFade.addEventListener(TweenEvent.MOTION_FINISH, spliceTarget);
[Code]....
View 8 Replies
May 6, 2010
Is there any way to put 2 objects as the argument for a with statement. example:
[Code]...
I am aware I can use the statement like this code: with(bodyWrapper.fld){} Just wondering is there was a way of adding multiple objects to make typing shorter.
View 2 Replies
Aug 4, 2010
My question is, can a function bring in an argument and then use that argument as a class name? Here is an example:
Actionscript Code:
package {
import flash.text.Font;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
public class embedTest extends Sprite {
[Code] .....
Basically, if I have a swf with:
Actionscript Code:
var example:embedTest = new embedTest(Font1);addChild(example);
Can the class file bring in Font1 and use it as the class name.
View 8 Replies
Jul 6, 2009
I do not understand what is happening. This is the error I am getting:
ArgumentError: Error #1063: Argument count mismatch on sixties_fla::60s_1/forward(). Expected 0, got 1.
And this is the actionscript I am using:
pre_btn.visible = false;nex_btn.addEventListener(MouseEvent.CLICK, forward);
pre_btn.addEventListener(MouseEvent.CLICK, backward);
function forward() { nextFrame();
}function backward(){ prevFrame();
}
View 1 Replies
Mar 20, 2010
is any way to get argument for onFinishTween's function ?!
[Code].....
View 5 Replies
Jun 8, 2011
Ok I have gotten this far but it throws an Argument Error after the first sequence.
[Code]...
View 3 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