ActionScript 3.0 :: Can Pass Touch Event To Class Defined 'global' Function

May 12, 2011

I have a class file defined in my package as MyGlobals.as.[code] (I have tried adding/removing "static" and "dynamic" to no effect.)I am trying to call a touch event from the main timeline in this way:myObject.addEventListener(TouchEvent.TOUCH_BEGIN, MyGlobals.myFunctionName);(I have tried removing the class name to no effect.)When I compile I get the error 1046: Type was not found or was not a compile-time constant: TouchEvent. This error occurs on function definitions in the class file.What syntax/concept am I getting wrong? The functions were working fine when I was using constants in the timeline, but I need to be able to reuse these functions over and over again, so I wanted them to be able to take touch event variables so that I didn't have to write a different function for every touch event.I tried googling "error 1046" but I can't find anything useful.

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Sloppy Global Function By Calling Global Function Class

May 14, 2009

I'm try to calling my sloppy global function by calling my global function class as u can see below.[code]

View 2 Replies

ActionScript 3.0 :: Pass Variable Defined In Event Listener Method Outside It?

May 8, 2010

I have 3-4 swf those i want to load one after another like a slideshow.What i  want to do is get the total frames of loaded swf and want to pass that value to Timer object's delay parameter.  i have converted total frames to milliseconds so i can use it in timer constructor. But i am not getting the value of that variable outside of my Event.COMPLETE listener method. Here is my code what i have done

[Code].....

View 2 Replies

ActionScript 3.0 :: Touch Event Function Not Working For Mobile Project

Aug 23, 2011

I am using flash builder4.5 and creating simple touch event function in pure Action script mobile project. When I run with on desktop running it not works but mouse event works. How can I get this to work with touch event function on desktop running

Here's my Code
package {
import flash.display.Sprite;
import flash.events.TouchEvent;
import flash.text.AntiAliasType;
import flash.text.TextField;
[Code] .....

View 3 Replies

ActionScript 3.0 :: Creating Custom Touch Event Handler Class

Jun 5, 2011

I have a problem that seems easy enough to solve but I'm trying to do it with reusable code, which involves doing something I don't understand yet. I've googled this endlessly and read dozens of articles and I'm still just as lost as when I started. I'm hoping a live human being can help me make sense of it.

I have a movie clip on stage. When this movie clip is pressed, I want it to play a certain frame of another movie clip for as long as it's being touched. (It's a map of the US, that will display each state name as it is pressed.) I COULD write 50 different functions, each to call a different frame of the displayName movie, or I could write my own custom event that would be able to receive from each touch event a string variable to then tell displayName which frame to play. So basically, I have, for example:

[Code]...

View 8 Replies

ActionScript 2.0 :: Eating A Global Listener On The Class And Receive Dispatched Event For Any Instance Of The Class?

May 11, 2006

I've done a class to be able to listen to the event for a CLASS not on an instance.

Code:
class net.webbymx.events.XClassEventListener {[code]....

why did I do this.It cames with my rugby game.I have player in two teams. When a player throw the ball I want the other teammate to act like "wait for ball" and the opponent like "seek for ball". Plus I'm lazy (and I don't want to register the listener for each instance of the player I'm creating). So this class is made to be able to handle as many instance of a class I want without adding a listener on each of them. I'm just creating a global listener on the class and then I will be able to receive dispatched event for any instance of this class .so in my team I can do

Code:
XClassListener.initialize(this);
this.addEventListener("throw", "net.webbymx.game.Player", "wait");

and in my opponent team I can do

Code:
XClassListener.initialize(this);
this.addEventListener("throw", "net.webbymx.game.Player", "seek");

View 4 Replies

Flash :: Adding Event Listeners Only To Objects Which Are Defined Tank Class

Mar 3, 2012

I want to make a little game. What I need is to add event listeners to all of Tank objects inside the Battlefield instance. I just can seem to figure out how.

View 1 Replies

ActionScript 2.0 :: Reffering To This From Function Defined Inside Class?

Jan 18, 2006

Code:
class className () {
//constructor
function className(targetmc,linkId) {

[code]....

My question is how can I set up an interval when I click on a button that is created from within the class.

I need my function updater to keep repeating untill I clear the interval.The only way I can figure out is to give the full path like this._parent._parent.instanceName.updater inside the setInterval, but although this works I think is just dumb to hardcode the instace name of the class. I could of course try to pass the instance name as a parameter, but I would really love to find out the smart way to do this (by the book).

View 3 Replies

Actionscript 3 :: Add Event Listeners To Global Stage Via Class?

May 24, 2011

i am making a simple game i want to be able to add an keyboard event lisnter within the class constructor. However i am having trouble. i undertsand you have to pass the stage through a listed display object property stage? anyway i am getting errors that do not recognise my event listener keyboard event.

package louiseguchi.game
{
import flash.display.Stage;

[Code]....

View 2 Replies

ActionScript 3.0 :: Reference To A Global Function With The Name Same As Class?

Feb 4, 2011

How would one get a reference of String global function (not class). According to language reference this function does exist (and I'm ready to believe it does), but, say and you have a:

Code:
function foo(bar:Function):void { ... }

How then would you pass that String to it?

View 9 Replies

ActionScript 3.0 :: 1061 Error (not Defined) When Call A Method Of A Self Defined Class

Feb 9, 2010

I am using flex builder 3.2, Action Script 3 and develop for Flash Player 10 and am quite new to it. when I call a method of a self defined class, I get the 1061 error (not defined). But the class and the method exist and are public, so what the hell am I doing wrong? Flash Builder is even offering me this method in the auto-completion, so at least the builder knows it... I have already tried cleaning the project (as this is the common source of strange errors when working with java/eclipse),

edit: solved... The problem was that a package had the same name as the variable I used for the class. Very strange error message, thumbs down for this .

View 0 Replies

Actionscript 3.0 :: Create A Global Function And Static Metod In Another Class File

Mar 3, 2009

i want to create a global function in actionscript 3.0 i can do this in flash as2 As3 remove that _global. if i want to create a _global function then want to create a static metod in another class file...?

[Code]....

View 1 Replies

ActionScript 3.0 :: Create Custom Event Class If I Dont Need To Pass Custom Property With That Event?

Dec 28, 2009

Is there a point of creating custom event class if i dont need to pass custom property with that event?

View 3 Replies

ActionScript 2.0 :: Get Global Variables That Are Defined Inside XML Array

Aug 22, 2007

I've been trying to get these variables that are defined inside this XML Array, outside of the XML array using _global, so that i can use them else where in the animation, but i'm not getting any purchase.

[Code]....

View 2 Replies

ActionScript 3.0 :: Pass Event.currentTarget To Function

May 12, 2011

I'm making a tile game in flash and I need to pass event.currentTarget (the current tile) into a new function which sends the tile back to it's start position.[code]I need to call this function from other places in my code..I've tried passing the object itself to another function as a variable but it loses it's start position information !

View 2 Replies

Actionscript 3 :: Pass A Function Name Into An Event Listener?

Jun 23, 2011

private function myFunction(numIn:Number){
trace ("numIn " + numIn);
}[code].....

This won't work, but can you see what I'm trying to do? It's kind of like a function pointer, or when you pass a function name into an event listener.

View 2 Replies

ActionScript 2.0 :: User Defined Global Variable Via An Input / Dynamic Box?

Sep 28, 2004

How can I have the user define a global variable via an input/ dynamic box?

View 1 Replies

ActionScript 3.0 :: Pass A Variable To A Function From An Event Listener?

Aug 29, 2008

How do i pass a variable to a function from an event listener which is inside a function Below is a function that is called when after loading some variables

function dataOK(mydataevent:Event):void{
var j:int = 0;
do {
trace(j);

[Code]....

This is a simplified version of the original code. The above function generates an error because j is undefined in the function. I am wanting to get the variable j when the button is pressed.

How do I pass the variable j to the Button_Click function?

View 1 Replies

Actionscript 3 :: Pass A Variable Into An Event.COMPLETE Function?

Feb 6, 2011

I am running a loop to pull thumbs into a containing movieclip from an xml list. What I want to do is have the thumb's parent movieclip fade in after they are done loading, but I can't figure out how to reference the parent once it's loaded.My code(which currently doesn't work the way I want it):

var vsThumb:articleBox;
var currentarticleX:Number = 0;
var articleLinkURL:String;

[code].....

View 2 Replies

ActionScript 3.0 :: Possible To Pass An Argument To The Function Triggered By An Event Handler?

Mar 31, 2009

Ok, I have 2 buttons on the stage. Each button does almost the same thing, so I want to create a single function, and each button calls that same function (we'll name that function "Navigate")... however, the function will need to end up doing something different dependant on which button was clicked.So, previously, in AS2, I would've added some code onto the buttons themselves with on(release) methods, like so:

Code:
// Define the Navigate function
function Navigate(myLabel){

[code].....

View 7 Replies

ActionScript 3.0 :: Pass An Argument To The Function Triggered By An Event Handler?

Mar 31, 2009

Trying to migrate my way of thinking from AS2 to CS4/AS3. Ok, I have 2 buttons on the stage. Each button does almost the same thing, so I want to create a single function, and each button calls that same function (we'll name that function "Navigate")... however, the function will need to end up doing something different dependant on which button was clicked. So, previously, in AS2, I would've added some code onto the buttons themselves with on(release) methods (see CODE EXAMPLE 1) So, each button effectively calls the Navigate function, and passes a different frame label to the function. Now, I'm trying to recreate this functionality in AS3. As you all know, on(release) has been done away with (still don't know why), but we now have to use event handlers, so I'm trying to figure out a way to pass a different frame label argument to the Navigate function. Currently I can achieve that by using a switch statement to test which button was clicked, and act accordingly (see CODE EXAMPLE 2).

[Code]...

View 2 Replies

Actionscript :: Pass Arguments Into Event Listener Function In Flex

Jun 20, 2011

Since when using sql lite if you try and do a function at the same moment it throws an error, im just trying to make a function that will check if its executing, and if it is try again in 10 milliseconds, this exact function works fine if i dont have to pass any arguments to the function but im confused how I can pass the vars back into the function it'll be executing.[code]

View 4 Replies

ActionScript 3.0 :: Pass Additional Arguments To An Event Listener Function?

Aug 19, 2009

I am trying to pass an additional arguments to my listener function, like this[code]...

View 8 Replies

Actionscript 3 :: Creating Event Listeners That Call The Same Function And Pass A Variable

Feb 20, 2012

I COMPLETELY MESSED UP MY CODE AND DID NOT CHANGE THE MOVIECLIP NAMES WHEN COPING IT INTO STACKOVERFLOW. SO IT MADE NO SENSE.

I am wondering if there is a better way to accomplish the following as3:

//THREE EVENT LISTENERS
shoe_icon.addEventListener(MouseEvent.MOUSE_DOWN, shoeApp);
top_icon.addEventListener(MouseEvent.MOUSE_DOWN, topApp);

[Code].....

View 4 Replies

ActionScript 3.0 :: Pass A Class Name As A Function Parameter?

Sep 10, 2009

I ran into a problem today. Since I wanna pass a class name as a function parameter. In that function I wanna make instances of that class,

View 3 Replies

ActionScript 3.0 :: Pass The Scope Of One Class To The Function Of Another

Oct 5, 2011

[Code]...

Specifies the value of thisObject to be used within any function that ActionScript calls. This method also specifies the parameters to be passed to any called function. Because apply() is a method of the Function class, it is also a method of every Function object in ActionScript. i don't get how "thisObject" is accessible from within the function invoked with it's apply method i'm trying to pass the scope of one class to the function of another so that the keyword "this" in the target function refers to the passed scope or am i misunderstanding the apply() method? it appears to behave differently between as2.0 and as3.0 as well, try this example code from the adobe docs

[Code]....

View 3 Replies

ActionScript 3.0 :: Pass Name Of A Class As Argument In Function

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

Call A Function With Event Parameter When Have No Event Parameter To Pass?

Aug 14, 2009

Forgive me for this stupid noob question but I want to call a function (loadList) that originally gets triggered after a mouseevent from another function (addToXML) that does not have an event.

The loadList function takes info from a XML var, sticks it into an array which then gets loaded into a tile list and that is working fine.

The addToXML function when called adds elements to the XML var after which I want to call the first function with the event parameter so it refreshes the items in the tile list.

I know it can do this by creating a new array and loading that into the tile list in the addToXML function, but it be much simpler to just recall the function.

I have tried things like

Code:
addToXML.addEventListener(Event.COMPLETE, loadList);

but all the event constants I have tried give me error messges like "1061: Call to a possibly undefined method addEventListener through a reference with static type Function."

View 3 Replies

ActionScript 3.0 :: Pass Parameters To A Function In Main Class From Loaded SWF?

Aug 15, 2011

I've got a main.as that loads SWF to the stage. the loaded SWF seppoused to pass a link to the main.as and trigger a javascript function to popUp that photo from that link.

I know there are two ways:
 
((root as MovieClip).parent.parent as Object).somefunction(parameters);
 
and to dispatch an event. inorder to pass parameters throug the event i need to extend it with another class.
 
isnt the (root as... )  more efficient if all i need is to pass a link?

View 7 Replies

Flash - Listener In Main Document Class For Custom Dispatch Event From Another Class Does Not Respond Or Call Function?

Apr 1, 2011

I have a document class called Main.as In the class constructor I have the following listener:

enter code here
var listeningFORModeChangeToStudent:Sprite = new Sprite;
listeningFORModeChangeToStudent.addEventListener(TellAllModeChangeToStudent.STUDENT,exp);
addChild(listeningFORModeChangeToStudent);

[code]....

In a third class I make a call to the despatcher in the previous class:

enter code here
var ThisTellAllModeChangeToStudent:TellAllModeChangeToStudent = new TellAllModeChangeToStudent;
ThisTellAllModeChangeToStudent.tellAllModeChangeToStudent();

I have trace statements in eveything and from this I know the despatcher in TellAllModeChangeToStudent is being called.The problem is that the listener in the main.as is not calling the function exp.I cant see why and I dont know how to check if the listener is actually seeing the dispatch event?

View 1 Replies







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