ActionScript 3.0 :: Call The Same Function Within A Function AND When Listening For An Event?
Feb 3, 2009How could i call the same function within a function AND when listening for an event?
would something likt this:
[Code]...
How could i call the same function within a function AND when listening for an event?
would something likt this:
[Code]...
is it possible to write a function to move an object and then call that function on a clip event for instance
function (bounce){
script;
script;
}
and then call it by saying
on(mouseOver){
this.bounce;
}
I have been having a problem usign a custom event... I attached it to the the main class using "addEventListener" and fire it off with "dispatchEvent" in another class. I checked that it was attached to the main class using "hasEventListener" and it returned true, also "dispatchEvent" returns true... but it ever reaches the function that I attaced it to... is there any thing I am missing?
View 3 RepliesHow do I call a function with a event inside it?[code]...
View 2 RepliesI need to use an onEnterFrame event to call a function just once. Here's the code:
my_object.onEnterFrame = function() {
if (this._y == 100) {
my_function();
}
};
So say i drag "my_object" to a y-coordinate of 100, how do i make it so it only calls the function once. Then if i drag the object away from y=100, and then back to y=100, i want it to call the function again.
I'm using the onEnterFrame event b/c i need it to constantly look for the object to be at y=100, maybe except when its actually at 100.
ActionScript Code:
import gs.TweenMax;
import fl.motion.easing.*;
var where:String
buttongroup.addEventListener(MouseEvent.MOUSE_OVER, buttonOver);
buttongroup.addEventListener(MouseEvent.MOUSE_OUT, buttonOut);
[Code] ......
I have some movie clips that I want to load by using a text box. The way I want to do it is to have a text box and based on the word typed into it call the respective movieclip. My problem is that I do not know how to call the function based on the event of someone hitting the "enter" key.
View 3 RepliesI'm playing with the event system and my own custom event class for a project I'm working on. I'm wondering if it's better to use obj.dispatchEvent(new CustomEvent(event)) or if I should just use a regular function call.
It seems to me that in most cases when one object is detecting the event and another is responding to it it is better to use the event system so I'm not passing around objects too much.
I was also wondering what the performance hit of using the event vs. the function call is. I'm sure the event is more cpu intensive but is it negligible?
im having this errors:
1021: Duplicate function definition function onComplete1(event:Event):void {
1021: Duplicate function definition function stopSound1(event:MouseEvent):void {
1021: Duplicate function definition function backSound1(event:MouseEvent):void {
codes i used:
Code:
var thereReq:URLRequest = new URLRequest("SOUNDS/how.mp3");
var there:Sound = new Sound();
var thereControl:SoundChannel = new SoundChannel();
[code]....
Curious if it is possible to add additional parameters (arguments) when you call a function with an event?
ActionScript Code:
// this is a normal event listener
my_mc.addEventListener(Event.COMPLETE, doNextFunction, false, 0, true);
// This is a function called by the event listener private function doNextFunction(event:Event, targ:Sprite, filePath:String):void {
[Code]...
How do I call the slideShow function without an event listener?[code]...
View 1 RepliesHow to create a mouse over event that call a function after 3 second?
I'm trying to create a function where when a mouse go over a sprite, it will count 3 second and call upon another new sprite, when mouse out before 3 second, the new sprite will not be called, how can i do this?
So I have an event listener, and I call a function from it.. but I want to pass some variables along with it as well.Is that possible?
View 10 Repliesi have simple question about how to call a function on a class but i dont know how to do it,I have a class :
Code:
class MyClass{
private var lvSendState:LoadVars;
[code].....
Say I have the following function
Code:
function myVideoFunction(event:VideoEvent):void {
do some stuff....
}
but i want to call it from the event listener
Code: button.addEventListener(MouseEvent.CLICK,myVideoFunction);
I cant because it runs off a VideoEvent, not a MouseEvent.The obvious work around is to copy and paste the function and rename this part, or alternativly just make a function such as:
Code:
button.addEventListener(MouseEvent.CLICK,callMyVideoFunction);
function callMyVideoFunction (event:MouseEvent) {
myVideoFunction(null);[code].....
Code:
stage.addEventListener(Event.DEACTIVATE,callMenu);
...
function callMenu(e:Event)
{
//game is paused and a menu is brought up.
}
if i also want to call the menu within another function which is not the same type of event, should i pass in null?
example: a switch statement finds the correct keyboard input has been pressed, is it bad to use callMenu(null);...it seemed to work, but feels wrong.
how to create a mouse over event that call a function after 3 second?
I'm trying to create a function where when a mouse go over a sprite, it will count 3 second and call upon another new sprite, when mouse out before 3 second, the new sprite will not be called, how can i do this?
I want to call the same event handler function with a click and also with a custom event. the problem is the event type that needs to be passed to the function. Is there are generic event type that can be used to call the function from both places?
Code:
menuBtn.addEventListener(MouseEvent.CLICK, menuOpen );
function menuOpen(event:MouseEvent){
[Code].....
The keyBoard event listeners call on the rotate and unrotate functions and based on the key inputs(A and D) will implement either of the functions and rotate the image or return it to the original upright position. However, I haven't been able to get the function to work. When I press the A or D keys on the keyboard nothing happens. I even put trace() in one of the functions to see if the function will even be implemented but I don't get anything. I put in my Scripts below. Why are the functions not working? Do the eventlisteners fire or are there conflicts? I'm not getting any error messages.
ti.border = true
ti.addEventListener(TextEvent.TEXT_INPUT, onInput);
function onInput(event:TextEvent):void {
if(ti.text.search('a')!=-1) load_image("http://i54.tinypic.com/anom5d.png", "ottefct");
[code]....
The keyBoard event listeners call on the rotate and unrotate functions and based on the key inputs(A and D) will implement either of the functions and rotate the image or return it to the original upright position. However, I haven't been able to get the function to work. When I press the A or D keys on the keyboard nothing happens. I even put trace() in one of the functions to see if the function will even be implemented but I don't get anything. I put in my Scripts below. Why are the functions not working? Do the eventlisteners fire or are there conflicts?[code]...
View 1 RepliesHere is the code to call function using event listener:
var listListener:Object = new Object();
istListener.change = function() { changeImage(); }
thelist.addEventListener("change", listListener);
[code]......
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].....
I am loading 5 images using "for loop" and I have created the listener and if the images completes the loading, the function is called. Now, I need is the name of the "image" which is loaded on each five images gets completed.
[Code]...
in the output it is throwing as "[object LoaderInfo]". Now i need is the name of the "Image", inside the thumbnail_load function, that means, which image loading is completed.
i am not an action script developer nor flash designer, i just want to have a small action script sample that i will edit a little to make it interact with my javascript code. By the way, i want to have a button and a label on a flash form, when the user clicks on this button the onclick event will call another function 'setText for example' this setText() function will change the label text. So i think the code will be something like this:
[Code]....
I managed to put the button and the label i want just the code i will write to make this work.
I am working with Flex 4 windowed application. I have a mx:HTML container with location attribute like [URL]. That abc.html has a html button and i want when that html button is clicked then a flex windowed application function should be called.
Dummy Flex 4 windowed application screen shot: [URL]
is it possible to store a list of params needed for a function in an array and then use that in a funciton call?
[Code]...
or something like that?? Prob have to iterate the array but how do i get the params into the function call? Is this even possible?
How create baseurl function in flash and how i call that function in button script
View 1 RepliesI 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?
I have an AS3 program that calls a function multiple times. The function must return multiple variables, so I created a class for the function to declare an object containing all of these variables. For example, here's my class:
package
{
public class PER
{
[Code].....
Let's say the calling program calls the function, which returns the variables into data_set1 (where data_set1 depends on input variables arg1, arg2, arg3) using:
var data_set1:PER = function_name(arg1, arg2, arg3);
The calling program does some stuff, then calls the function again, but returns the variables into a new variable name, data_set2:
var data_set2:PER = function_name(arg4, arg5, arg6);
My intention is that data_set1 and data_set2 are different (e.g. not linked together).
My question is, given that arrays are passed by reference, will data_set1 be modified to agree with data_set2 upon the 2nd function call? Why or why not?
I'm using this code to call a actionscript 3 function through javascript
[URL}
and I want to call the acrionscript 3 function from a javascript function, but not on a button action.
actionscript code:
//call to javascript
ExternalInterface.call("sendToJavaScript");
//call from javascript
[Code]....