ActionScript 3.0 :: Artificially Set An Event Call?
Dec 2, 2009
i'm creating a menu that of course calls some functions then items are clicked. the problem i'm having is i want to fake one of these menu click events from a function when the menu loads and i can't figure out how to do it.
here's a sample of the function(not complete).
function itemClicked(e:Event):void {
trace("activeMenu:"+e.target.name); //traces out menuItem0, menuItem1, etc.
trace("moveItems:"+e.currentTarget.name); //traces out menuItem0, menuItem1, etc.
[Code].....
so i guess what i'm asking is how do you artificially set an event call if you know the name of the movieclip that you want to simulate a click on?
I'm newish to OOP AS... trying to build a image loader that wipes between loads. having trouble getting my onloadComplete event to call a method in the main body of the class. what am I missing?
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.
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."
I have a simple event im trying to listen for in one class and dispatch in another but it does not seem to be working. Before I start tearing this apart is this even possible. A quick test shows its being dispatched fine (checked with trace) but my listener never gets called.[code]...
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.
I'm just trying to build as simple of a player as possible, and I have it working how I want it to, but I need to figure out how to know when the video ends so I can call any callback functions I might want to be called.I've spent the better part of the last 3 hours trying different examples online, but none do anything. It compiles fine, but just doesn't do anything...
I'm attaching the code I already have, and would appreciate it if anyone could point me in the right direction.
ActionScript Code: var _path:String = root.loaderInfo.parameters.Path; var _w:int = root.loaderInfo.parameters.Width; var _h:int = root.loaderInfo.parameters.Height;
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.
I'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?
I have a movie clip being dynamically added to the stage via an AS3 linkage call:
gameOver_mc = new GameOver(); stage.addChild(gameOver_mc);
The movie loads as required.But when the movie has been added I want the user to be able to press spacebar and a function to run.So in the GameOver.as class I wrote the following:
Code:
package { import flash.ui.Keyboard;
[code]...
But as soon as the movie clip tries to load I get the error message: TypeError: Error #1009: Cannot access a property or method of a null object reference.I would have thought this would work fine. When I trace the statement in the Constructor function is works. Its only when I try to add an event listener that I get the problems. So am I not allowed to add event listeners from a dynamically loaded class?
isit possible to call two functions from one button event listener?
or is it even possible to write two seperate listeners for one button that listen for the same thing an example is shown in the code;
also, i have string variable, that i want to use to call a certain funtion depending on the variable, for example the vairables name is phase_no can i do next_btn.addEventListener(MouseEvent.CLICK,nextPhase,beginSubmit+phas e_no)??
I just posted a message asking how to call a method from the constructor which has the parameters e: Event. I mistakenly ticked that post as answered when in reality it isnt. I was told I could add = null in the parameter of the function to make it work, like this:
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 function after every 20 seconds even if enter key is not pressed by the User. Can I create the same effect as pressing the Enter key through code in some way so that the code within the if condition inside the function gets executed?
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].....
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){