Dispatching event from Javascript
Can I dispatch events from javascript to flash player? I am trying to do so by calling dispatchEvent() on flash player dom object but the event is not passing inside flash player. Any links or clue?
To be specific ... I can catch a right click and supress it. But I want to send it to flash (lets say) as a left click. Problem is when i do that, javascript listner for dom element will get fired for left click but there wont be any events in flash.
SO the question is can i fire events on flash from outseide or is it outside the public APIs?
Similar Messages
-
Pass Mouse click events from JavaScript to Falsh Movie
Hi,
I have an interesting problem here.
i am trying to create a web page which has my
flash-presentation movie. i need to disable mouse click &
keyboard click navigation of the flash movie. The only way by which
i can navigate my slide in the flash movie should be using 2
buttons say Next & Prev that are i my web page.
when i click the Next button i should be able to go to the
next slid or the animation in the same slide like how i do in the
power Point.
Is there any way by which i can send these mouse click
events from my javascript to my flash movie or is there any other
means by which i can achieve this.
~BlackperilHi Mathias,
What i understood is that you want to triger a server side event (simulate onClick event of button)from a client side event (javascript confirm popup), based on the choice of user..
You can also try this one...
Check = confirm("Do you really want to proceed?");
if (Check == true)
document.getElementById('do_proceed').click();
else
document.getElementById('do_cancel').click();
Regards,
Anubhav -
Dispatch event from the main App file
Hi,I have one simple question.I know how to dipatch events from the some of the components files to the main App file,but I don't know how to do the opposite?
I have an HTTPService with id = "getData" in some component file and I want to dispatch an event that will send it getData.send();
Is this possible,and it if is how?It is possible but not a recommended practice.
Worst case you proxy out methods on your components and call directly:
maiAPpp.someComponent.doSomething();
SomeComponent
doSomething();
someOtherComponent.doSomething();
SomeOtherComponent
doSomething();
servcie.send();
My 2 cents are too look into MVC architecture and have the service inside a command which gets treiggered by a controlled which reacts to your event dispatched by the view.
C -
Can I dispatch an event from the skin and have the hostcomponent listen it? I have a text input and an info icon in frnt of it, I want to show the tooltip of the textinput when there is a rollover event on the icon. I wrote a skin with the textinput and icon and in the rollover event on the icon I am dispatching an event and added an event listener to the hostcomponent of the skin. It seems like hostcomponent is not listening the event.
My skin handles all the animation logic and contains the image and the textinput,and then I am extending the skinnable component class with the two skin parts and controlling the skin states from there. In the rollover event I dispatched an event which host omponent is supposed to catch and do the following:
myTextInput. tooltip = _toolTip
_toolTip is in the construcotr of the hostcomponent.
What is wrong in what I did? Why is my host component not receiving a event from the skin?Thanks for your reply. My code is kinda long and apparently I can't copy paste in this window(not sure why).
Is there any way to attach the code somehow? -
I've got an application that is trying to watch for mouse events anywhere and everywhere. The goal is to be in-the-know when there is mouse activity going on in general, with the Java app running in the taskbar.
I have determined that I'll likely need JNI to accomplish this, as paying attention to mouse activity over the whole operating system is somewhat operating system dependent. : )
Nevertheless, I'd like Java code to handle the events, and I can't seem to find any way for JNI to dispatch events back to the Java side of things. My hope was to catch the events thrown by the system in C/C++ and then simply dispatch them again to act as a middle-man.
If anybody can tell me how I might accomplish this using JNI, or even a step in the right direction, I would greatly appreciate it. Or, if I'm barking up the wrong tree, please please let me know.
Thanks,
- JSteps in order
1. Determine how to capture the events in C/C++. There is no java in this step.
2. Write an API in C/C++ that models the functionality that you want to use in java. There is no java in this step.
3. Write java/jni that uses the API in 2. There is java in this step.
As a callback you will need to use the jni attach thread method.
You better be careful as messing up on any of the steps above can render your mouse inoperable for the entire OS, so learn the keyboard shortcuts.
I think that someone posted code like this in the past. I could be mistaken however. -
Dispatch event from itemrenderer
Greetings.
i've got a main applicationxml: main.mxml
followed by a component: optionbox.mxml, being loaded in the
main.mxml.
in optionbox.mxml another component is loaded:
optionCanvas.mxml
inhere, a datagrid is being created with a custom
itemrenderer: itemsRenderer.mxml
in this itemsRenderer (wich alters the display of the cells)
is an image located.
when you click this image, an object has to be dispatched to
the main.mxml.
how can I do this? It works when I dispatch from a component,
but not from an itemrenderer.
can anyone help me out.??
main.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="vertical"
xmlns:c="comp.*"
backgroundAlpha="0"
backgroundColor="#FFFFFF">
<mx:«»Style>
global{
fontFamily:Arial;
Canvas{
color:#000000;
.FooterLink{
color:#0066CB;
fontWeight:Bold;
fontThickness:900;
.Footer{
backgroundColor:#E1F0F7;
DataGrid{
borderThickness:0;
selectionColor:#FFFFFF;
selectionDisabledColor:#FFFFFF;
disabledColor:#FFFFFF;
rollOverColor:#FFFFFF;
ToolTip {
fontFamily: Arial;
fontSize: 12;
color: #000000;
</mx:«»Style>
<mx:«»Script>
<![CDATA[
import events.itemEvent;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var selectedItems:ArrayCollection = new
ArrayCollection();
private function photoSelectedHandler(event:itemEvent):void{
selectedItems.addItem(event.selectedItem);
]]>
</mx:«»Script>
<mx:VBox width="980" height="100%">
<mx:HBox>
<mx:VBox>
<c:LeftPane id="leftpane" width="201" height="100%" />
<c:Checkout id="checkout" selectedItems="{selectedItems}"
styleName="checkout" fontWeight="bold"/>
</mx:VBox>
<c:«»Swfcontainer width="537"
height="405" />
<c:OptionBox width="222" height="100%" id="optionBox"
itemSelected="{photoSelectedHandler(event)}"/>
</mx:HBox>
<c:Footer width="100%"
styleName="Footer"></c:Footer>
</mx:VBox>
</mx:Application>
[/code:1]
optionbox.mxml
[code:1]<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
color="#400000" creationComplete="printerData.send()"
xmlns:c="comp.*">
<mx:Metadata>
[Event(name="itemSelected",
type="events.itemEvent"«»)]
</mx:Metadata>
<mx:«»Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable]
public var printer:ArrayCollection
private function printerDataHandler(event:ResultEvent):void{
printer = new ArrayCollection();
printer=event.result.printer.confItem;
]]>
</mx:«»Script>
<mx:HTTPService id="printerData" url="data/data.xml"
result="printerDataHandler(event)"/>
<mx:Accordion id="accOptions" width="100%" height="100%"
headerHeight="32" backgroundAlpha="0" fontSize="11" color="#0066CB"
resizeToContent="true">
<mx:Canvas label="{printer.getItemAt(0).label}"
width="100%" height="100%" backgroundAlpha="0">
<mx:VBox>
<mx:Text width="198"
htmlText="{printer.getItemAt(0).text}" />
</mx:VBox>
</mx:Canvas>
<mx:Repeater id="repAccOptions" dataProvider="{printer}"
startingIndex="1" >
<c:optionCanvas
itemData="{repAccOptions.currentItem}"/>
</mx:Repeater>
</mx:Accordion>
</mx:HBox>[/code:1]
optionCanvas.mxml
[code:1]<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
label="{itemData.label}" width="100%" height="100%"
verticalScrollPolicy="off">
<mx:«»Script>
<![CDATA[
[Bindable]
public var itemData:Object;
]]>
</mx:«»Script>
<mx:VBox width="100%">
<mx:Text width="100%" htmlText="{itemData.text}" />
<mx:«»DataGrid
dataProvider="{itemData.consumables.consumable}"
headerHeight="0"
width="100%" itemRenderer="itemRenderers.OptionsRender"
alternatingItemColors="#FFFFFF">
<mx:columns>
<mx:«»DataGridColumn
dataField="consumableLabel" width="200"/>
</mx:columns>
</mx:«»DataGrid>
</mx:VBox>
</mx:Canvas>[/code:1]
optionsRenderer.mxml
[code:1]<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
verticalScrollPolicy="off" horizontalScrollPolicy="off" width="165"
height="45">
<mx:Metadata>
[Event(name="itemSelected",
type="events.itemEvent"«»)]
</mx:Metadata>
<mx:«»Script>
<![CDATA[
import events.itemEvent;
[Bindable]
public var selectedItem:Object;
private function addItem(itemObj:Object):void{
selectedItem = new Object();
selectedItem = itemObj;
var eventObj:itemEvent = new
itemEvent(selectedItem,"itemSelected"«»);
dispatchEvent(eventObj);
]]>
</mx:«»Script>
<mx:Image source="assets/btnAddItem.jpg"
click="addItem(data)"/>
<mx:Text htmlText="{data.consumableLabel}"
height="45"/>
<mx:Image source="assets/btnInfoItem.jpg"
horizontalAlign="right">
<mx:toolTip>
{data.consumableLabel}
Partnumber:{data.consumablePartnr}
Price:{data.consumablePrice}
Omschrijving
{data.consumableDescr}</mx:toolTip>
</mx:Image>
</mx:HBox>[/code:1]Override clone() method inside event to make sure you take into account the bubbling property, and then inside renderer dispatch the event with bubbling property set to true.
Alternatively you can dispatch on the list e.g :
owner.dispatchEvent(newCopyProductEvent(CopyProductEvent.COPY_PRODUCT,o));
If you choose to do the latter make sure you don;t get into an infinite loop inside list if you decide to redispatch from there,
C -
Can you dispatch events from a custom component skin?
If so, how?
Thanks~BennyI'm curious to know if this is possible as well (or really the question should be, is there a non-hackish way to get a reference to the skin instance)?
When I've needed to do something like this, I've always just dispatched an event off a skin part from within my skin. IE.
this.contentGroup.dispatchEvent(...)
Then I would just listen for the event on the skin part.
This is a bit hackish, so it would be nice if someone could share a better solution. I've been meaning to look into it, just never have been able to justify the time looking for a better solution. -
How to dispatch events from custom AS3 classes to MXML
Hello,
I introduce some custom classes inside my SCRIPT tag in MXML.
These classes should dispatch custom Events (or any events for that
matter) and the listeners should be defined inside the SCRIPT tag.
In the custom class I have:
quote:
dispatchEvent(new Event("customEvent"));
And inside the script tag:
quote:
addEventListener("customEvent", testListener);
quote:
public function testListener(evt:Event):void{
Alert("Event fired successfully.");
However, this event is not handled in the listener (the alert
is not shown). What could be wrong?<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function init():void
addEventListener("customEvent", testListener);
dispatchEvent(new Event("customEvent"));
private function testListener(evt:Event):void{
Alert.show("Event fired successfully.");
Do like this
Alert is the Class Object. This is not the Function. -
Help dispatching events from glassPane to other components
Hi guys,
I laready did a search in the forum but everybody seems to have trouble blocking events via GlassPane.
For me it is the opposite.
I set a glassPane on the Frame via setGlassPane()... works great but now i can't dispatch the events to the rest of the UI. Can someone please give me some example code how to do that;
Here is what i have tried :
myFrame.this.getGlassPane().addMouseListener(new MouseAdapter()
public void mouseClicked(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
public void mousePressed(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
public void mouseReleased(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
public void mouseEntered(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
public void mouseExited(MouseEvent e)
Frame.this.getRootPane().dispatchEvent(e);
Please show how it is done ...Hey Tom,
You know what's funny, i read that article already and even look at the code but it was too complicated for me...And now that you mentionned it again i decided to look at it again and took one method out of it and now it seems to work but i still don't quiet understand what it does exactly??? Thanks For pushing My Back :)
Any Other way to do that ???
private void redispatchMouseEvent(MouseEvent e)
Point glassPanePoint = e.getPoint();
Container container = this.getContentPane();
Point containerPoint = SwingUtilities.convertPoint(this.getGlassPane(), glassPanePoint,container);
//The mouse event is probably over the content pane.
//Find out exactly which component it's over.
Component component =
SwingUtilities.getDeepestComponentAt(
container,
containerPoint.x,
containerPoint.y);
if ((component != null) )
//Forward events over the check box.
Point componentPoint = SwingUtilities.convertPoint(
this.getGlassPane(),
glassPanePoint,
component);
component.dispatchEvent(new MouseEvent(component,
e.getID(),
e.getWhen(),
e.getModifiers(),
componentPoint.x,
componentPoint.y,
e.getClickCount(),
e.isPopupTrigger())); -
Dispatchig event from one module and listen it in an other module
Hi,
I would like to know if it's possible to dispatch event from module for example "M1" and listen this event to call the corresponding command but in an other module "M2". Knowing that M1 produces an swf "SWF1" and M2 produces an other swf "SWF2". For example :
In the view of a module M1, I should have this statement : CairngormEventDispatcher.getInstance().dispatchEvent(new MyClassEvent(parm));
know in module "M2" I would like to know how to recover this event and then executing command corresponding to this event.
If it's not clear enough I can explain it again.
I need really your help for the rest of my development.
Thank you in advance. :)
Ziad.Hi Ziad,
Sorry, but this forum is for discussing the future of cairngorm, not how to use it today.
I suggest you post your question on the FlexCoders mailing list or on the Cairngorm Documentation Group :
http://tech.groups.yahoo.com/group/cairngorm-documentation/
Thanks ;) -
Calling events from scripts in UIX
Hi,
I am able to call the ordinary events in the UIX from the script. But I am not able to call the
<ctrl:event .. >
from the script.
Could anyone please tell me how to call them.
Thank you
VelpandianVelpandian -
Assuming your page contains a form, you can trigger an event on the server from a JavaScript handler by calling submitForm(). The following sample shows how to send an event both by using the ctrl:event attribute as well as from a JavaScript handler:
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://xmlns.oracle.com/uix/controller"
xmlns:ui="http://xmlns.oracle.com/uix/ui"
xmlns:data="http://xmlns.oracle.com/uix/ui"
xmlns:ctrl="http://xmlns.oracle.com/uix/controller">
<content>
<form name="foo" xmlns="http://xmlns.oracle.com/uix/ui">
<contents>
<!-- Import the submitForm() function -->
<importScript names="submitForm()"/>
<stackLayout>
<contents>
<!-- This link sends an event using a ctrl:event attribute -->
<link text="Send Event" ctrl:event="test"/>
<!-- This link sends an event using a JavaScript event handler.
We use submitForm() and specify the event name using
a parameter. Note that this means that we need to be
sure that we also have an "event" hidden field - which
we add via a formParameter element below -->
<link text="Send Event from JavaScript"
onClick="if (confirm('Send event')) submitForm(0, 0, {'event':'test'}); else return false;"
destination="#"/>
<!-- Need a form value to contain the event name -->
<formParameter name="event"/>
</contents>
</stackLayout>
</contents>
</form>
</content>
<handlers>
<!-- Use a null event handler to set up a session variable -->
<event name="test">
<go name="nextPage"/>
</event>
</handlers>
</page>I couldn't find the documentation for submitForm() online anywhere... Here is a copy of the documentation from our source code:
* Attempts to submits the form, potentially firing validation and notifying
* any Cabo onSubmit handlers registered on the form, returning
* <code>true</code> if the submission actually occurred.
* <p>
* If the <code>doValidate</code> parameter is false, no validation will
* be performed, and the form is guaranteed to be submitted. Otherwise,
* the form will be submitted if both the validation succeeds and any
* registered Cabo onSubmit handlers do not return <code>false</code>.
* <p>
* @param form The form to submit. This can either be the name of the form
* in the current <code>document</code>, the index of the form
* in the current <code>document</code> or the form itself.
* @param doValidate boolean value specifying whether validation should
* occur before the form is submitted. (As per a common Javascript
* idiom, it is acceptable to pass true/false as well as 0/1). If
* this parameter is ommitted, it defaults to true.
* @param parameters a single Javascript object that specifies
* all the additional key-value pairs to submit. There must be
* pre-existing <input type="hidden"> elements as targets
* for each of these parameters.
function submitForm(
form,
doValidate,
parameters
)Andy -
How to call a bean method from javascript event
Hi,
I could not find material on how to call a bean method from javascript, any help would be appreciated.
RalphHi,
Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
Cheers,
Ralph -
Dispatch custom event from itemClick handler
hi,
I'm trying to dispatch a custom event from my itemClick handler.
So when I click on an item of my datagrid, I want to send a custom event.
private function dataGridItemClickHandler( event:ListEvent): void
dispatchEvent( new myEvent( myEvent.NEW, values[event.columnIndex]["name"]) );
<mx:DataGrid dataProvider="{values}" itemClick="dataGridItemClickHandler(event)">
</mx:DataGrid>
but this code doesn't work.
Can you help me
thanks
best regardsPlease see that you override the function clone() and return the new function.If that is correct.you can call the super() method to initialize your base class.
If your custom event {myEvent} is in package say: CustomEvent,
1)import package CustomEvent.myEvent
2) keep in <mx:metadata>[Event(name="NEW", type="CustomEvent.myEvent")]</mx:metadata>.. name suggest what type of event you want
3)Create an itemclick listener and in dataGridItemClickHandler
private function dataGridItemClickHandler( event:ListEvent): void
dispatchEvent( new myEvent( ' NEW ', values[event.columnIndex]["name"]) );
private funcation myEventListener(evt:myEvent):void
//Put your logic
4)Use this event by name NEW="myEventListener(event)" this will behave as event type in the datagrid tag like click, hover and others.
Hope this helps! Please excuse if anything is logically incorrect.Do point out.Thanks. -
Revision: 14474
Revision: 14474
Author: [email protected]
Date: 2010-02-28 23:53:31 -0800 (Sun, 28 Feb 2010)
Log Message:
Adding a 'dispatchInitialChangeEvent' parameter to the 'watch' method in order to allow the initial change event from being dispatched, continued.
Modified Paths:
osmf/trunk/framework/OSMF/org/osmf/metadata/MetadataWatcher.as*Feedback*
"Use the form below to send us your comments. We read all feedback carefully, but please note that we cannot respond to the comments you submit."
http://www.apple.com/feedback/ipad.html
We can complain about Apple's business decisions, but these discussions are user to user talk about possible solutions.
Here are the places to report bugs:
Get an account at
http://developer.apple.com/ then submit a bug report to http://bugreporter.apple.com/
Once on the bugreporter page,
-- click on New icon
-- See if you need to attach a log file or log files, clicking on Show instructions for gathering logs. Scroll down to find the area or application that matches the problem.
-- etc. -
Revision: 14473
Revision: 14473
Author: [email protected]
Date: 2010-02-28 23:45:28 -0800 (Sun, 28 Feb 2010)
Log Message:
Adding a 'dispatchInitialChangeEvent' parameter to the 'watch' method in order to allow the initial change event from being dispatched.
Modified Paths:
osmf/trunk/framework/OSMF/org/osmf/metadata/MetadataWatcher.asPerhaps you're not handling the "EndOfStreamEvent" correctly/at all, and thus not freeing up the socket to listen for the "NewReceiveStreamEvent " after the initial stream has ended...
?
Maybe you are looking for
-
How can I delete large amounts of mail at once
On my iPad, how can I delete all of my mail at once?
-
How to use a custom.dll in forms 6i
Hi, i have made a small dll using a icon-making software, that software has made a .dll of the icon I made in that software Now i want to use that .dll in my forms 6i. (client/server) the dll contains only one icon named 'Icon1' would any one please
-
hi, i have just downloaded mountain lion onto my mac but i cannot get safari 6 on it any help please regards jonmau
-
How to use image load gif of 「GIF87a」 by ByteArray ?
Hi all: I want use image load gif file of 「GIF87a」 by ByteArray, but it not be displayed correctly on the screen, How can I do it , or How to conver 「GIF87a」 to 「GIF89a」 ? private function onButtonClick():void { fileRef.browse([new FileFilter("Im
-
Button with sound in scrollable frame
I ran into a problem. If i add sound to a button inside of a scrollable frame the 'on click' action of the button doesnt work. Outside of a scrollable frame it all works fine. Can somebody help me ?