ActionScript 2.0 :: Send "keydown" Event To A Movieclip?
May 12, 2010I have to embed an external movieclip in my swf, andi'd want to send it keyboard events by code.
the swf to be embedded resides in the same domain as the parent swf.
I have to embed an external movieclip in my swf, andi'd want to send it keyboard events by code.
the swf to be embedded resides in the same domain as the parent swf.
I am trying to detect the key down event for the alt key in flex. I have a standard event listener for KeyboardEvent.KEY_DOWN and KeyboardEvent.KEY_UP but don't get any response for the alt key (or ctrl key).
I know I can detect if the alt key was pressed via a mouse event, but I want to update the cursor when the alt key is pressed to show it will perform a different action from when it's not pressed.
I am using Safari on a Mac for developing so let me know if perhaps it's an isolated issue.
All i have a flex editable datagrid. By default if i press the left navigation arrow key , it moves to the left but not to the next cell. I would like to override the keydown event such that if the left navigation arrow key is pressed down i set the focus to the next cell on the left.
In short the user needs to be able to navigate using the keyboard through the cells using just like in excel(currently the arrow keys move between characters within a cell).
I'm using a component in a cairngorm PopupWrapper. I want to listen to the KeyboardEvent.KEY_DOWn event on the component but it doesn't seem to be dispatching it. Is it because it's in PopupWrapper? Is there anyway I can get it to dispatch the event?[code]
View 1 RepliesI have a function that is called on a keydown event. Inside the function I do this:
function keyDownHandler(event : KeyboardEvent) : void {
if(cursorMoveCnt < 5 && event.keyCode != Keyboard.ENTER) {
trace(i);
trace(cursorMoveCnt);
stage.focus = arrayOfBoxes[i+cursorMoveCnt];
cursorMoveCnt++;
}
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 am new to flex framework.I have created an application using flex framework 4.1 which is having various components that are shown to the end user in the form of a popup window using <mx:TitleWindow>.This titlewindow is closed either on the click of the close button (displayed in it's titlebar) or by pressing the "escape key" on the keyboard.I coded a functionality wherein I close the current TitleWindow whenever an 'escape' button is pressed.Here is what I did.On the keydown event of TitleWindow I called this function.[code]I had to repeat this code for every TitleWindow that I have used in the project.How can I write the above functionality only once and reuse it amongst various TitleWindow and other components so that the code for the same is not repeated across various components? Every TitleWindow that I am using has different code, scripts and layout in it.
View 1 RepliesI have create a game and added keydown event on Stage but but problem is user need to click on stage then it start capturing keydown event. I want that when game window open after that user don't need to click on flash stage area for unable keydown event..
View 1 RepliesWhat 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]....
Is it possible to send a custom event to a child?
[Code].....
when I click the parent, it gets click event. in the click event handler, the parent dispatches a custom event of type E. and the child is listening for E. obj.dispatchEvent() by default targets for obj it is called from. So, the event being dispatched won't reach the child if obj had one. Is there a way to send an event from parent to child? Better yet, is it possible to send an event to an object not in the DisplayList nor is a DisplayObject (the object is instanciated, but it doesn't have graphical role in the program)?
I have a loop that creates movie clips where the movie clips are named mc_+ x for say x = 1 to 10 so the movieclips are called mc_1, mc_2.....mc_10.
What I need to do is the know which one of the movieclips is clicked on but more importantly the number i.e if movieclip mc_2 is clicked on then I need to use the value 2.
At the moment I am sending the value of x to be displayed in a text box within each movieclip:
_root.search.textfield.text = x;
Then I have a piece of actionscript that uses the value of x but I don't seem to be able to "re-read" the value of x back with:
var t = _root.search.textfield.text;
what I want is t = x is it to do with strings and number variables?is it possible to send the variable x to each movieclip so that it can be called from within each movieclip instead?
Relative newbie with AS3 but I need to make an onscreen keyboard for a touchscreen. Through some searching and coding I have a keyboard object that can send events based on clicks but I'm not sure how to go that "last mile" to trigger an actual keyboard event so the selected TextField gets updated.
View 10 RepliesI made this example to experiment. But what i can't seem to get working is to retreive the parameters in the onTimer function.This is the test class:
package {
import event.MyCustomEvent;
import flash.events.TimerEvent;
[code].....
I have a Tile with a repeater. I need to select a repeater item or the tile and change its values, or fire an event, or something.
View 1 RepliesI want to assign a value to a variable ONCE on the correct key strike. THe problem is, I can hit the key three times and get the desired value of 3 that is to trigger another function. I only want each key to be a value of 1 in my switch/case. My brain is mush on this one.
[Code]...
I have code that, when pressing the left or right key, will go to the next frame within my movie:
Code:
stop();
this.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
this.prevFrame();
[code]....
However, this will go to the next frame and stop.How can I get it so it will go to the next frame and play through the time line until I put in a stop command?Or, along the same lines, how could I set it so on keyDown it will go to and play whatever frame I choose?
I am in the final stages of building my new web site: http:[url]....On most of the pages in the portfolio there is a video "Commentary" link (top right corner).Each of the commentaries are flv called up by f.ex:
myMCL.loadClip("http:url.....);
Once the video is done playing, it fades to black.I would really like the flv to trigger an event to send the playhead to another frame and load another swf.I could use a pause command and let the main time line pause so many milliseconds and then proceed, but it is probably not consistent how long it takes each viewer to download the video and watch it.
I'm having an issue with an event dispatcher and an event listener. Here is the application code...
Code:
Select allpackage {
import flash.display.MovieClip;
import flash.events.*;
import flash.net.URLVariables;
import SendAndLoad;
public class Test extends MovieClip {
[Code] .....
It will trace the loader.data variables but doesn't dispatch the event to the main application (Test). I'm listening for the event on the stage of the main but it doesn't trigger the event to display that the login has been successful even though it traces from the sendAndLoad class...
I have a simple movie with the following code. The idea is to move from one frame to the next or back using the arrow keys on the keyboard [code]...
View 6 RepliesMy app has a datagrid as well as many other UIComponents (buttons, menus, etc). I have a general stage KeyDown handler as well as a specific one for the datagrid. The behavior I'm trying to implement is turning out to be trickier than I thought: basically, when using the keyboard arrows I would like the datagrid to always hear about such commands, even if it's not in focus.
Possible approaches I thought of:have the DG be in focus at all times: seems stupid / tricky - basically would need to remember to give focus back to DG after any interaction with the rest of the UI, which obviously doesn't scale.try to set the DG in focus from stage KeyDown handler: seems like the timing doesn't work since the DG gets focus too late to "hear" the event.from the stage keydown handler, check if the DG is not in focus, and if so pass it the event. This seems to make sense in theory, but I'm not sure how to do this properly since my stage keyDown handler uses capture, and thus seems to catch the same event over and over.
I'm trying to make a simple virtual keyboard. So if I click the btnA, the A keydown will be inputted.
View 1 RepliesI have a game with two joysticks and I use the dispatchEvent command to send the fire button event. What would be a good way to send the number of the joystick to check who pressed the fire button. A bit dirty way would be to save just the number in root or in my main class.
View 1 RepliesI came to the point where I need to communicate between 2 objects (let's say Tank and the Cannon). It is tile game, and when the Tank approach specific tile I need my Cannon to shot the Tank. When Tank gets that specific tile I want to dispatch some custom event and have listener in Cannon class body to make the shot happen. Other way I would have to check in ENTER_FRAME loop (inside Cannon body class) if the Tank touched tile that runs the Cannon shooting - but this is not elegant and efficient. The issue is complicated by the fact that the Cannon and Tank are added to the Engine (document class) and can't simply hear for each other, because they seat on the same level in display list.
Initially I could addEventListener to the Engine, but this way my document class would enlarge to the XXL size (all listeners functionality, all methods for game etc). What I would accomplish is to have event listener in every Cannon object (defined in body class) listening for Tank's dispatching the event. I saw some 'Centralized Event Manager' article in the net, but can't download full classes [url]...
I am looking for a way to trigger the downState of my SimpleButton using my KEY_DOWN event. I am hoping there is a way to do this without having to switch this to a MovieClip custom button.
[Code]...
The actionButton is my SimpleButton. I have tried dispatcing the CLICK event and MOUSE_DOWN event but neither has worked.
I am trying to detect the keydown/keyup event of a textbox. I am trying to do it using an EventListener object. Here's my code, which is not working. MyTextbox is the instance name of the textfield on the stage. When I run this code, nothing appears in the output window as it should.
[Code]...
I could put a hidden button on my movie. I found this code over the internet but it seems not to work.
breadcrumbs_btn.onRelease = function() {
if (Key.isDown(99)) {
getURL("http://www.mysite.com/mypage.php", "_self");
}
};
99 is the keycode for letter c by the day
I have a data grid in one frame, then upon moving to the next frame use removeChild to get rid of it, which works fine.But it seems to leave behind the keyDown handler that is naturally part of the component (which is used to navigate the rows of the datagrid).Is there any way to get rid of this?The first time (and only the first time) I press the up or down arrow key in the next frame which does not have the grid, I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.controls::DataGrid/drawList()[code]...........
I work at project to build dance game with AS 3.0 control by Page Dance.
View 1 Repliesi have searched on the web and i haven't found anything that works.
How can i send to back a movieclip by actionscript?
In my swf Application, I can change var's movieclip:background color, text, drag- swf, image into the movieclip ( WYSIWYG method ).in the end, I send via xml to php page all the movieclip var's, and to sql database.
I need also, send by the xml, the position of the movieclip to php file.( The reason is: I want to display just this moveclip with all the change vars in a new browser page ).
I dont know how to write this xml in my Actionscript2 -position of the movieclip.[code]..
I've got some movieclips where everytime when you click on one, that movieclip has to be send to the back.Most logic solution is MovieClip.swapDepth(1), so you swap with the movie wich is at the lowest depth, but for one reason or another, this results in the movieclip jumping to the front.An examplefile is in attachment.this is my script:
mc1.onRelease = function() {
mc1.swapDepths(1);
};[code].....