ROLL_OVER event on all flash content - actionscript-3

I'm trying to send a hover event from flash to js (in some browsers, the mousemove / mouseover events won't trigger over flash content). I've tried to do this:
stage.addEventListener(MouseEvent.ROLL_OVER, function():void {
ExternalInterface.call("alert", "Rolled over!!");
});
But it didn't work. I'm an AS newbie, can you point me to the right direction?

also, you have to define a function to the externalinterface to be called.. its a bit overhead:
ExternalInterface.addCallback("sendToActionScript", receivedFromJavaScript);
more info here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html
use last example.

Related

How does Haxe/OpenFL handle canvas click events?

I am adding a canvas on top of a Haxe HTML5 Game. But once I do, the buttons in the Haxe game no longer register the click events. Does anyone know in the Haxe/openFL compiled code where the click events are being handled?
My best guess is that they are looking at the top most canvas, which is now mine and therefore not seeing the hits.
EDIT:
Found this code where the mouse events were being added to the canvas:
while(_g2 < mouseEvents.length) {
var type2 = mouseEvents[_g2];
++_g2;
element1.addEventListener(type2,$bind(this,this.element_onMouse), true);
}
Where element1 = the canvas.
I can't seem to send $(canvas).click() events to that canvas. Anyone have further suggestions?
My conclusion is, I was using JQuery to send calls to event listeners that were added through plain JavaScript.
document.getElemntById("canvas").addEventListener("mousedown", func...);
Apparently the JQuery calls can not call non JQuery events.
$(canvas).mousedown(); // does not work
Using
document.getElemntById("canvas").dispatchEvent(event) r
and sending MouseEvents to the Haxe canvas worked fine.

Action script 3.0 onSwipe{ gotoAndPlay(x); {

Action script 3.0
swipe left/down/right/up gotoAndStop/play (x)?? Someone got a skeleton code of this? I know how to make it in Air for ios/android, but not on regular 3.0. Thanks.
Since you're asking in general - you're not showing specific code:
Use MouseEvents in place of TouchEvents - mousedown in place of a touchBegin for example. mouseX for the position, mouseMove event for swipe code, etc.
Unless you're handling gestures, it should be pretty easy to swap.

Kinetics JS "Click" or simple "Touch" event for Mobile device

I am using kinetic-v4.3.0-beta2.js
I want to handle mobile touch event on group for ios & android.
I am binding event such as following
group.on('touchstart', function (evt) {
$('#onpopMenu').popup("open", { x: leftPosition, y: topPosition });
});
I tried 'touchend', 'touchstart' and 'tap'
Got partial success in "Tap" but in that case, shape is draggable so tap event is not properly fire because object will move from it's place.
but if shape is not draggable then it will work fine.
I tried 'touchend' and 'touchstart' event also but popup menu is close after event fire in iOs and android as I am opening Jquery Mobile Popup by Touching group!
The popup menu will only open for 2-3 seconds when the touchstart event fired.
Anyone faced the same problem with kinetic JS Mobile events? How to handle only "Click" or "Touch" event with it.
I checked this http://www.html5canvastutorials.com/kineticjs/html5-canvas-mobile-events/ for reference but had no luck!
I am developing application with Phonegap + JQM + Kinetics JS
Thanks in advance!
Keep in mind that your application is running inside a webview. This is why you've got these 2/3 seconds of delay on touch/click event.
This is why in all my PhoneGap dev, I use Fastclick.js. FastClick is a simple, easy-to-use library for eliminating the 300ms delay between a physical tap and the firing of a click event on mobile browsers. The aim is to make your application feel less laggy and more responsive while avoiding any interference with your current logic.
You can find it here https://github.com/ftlabs/fastclick.
It's easy to use (if you're using jQuery) :
<script type='application/javascript' src='/path/to/fastclick.js'></script>
<script>
$(function() {
FastClick.attach(document.body);
});
</script>
I made a jsfiddle for you to test out the click/touch events.
From what I understand, you have a Kinetic.Group node that is draggable but you want to open up a popup using jquery mobile.
You are right that when you drag an object, the tap event does not fire. But you said otherwise the tap event works fine if the shape is not draggable. This leads me to believe:
You want a popup on "tap"
You want a popup on "dragend"
If so, all you need is to use both events like this:
group.on('tap dragend', function (evt) {
$('#onpopMenu').popup("open", { x: leftPosition, y: topPosition });
});
Please let me know if my assumptions are wrong, and I can work with you to get the right solution. I am guessing when you want to popup, so if you let me know exactly when you want a popup to occur that will help a lot.
You might want to also look into using evt.cancelBubble = true; http://www.html5canvastutorials.com/kineticjs/html5-canvas-cancel-event-bubble-propagation-with-kineticjs/

How to capture all keyboard input to a custom element?

Here is my problem: I've got a swf loaed inside my loader an in that swf I have a keylistener:
stage.addEventListener(KeyboardEvent.KEY_DOWN, this.__onKeyDown, false, int.MAX_VALUE);
Now I'm adding a TextInput to this stage and I would like this input to catch all keyboard events while I'm focusing it. Is it possible to do so that native __onKeyDown will not fire until my TextInput has lost focus?
Thank you for your answers and sorry for my bad english.
You could give your listener higher priority (which you are), and stopAllPropogation in your handler. I've never tried this with an embedded swf so if it doesn't work right away, you could also try listening to the event in the capture phase (third parameter in addEventListener).
function __onKeyDown(e:KeyboardEvent):void {
e.stopImmediatePropagation();
//rest of you handler code here
}

Custom ActionScript 3 Play/Pause button on raw animation

I tried to search it on google but no one was matched to my search.
Anyway, I'd like to create a custom play / pause button for the animation to control the animation and the audio. I am not so familiar with ActionScript 3 so beg for me.
Here's my screenshot so you can see what i mean.
Thanks and looking forward.
You need to create a layer with one keyframe at the begin, and normal frame till the end of your animation.
In this keyframe, you'll put the button for play/pause control.
On the document class (or sigh on the keyframe itself) you'll put something like that.
myPlayPauseButton.addEventListener(MouseEvent.Click, playPauseHandler);
function playPauseHandler(e:Event):void{
if(e.target.currentFrame == 1) // button is in the play state
this.stop();
else
this.play();
}
please note that the "this" reference in the handler function, is referring to the main scene (the _root for the as2 programmers).
Note also that you can access this.currentFrame in order to know the current frame of the main animation.
myPlayPauseButton.addEventListener(MouseEvent.Click, playPauseHandler);
the Correct
myPlayPauseButton.addEventListener(MouseEvent.CLICK, playPauseHandler);