ActionScript 3.0 :: Passing MouseEvents Of Different Types To Same Function?

Sep 21, 2009

I was just wondering if there are any problems that could arise from passing MouseEvents of different types (i.e. MouseEvent.CLICK or MouseEvent.MOUSE_DOWN) at different times to the same function? I've already built my project, and it seems to function fine, I just want to make sure that I'm not setting myself up for some problems in the future. I understand it's probably not the "cleanest" or "best practice" to construct my project in this manner, but if it works...

A simplified example:
PHP Code:
// This is the function that I want to call from varying places with different MouseEvents and triggered by different event listeners
function myFunctionA(evt:MouseEvent):void{
[Code] .....

Actually, in writing that, I may have answered my own question, because it seems that myFunctionA is simply expecting a MouseEvent... regardless if that event is CLICK or MOUSE_DOWN or MOUSE_UP event, right? Now, a MouseEvent.CLICK may have different properties than a MouseEvent.MOUSE_UP that I can access within myFunctionA; however, that shouldn't matter to the function, or is my thinking flawed?

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Converting Variable Types For Passing In A Function?

Mar 17, 2009

I'm trying to write a robust "eventMaker" function that I can run with arguments that will then create an event listener based on the arguments.

However, I can't seem to get it to pass the arguments. Functions are impossible to pass; it can't convert string versions back to functions, and passing the function as type :function just yields "function() function{}".

The same is true with strings and class definitions - if I want it to refer to an object in my other .AS file called "helloWorld", I can't make it think of helloWorld as anything other than a string or an object, and when I write commands based on it I get errors.

So how do I contain classes, functions, et al in variables that I can then reference again, in code, as those functions/classes? How can I convert a string value to something that the code will know is a reference?

View 3 Replies

Actionscript :: Passing Reference Types By Ref - Flex

Jun 30, 2010

I know that in C# when you pass an object (non primitive) to a method the following is true: A reference to the object is passed Changes made to the object in the method are reflected outside of the method. Also, you can pass a reference to a reference in C# e.g this.changeObject(ref myObject);, in which case: Changes to the object and also to the ref are reflected outside of the method e.g. myObject = new new List(); would change the passed objects referred location. Is this possible to do in Flex/Actionscript - can a ref keyword be used?

View 1 Replies

ActionScript 3.0 :: Passing Complex Types To Php With AMFPHP 2

Jan 13, 2009

Passing a complex type to PHP with AMFPHP 2. This 'sort of' works, sort of in that I can pass an AMF object to a service, and I can echo that object back to Flex/Flash, but I cannot access the contents of the object in PHP.

A simple service

[Code]....

We get null. - Now I am assuming this is some sort of serialization I am missing, does anyone know what it is?

Edit - also worth noting when passing an Array to AMFPHP I have no problems accessing the data

View 2 Replies

ActionScript 3.0 :: Create Different Variable Types From Single Function?

Jul 26, 2010

This is hard to describe in a sentence, so i'll write some false code: (with incorrect syntax, of course)[code]...

Is it possible to do something like this, where I pass the name of the data Type that I want it to create and it does it within the function? And I know that with this simple example it isn't necessary to do it this way, but in the full program this would save some time and make the code more efficient.

View 7 Replies

ActionScript 3.0 :: Map Data Types To Custom Types?

Jan 24, 2012

Consider the following function:

Code:
public function foo(bar1:int, bar2:uint, bar3:String, bar4:Boolean):void{}

What I want is to have the different types of data represented by custom named types which are essentially representing the original data types. I other word, I would like to proxy the data types and have a valid function as following:

Code:
public function foo(bar1:PAR_Bar1, bar2:PAR_Bar2, bar3:PAR_Bar3, bar4:PAR_Bar4):void{}

so PAR_Bar1 would proxy the `int` data type, PAR_Bar2 would proxy the `uint` data type, so on and so forth.

The reason I need this is because I'm using a debugger with a GUI that can run methods and allows changing function parameter values in real-time, the issue is that the debugger can't tell me what parameter I'm changing, it only displays the data type of a parameter. So if I need to change 10 different parameters all of type int, the debuggers display all of them as int and not by their names.

I think that if I use proxy types I can easily differentiate between parameters.

So, my question: Is it possible to proxy data types? I mean map specific data types to custom data types that would represent the base data types?

View 2 Replies

ActionScript 3.0 :: Calling A Function Sending Different Data Types As Parameter?

May 23, 2009

In my code there's a function that shows an image on the screen (or loads the image and shows a progress bar). This function is called by clicking on a thumbnail, and it uses a parameter [e.target.name] refering to the property "name" of the thumbnail clicked, which is an integer (or I believe so). The thumbnails are placed inside the cointaner_mc MovieClip.

Code:
container_mc.addEventListener(MouseEvent.CLICK, clickThumb);
function clickThumb(e:MouseEvent):void{
if (my_full_images[e.target.name] == undefined){[code]...

but I want to call this function by clicking on a button, which would need to pass another type of parameter, in this case, a variable which refers to the number of the image displayed on the screen plus one.I tried this:

Code:
clickThumb(image_num + 1);
But it doesn't work, I get the following error:

1067: Implicit coercion of a value of type Number to an unrelated type flash.events:MouseEvent.

How could I call the function clickThumb and make it use "image_num + 1" instead of "e.target.name" ?

Could I dispatch the event (MouseEvent.CLICK, clickThumb), passing this value "image_num + 1" ?

View 2 Replies

ActionScript 3.0 :: Execute Callback Functions Dynamically By Passing A Function In As An Argument To Another Function?

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

ActionScript 2.0 :: Passing Variable To Function Inside Function?

Sep 16, 2009

I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).

ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",

[code].....

View 1 Replies

ActionScript 3.0 :: Passing A Var From One Function To Another?

Apr 20, 2011

I im trying to pass one a var from one function to another, Im trying to pass 'THICKNESS' from 'moveMouse' to 'mouseDown'.

ActionScript Code:
var THICKNESS:uint = 1;
ActionScript Code:
function mouseDown(_x:Number, _y:Number):void {

[Code].....

View 4 Replies

ActionScript 3.0 :: Passing A Function Around?

Feb 24, 2009

so, i think it's just cause it's the end of the day and my brain wants to quit, but i would like some input.

im trying to pass a function to a question box that when you click the YES button the function passed in will fire for some reason im having a hard time holding the function until the YES is clicked.

here is what i got Code: //the call that opens the choice box and sets the info the gui_obj part is cause the //funciton is in a separate class file gui_obj.displayChoice("Add the cell phone to your inventory?", "YES", "NO", gui_obj.addToInventory(item))

[Code]...

View 5 Replies

IDE :: CS4 - Passing XML File Name To Function

Aug 19, 2010

I'm new to AS3, I have an index.swf that loads thumbnail images from this file (projects_list.xml). When the user clicks on a thumbnail image I want it to pass the selected thumbnails "link" node information to the callFull function. You can see that I have managed to get it to work when I use the real path name. I just can't figure out how to pass the link node text.

Projects_list.xml file set up
Code:
<project id="0" name="Con" thumb="portfolio/images/con/thumbs/web_1_200pix.jpg" htm="" link="portfolio/xml/desc/desc_con.xml"></project>
desc_con.xml file set up (details file)
[Code].....

View 1 Replies

ActionScript 3.0 :: Passing A Variable Into A Function?

Mar 19, 2009

I have 3 movieclips in the Libarary, called (both by name and class) section0, section1 and section2.This works for instance to attach a movie clip to the stage:

Code:
var myMovie:MovieClip = new section1;
addChild(myMovie);

[code].....

View 2 Replies

ActionScript 3.0 :: Passing Variable To Function?

Feb 21, 2011

Trying to create a random movement for fish MCs:

//----------------------
var deg2rad:Number = Math.PI / 180;
var speed:Number = 1;// set to speed you want
var numFish:Number = 4;

[Code].....

Problem I have is that they all move to the same angle (the last one created).

How do I pass the different "my_angle" values to the "move_me" function...?

View 7 Replies

ActionScript 3.0 :: Passing Variable From A Function?

May 6, 2009

How do I pass mulitple variables from a function using AS3? Does this have to be done using a Class?
 
example:

var endValue; // variable I want to fill
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, dataLoaded);

[Code].....

View 8 Replies

ActionScript 3.0 :: Passing Variable With Function

Jun 8, 2009

This is a function on the first frame of a .fla updated to AS3 from an old AS2 file:[code]When the function is called it should set "max_messages" to 600 in AS3, right?

View 1 Replies

ActionScript 3.0 :: Passing A Function To AddEventListener?

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

ActionScript 2.0 :: Passing Arguments To Function?

Oct 8, 2009

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.

View 0 Replies

ActionScript 3.0 :: Passing A Sprite Into A Function

Jan 20, 2010

I'm creating a jeopardy like game and have run into a problem. when you click on the dollar amount a create a sprite on the fly and inside the sprite is a shape and some textfields. One of the fields is an input box. once you enter in an answer and press enter I create another sprite with a textfield inside it to let you know if the answer is right or wrong. Herein lies the problem. once your told if your right or wrong, I want the sprites to stay on the screen for 3 seconds then disappear.

I can get them to stay on the screen, but I can't get then to disappear because I can't pass the sprite to the function that I created to remove them. So everything works except the remove function. This is the error I get when the remove function runs: "TypeError: Error #1009: Cannot access a property or method of a null object reference."

I'd post some code but its broken What I'm looking for is just information on how to assign a sprite to a variable so I can use it in a function. if thats not possible then is there a better way to do what I need done?

View 2 Replies

ActionScript 2.0 :: Passing Variables Through A Function

Aug 5, 2010

Hello, I'm trying to minimize code, so I am trying to use functions, and need to pass some strings through them in order for it to work.I believe I may be doing this incorrectly, so could someone please take a look and tell me what I'm doing wrong? On one of my movieclips:

[code]...

What that previous code should do is loop through all movieclips in the game and if it's not named player, move it in accordance to what "Direction" is.If the player is pressing the arrow down key, it will change "Direction" to "DOWN" and hopefully pass it.

View 4 Replies

ActionScript 3.0 :: Passing Xml File Name To Function?

Aug 19, 2010

I have an index.swf that loads thumbnail images from this file (projects_list.xml). When the user clicks on a thumbnail image I want it to pass the selected thumbnails "link" node information to the callFull function. You can see that I have managed to get it to work when I use the real path name. I just can't figure out how to pass the link node text.

[Code]...

View 3 Replies

ActionScript 2.0 :: Passing Variable To Function By Ref?

Feb 23, 2011

If I remember correctly, objects are being passed to functions by reference, so I wrapped my primitive variable into object but did not get the resilt I wanted. I combed this group to see the solution and found only this one:

function changeObjectStatus(obj)
{
return obj.status = true;
}

[Code]....

var v seems to be a new object rather then a reference to the old one. and changing v does not affect the original object.

Does this mean that if I want the function to work with several variables, I need to create a separate object for each variable?

View 2 Replies

ActionScript 3.0 :: Passing Array Of MC's To Function?

Oct 19, 2011

when doing something like passing an array of movieclips to a function then trying to access the name of the movieclip (a[i].name) why does it give instance names instead of the names passed in.

Here is example code from a function I'm trying to use to enable whatever navigation movieclips i pass into it:

ActionScript Code:
function enableNavButton(a:Array):void
{
for(var i = 0; i < a.length; i++)
{

[Code]...

View 3 Replies

Actionscript 3.0 :: Passing Arguments To Php Function

Apr 8, 2009

i 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].....

View 1 Replies

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

ActionScript 2.0 :: Passing Parameters To A Function

Feb 3, 2006

way to say the same in just a few line of code? 25 lines of code people

[AS]menuAS = function () {
//TIOCCHA
menuBar.menu01.menu01_btn.onRelease = function() {

[Code]....

View 6 Replies

ActionScript 2.0 :: Passing Movieclip Name To Function?

May 12, 2007

Here is the code that I have right now (it obviousvly doesn't do what I want it to):

Code:#include "lmc_tween.as"
orig_x = mc_01.black_bkg._x;
orig_y = mc_01.black_bkg._y;
function buttonIn() {

What I want to be able to do is pass the name of the movie clip (ie mc_01, mc_02...) to the function, and have the function effect that particular movie clip. I had this code that didn't work

[Code]...

View 6 Replies

ActionScript 2.0 :: Passing A Function Name As A Variable?

Aug 31, 2007

Been looking everywhere to find out if there is a way to do this:

[Code]...

Anyone know Of a way to accomplish this without having to use an if/then statement

View 4 Replies

ActionScript 2.0 :: Passing Movieclip To Function

Oct 16, 2007

[code]how to get my target variable in my function to work? I am trying to make it the movieclip in which to make the text field.

View 2 Replies

ActionScript 2.0 :: Passing String Var Into Function?

Jan 18, 2008

im making a function that limmits text to a specified number... only problem is i cant seem to pass in the text var that contains the text

Code:
var textF1:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam neque purus, aliquam sed, sagittis tincidunt, adipiscing ac, urna. Ut libero urna, nonummy sodalesxxx";

[Code]....

View 1 Replies







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