Trying to make up a Modal Dialog with customized event dispatcher

Hello everyone.
I try to make up a ModalDialog class with customized event dispatcher in order to wait an invoker.
But it fails :-(
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventDispatchChain;
import javafx.event.EventHandler;
import javafx.event.EventTarget;
import javafx.event.EventType;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
import javafx.stage.WindowEvent;
import com.sun.javafx.stage.WindowEventDispatcher;
import java.util.ArrayList;
public class ModalDialog extends Stage {
  ArrayList<Button> buttons;
  int rc;
  Stage stage;
  Event event;
  EventDispatchChain tail;
  public ModalDialog( Window owner, String title ){
    initModality( Modality.APPLICATION_MODAL );
    initOwner( owner );
    initStyle( StageStyle.UTILITY );
    setTitle( title );
    stage = this;
  public void setContents( Group group, ArrayList<Button> buttons ){
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root);
    setScene(scene);
    root.setCenter( group );
    this.buttons = buttons;
    HBox buttonPane = new HBox();
    buttonPane.setSpacing(10);
    for( int i=0 ; i<buttons.size() ; i++ ){
      buttons.get(i).setOnAction( actionHandler );
    buttonPane.getChildren().setAll( buttons );
    root.setBottom( buttonPane );
  public int show( double screenX, double screenY ){
    setX( screenX ); setY( screenY );
    show();
    MyWindowEventDispatcher dispatcher =  new MyWindowEventDispatcher( stage );
    setEventDispatcher( dispatcher );
    while(true){
      event = dispatcher.dispatchEvent( event, tail );
      EventType<? extends Event> type = event.getEventType();
      if( type==WindowEvent.WINDOW_HIDDEN ){
        break;
    return( rc );
  EventHandler<ActionEvent> actionHandler = new EventHandler<ActionEvent>() {
    public void handle( ActionEvent e ){
      EventTarget src = e.getTarget();
      rc = buttons.indexOf( src );
      stage.hide();
  class MyWindowEventDispatcher extends WindowEventDispatcher {
    public MyWindowEventDispatcher( Window window ){
      super( window );
    public Event dispatchEvent( Event event, EventDispatchChain tail) {
      ModalDialog.this.event = dispatchCapturingEvent( event );
      ModalDialog.this.tail = tail;
      return( event );
}A sample code to invoke ModalDialog
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class WindowEvent06 extends Application {
  Stage mainStage;
  public void start(Stage stage) throws Exception {
    Group root = new Group();
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("WindowEvent06");
    mainStage = stage;
    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
      public void handle(WindowEvent e){
        ModalDialog dialog = new ModalDialog( mainStage, "Question" );
        Button yes = new Button( "Yes" );
        Button no  = new Button( "No" );
        ArrayList<Button> buttons = new ArrayList<>();
        buttons.add(yes); buttons.add(no);
        Label msg = new Label( "Really Exit ?" );
        Group groupInDialog = new Group();
        groupInDialog.getChildren().add( msg );
        dialog.setContents( groupInDialog, buttons );
        int ans = dialog.show( 300, 300 );
        System.out.println("returned from a modal dialog");
        if( ans == 1 ){
          e.consume(); // this blocks window closing
    stage.show();
  public static void main(String[] args) {
    launch(args);
}

Hi,
The logic what you follows is some what in the right direction but need to have some changes.
What I would say is, first consume the windowClose event. Then open the dialog box and close the parent accordingly.
So after refactoring your code.
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class ModalDialog extends Stage {
     Stage owner;
     Stage stage;
     BorderPane root;
  public ModalDialog( Stage owner, String title){
    root = new BorderPane();
    stage = this;
    this.owner = owner;
    initModality( Modality.APPLICATION_MODAL );
    initOwner( owner );
    initStyle( StageStyle.UTILITY );
    setTitle( title );
    setContents();
  public void setContents(){
    Scene scene = new Scene(root,150,150);
    setScene(scene);
    Group groupInDialog = new Group();
    groupInDialog.getChildren().add( new Label("Really Exit ?") );
    root.setCenter( groupInDialog );
    Button yes = new Button( "Yes" );
    yes.setOnAction(new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent paramT) {
               stage.close(); // Closing the pop up.
               owner.close(); // Closing the parent stage also.
    Button no  = new Button( "No" );
    no.setOnAction(new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent paramT) {
               stage.close(); // Closing the pop up only
    HBox buttonPane = new HBox();
    buttonPane.setSpacing(10);
    buttonPane.getChildren().addAll(yes,no);
    root.setBottom(buttonPane);
    stage.show();
}And the main class to check this implementation is
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class WindowEvent06 extends Application {
  public void start(final Stage stage) throws Exception {
    Group root = new Group();
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("WindowEvent06");
    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
      public void handle(final WindowEvent e){
         e.consume(); // Consuming the event by default.
         new ModalDialog( stage, "Question");
    stage.show();
  public static void main(String[] args) {
    launch(args);
}I hope the above code will give you some idea what i mean. :)
Happy Coding !!
Regards,
Sai Pradeep Dandem.
Edited by: Sai Pradeep Dandem on Jan 20, 2012 4:03 AM

Similar Messages

  • Display a MFC Modal Dialog with CListBox in TestStand

    I want to display a MFC Modal Dialog with a CListBox element, but I can't fill the listbox with data.
    Here are some commands of my program:
    SequenceContext seqContext;
    Engine engine;
    seqContext.AttachDispatch(seqContextDisp, FALSE);
    engine.AttachDispatch(seqContext.GetEngine());
    HWND parentHwnd = (HWND)engine.GetAppMainHwnd();
    CSearch_Line_Window_Dialog dlg(CWnd::FromHandle(parentHwnd));
    dlg.m_SearchLineWindow_Listbox.m_hWnd = parentHwnd;
    (without this command I get the error "Debug Assertion Failed", because of ASSERT(::IsWindow(m_hWnd)))
    dlg.m_SearchLineWindow_Listbox.AddString("Hallo");
    dlg.DoModal();
    seqContext = NULL;
    engine = NULL;
    The dialog with the emtpy listbox appears, b
    ut without any text. I tried the same by using NotifyStartOfModalDialogEx and NotifyEndOfModalDialog. The example "MFC_Modal_Dialog" opens only a dialog without elements.
    I hope you can help me to solve my problem.
    Thank you.

    I've about the same problem and tried to implement your solution but can't get it to run. I always receive an assertion failure.
    I try to fill the ComboBox in a dialog with items at runtime. (use VC++ and MFC-DLL)
    the header of my dialog:
    class DlgSelectECU : public CDialog
    public:
    DlgSelectECU(CWnd* pParent = NULL);
    BOOL OnInitDialog();
    //{{AFX_DATA(DlgSelectECU)
    enum { IDD = IDD_DLGSELECTECU_DIALOG };
    CComboBox m_ECUList;
    CStringList m_StringList;
    //}}AFX_DATA
    //{{AFX_VIRTUAL(DlgSelectECU)
    protected:
    virtual void DoDataExchange(CDataExchange*pDX);
    //}}AFX_VIRTUAL
    protected:
    DECLARE_MESSAGE_MAP()
    the implementation of my dialog:
    DlgSelectECU:lgSelectECU(CWnd* pParent /*=NULL*/)
    : CDialog(DlgSelec
    tECU::IDD, pParent)
    //{{AFX_DATA_INIT(DlgSelectECU)
    //}}AFX_DATA_INIT
    BOOL DlgSelectECU:nInitDialog()
    POSITION pos = m_StringList.GetHeadPosition();
    while (pos)
    m_ECUList.AddString(m_StringList.GetNext(pos));
    return true;
    void DlgSelectECU:oDataExchange(CDataExchange* pDX)
    CDialog:oDataExchange(pDX);
    //{{AFX_DATA_MAP(DlgSelectECU)
    DDX_Control(pDX, IDC_COMBO_ECU, m_ECUList);
    //}}AFX_DATA_MAP
    my dll function TestStand calls looks like that:
    EXPORT CALLBACK SelectECU(char ECUs[1024])
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    DlgSelectECU Dlg;
    Dlg.m_StringList.AddTail("ITEM 1");
    if (Dlg.DoModal() == IDOK)
    // do something
    Running the sequence file in TestStand and calling the dll function descriped above causes an assertion failure each time I try to add anything to the StringList. Why? And what am I doing wrong? Is there
    a documentation about how to write dlls with MFC elements
    for use with TestStand using other tools than LabWindows/CVI? Everything I found so far is rather crude.
    Thanks!

  • I am trying to make a time lapse video with Premier Element 13. When trying to publish it at about 15% of work done it stops and in a new screen it says an unknown error, what am I doing wrong?

    I am trying to make a time lapse video with Premier Element 13. When trying to publish it at about 15% of work done it stops and in a new screen it says an unknown error, what am I doing wrong?

    Click on the blue Internet Recovery in nbar's post. That is a link to what computers can run Internet Recovery.
    Do a backup,  preferable 2 separate ones on 2 drives. Boot to the Recovery Volume (command - R on a restart or hold down the option/alt key during a restart and select Recovery Volume). Run Disk Utility Verify/Repair and Repair Permissions until you get no errors.  Reformat the drive using Disk Utility/Erase Mac OS Extended (Journaled), then click the Option button and select GUID. Then re-install the OS.
    OS X Recovery
    OS X Recovery (2)
    When you reboot, use Setup Assistant to restore your data.

  • HT3702 Tried to make an in-app purchase with new card information and they said purchase could not be made at this time and contact the iTune store for support. Can you tell me why?

    Trying to make an in-app purchase with new account information...purchase would not go thru...told me to contact the iTunes support.

    Nobody on these boards can. Click here and ask the iTunes Store staff for assistance.
    (101541)

  • Plugin fails to display modal dialog with ActiveX'ed bean

    I have first posted this in the ActiveX bridge group, and have gotten no response. Since the plugin group also has posts on modal dialogs, thought this is also correct to post here. Both plugin and ActiveX'ed beans use beans.ocx for display.
    I have a bean wrapped as ActiveX with sun.beans.ole.Packager. The bean provides a method, which ultimately will pop up a modal confirm dialog (JOptionPane.showConfirmDialog(.)).
    If the method is triggered solely from within the bean, say via a click on a bean's button, all is well.
    If the method is triggered from its host (VB form), the
    - the call is done on the main thread. The confirm dialog shows, but when I click on one of its buttons, the app hangs.
    - If I try to pass the call into the event dispatch thread (SwingUtilities.invokeAndWait(.)), the confirm dialog somewhat pops up, but does not paint completely and the app hangs.
    - If I try to pass the call into the event dispatch thread with SwingUtilities.invokeLater(.) all is well, the confirm dialog pops up, I can click on its buttons, etc. but the function returns to VB too early, which is not what I want since I need the answer.
    - I have tried the following:
    entry method determines it is not on the event dispatch thread.
    Tries itself with invokeLater(.), yields the current thread and calls wait(.).
    The method invoked later will execute in the event dispatch thread, popup the confirm dialog and when finished will do a notifyAll(.).
    Unfortunately, what happens is that the entry thread (the main thread) puts the invokeLater into the event dispatch queue, yields itself and wait()'s. And waits and waits. In the meantime, the dispatch thread will get to the point where it wants to show the confirm dialog, but will then hang. If I time out the wait in the main thread, then the confirm dialog is popped up immediately after the wait finishes with the time-out.
    Sooo, this tells me that there is some strange synchronization going on which causes something like a deadlock. Is there any good approach to triggering modal dialogs from a native app hosting the ActiveX'ed bean??
    I have found many entries on probs with modal dialogs in the plug-in, which relate to applets. But no solution yet.
    Some keywords that I have came across are:
    - the event dispatch queue can be flushed and "empty events" can be posted into it. Also, the invokeAndWait(.) will register a "conditional" message pump on the event queue that seems to work until the locking condition is no longer valid. Any experience with these? Any way to manipulate (a) main thread, (b) event dispatch queue, (c) event dispatch thread to resolve the apparent deadlock?
    - There seems to be some difference in locking when the parent process is VB/COM as when it is Java. I have the impression that the main thread has some lock until the call made from VB/COM is fully completed and the call stack cleaned up. Can anyone confirm this? And/or suggest a way around it?
    Sylvia

    Sylvia - I found your posting because I have a similar problem in which a JavaBean wrapped using the Packager needs to call a Visual Basic event subroutine from a thread other than the main thread.
    This, I have discovered, is not supported in VB unless you use special thread marshalling calls (not available to the Java bean) or event queuing calls (ditto, afaik).
    My point is that this may be related to your problem. Check this Microsnot document on their public support site:
    Q196026

  • Trying to make a slideshow of image with iMovie

    Trying to make a slideshow of images for clients. Images are good quality images (5616x3744), edited in Lightroom.
    As soon as I import the images in iMovie, I see a clear degradations in quality. All the blacks are full of pixels. Impossible to work with.
    I can't even imagine the export that this file would suffer in term of quality.
    I did change in Preferences - Video : Import video in HD format. I've tried both options. Doesn't change a thing.
    Anyone? Am I a fool to think that iMovie should be doing a better job at handling those files ?
    Let me know !
    Thanks !

    Hi
    (5616x3744)
    • is a far higher resolution than iMovie can handle
    • downscaling is done badly in iMovie
    • is far more resolution that any screen / Projector I know of can show
    • and if You go for a DVD as result the quality loss will be even worse
    iMovie - should be able to handle 1920x1080 (at it's best I guess)
    DVD is as standard - interlaced SD-Video (at it's best)
    • NTSC (29.97fps) 520 lines - about 640x480 pixels (square) 720x480 rectangular (narrow) pixels
    • PAL  (25 fps)   625   lines - about 768x576 pixels (square) 720x576 rectangular (narrow) pixels
    If iMovie'08 to 11 is used in a DVD process then 50% of SD-Video quality is lost as they all discard every second line in the picture.
    So when I do my SlideShows I do
    • Use iMovie HD6 or FinalCut any version - as they deliver max (100% interlaced SD-Video) to DVD authoring software
    • FotoMagico™ - included in Roxio Toast™ bundle - then burn as Blu-Ray (on standard DVDs - CAN ONLY be played on BD-Players as PlayStation3 (not even on the Mac))
    Yours Bengt W

  • Java help dialog invoked from modal dialog with webstart

    Hi,
    we have an application where we invoke a Help window from a modal dialog. It works fine if ran from IDE but doesn't work if ran from a webstart loader. The problem is to be able to set decorations (exit/minimize) for this help window but since this window is null (from printouts) it never goes to lines where decorations are set. The help dialog is displayed by calling super.setDisplayed(true) but it is not setting variables "frame" or "dialog" of DefaultHelpBroker class.
    I am sure it doesn't sound very clear but if you had a similar problem with web start messing up something please let me know.
    thanks.
    private static void initHelp()
        ClassLoader loader = HelpFactory.class.getClassLoader();
        try
          URL url = HelpSet.findHelpSet(loader, HELPSETNAME);
          helpSet = new HelpSet(loader, url);
          helpBroker = new DefaultHelpBroker(helpSet)
            public void setActivationWindow(Window window)
              if (window instanceof Dialog)
                Dialog d = (Dialog) window;
                if (d.isModal())
                  super.setActivationWindow(window);
                  return;
              super.setActivationWindow(null);
            public void setDisplayed(boolean b)
              //no exception here and shows dialog with no decorations
              super.setDisplayed(b);
              System.out.println("d: " + dialog);//prints null here
              System.out.println("d: " + frame); //prints null here
              if (b)
                if (dialog != null)//since this is true, it never sets decorations
                  dialog.hide();             
                  dialog.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
                  dialog.show();
          helpBroker.setFont(new Font("Verdana", Font.PLAIN, 12));
          helpListener = new HelpListener(helpBroker);
        catch (HelpSetException e)
          e.printStackTrace();
      }

    sorry guys, i should've posted it either in the web-start or on javahelp forums. I'll do it right now.
    never mind :-)

  • Modal window with onmouseOver event

    Hi Friends,
    I am using modal dialog window , in order to come back to parent screen from where the modal window is invoked, can I use onMouseOver event or something similar so that when user clicks or moves out of the modal window area , the modal window should be closed.

    Nav,
    WD doesn't support client side eventing / prgramming. Instead, you can simply store the window instance in a context attribute and destroy the window.
    If you are not familiar with this, you may follow <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/55/084640c0e56913e10000000a1550b0/frameset.htm">Closing a Pop up</a>
    ~ Bala

  • How can i open the "Convert to Indexed Color" dialog with custom presets?

    Hi,
    I need to automatically open the "Convert to Indexed Colors" dialog in Photoshop. Before and after that i have some scripts running so its not possible to open the dialog manually. Also i want to set some custom presets (like number of colors etc.).
    Found something similar to what i want for the Color Range selection (opens the dialog with the presets you put in):
    function colorrange(enabled, withDialog, fuzziness) {
        if (enabled != undefined && !enabled)
          return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        desc1.putInteger(app.charIDToTypeID('Fzns'),fuzziness);
        var desc2 = new ActionDescriptor();
        desc2.putDouble(app.charIDToTypeID('Lmnc'), 31.22);
        desc2.putDouble(app.stringIDToTypeID("a"), 0.86);
        desc2.putDouble(app.stringIDToTypeID("b"), 0.31);
        desc1.putObject(app.charIDToTypeID('Mnm '), app.charIDToTypeID('LbCl'), desc2);
        var desc3 = new ActionDescriptor();
        desc3.putDouble(app.charIDToTypeID('Lmnc'), 95.34);
        desc3.putDouble(app.stringIDToTypeID("a"), 54.59);
        desc3.putDouble(app.stringIDToTypeID("b"), 49.85);
        desc1.putObject(app.charIDToTypeID('Mxm '), app.charIDToTypeID('LbCl'), desc3);
        desc1.putInteger(app.stringIDToTypeID("colorModel"), 0);
        var desc4 = new ActionDescriptor();
        var desc4 = executeAction(app.stringIDToTypeID('colorRange'), desc1, dialogMode);
    How can i achieve the same for the indexed color conversion dialog? Apart from doing a lot of guessing regarding the stringIDs.
    Is there some kind of "lookup table" for char and string IDs?
    Thank you guys in advance! This forum has been a great help many times.

    Ok never mind i got it, stupid me.
    Recorded it with Script Listener and changed the "DialogMode" parameter of the executeAction function from "DialogModes.No" to "DialogModes.All".
    var idCnvM = charIDToTypeID( "CnvM" );
                var desc249 = new ActionDescriptor();
                var idT = charIDToTypeID( "T  " );
                    var desc250 = new ActionDescriptor();
                    var idPlt = charIDToTypeID( "Plt " );
                    var idClrP = charIDToTypeID( "ClrP" );
                    var idSele = charIDToTypeID( "Sele" );
                    desc250.putEnumerated( idPlt, idClrP, idSele );
                    var idClrs = charIDToTypeID( "Clrs" );
                    desc250.putInteger( idClrs, 4 );
                    var idFrcC = charIDToTypeID( "FrcC" );
                    var idFrcC = charIDToTypeID( "FrcC" );
                    var idNone = charIDToTypeID( "None" );
                    desc250.putEnumerated( idFrcC, idFrcC, idNone );
                    var idTrns = charIDToTypeID( "Trns" );
                    desc250.putBoolean( idTrns, false );
                    var idDthr = charIDToTypeID( "Dthr" );
                    var idDthr = charIDToTypeID( "Dthr" );
                    var idDfsn = charIDToTypeID( "Dfsn" );
                    desc250.putEnumerated( idDthr, idDthr, idDfsn );
                    var idDthA = charIDToTypeID( "DthA" );
                    desc250.putInteger( idDthA, 75 );
                var idIndC = charIDToTypeID( "IndC" );
                desc249.putObject( idT, idIndC, desc250 );
            executeAction( idCnvM, desc249, DialogModes.ALL ); //Change from NO to ALL

  • Need help with custom event from Main class to an unrelated class.

    Hey guys,
    I'm new to Flash and not great with OOP.  I've made it pretty far with google and lurking, but I've been pulling my hair out on this problem for a day and everything I try throws an error or simply doesn't hit the listener.
    I'm trying to get my Main class to send a custom event to an unrelated class called BigIcon.  The rest of the code works fine, it's just the addEventListener and dispatchEvent that isn't working.
    I've put in the relevant code in below.  Let me know if anything else is needed to troubleshoot.  Thank you!
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        public class Main extends MovieClip
            var iconLayer_mc:MovieClip = new MovieClip();
            public function Main()
                Spin_btn.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
                addChildAt(iconLayer_mc,0);
                placeIcons();
            function placeIcons():void
                var i:int;
                var j:int;
                for (i = 0; i < 4; i++)
                    for (j = 0; j < 5; j++)
                        //iconString_array has the names of illustrator objects that have been converted to MovieClips and are in the library.
                        var placedIcon_mc:BigIcon = new BigIcon(iconString_array[i][j],i,j);
                        iconLayer_mc.addChild(placedIcon_mc);
            function fl_MouseClickHandler(event:MouseEvent):void
                dispatchEvent(new Event("twitchupEvent",true));
    BigIcon.as
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.utils.getDefinitionByName;
        public class BigIcon extends MovieClip
            private var iconImage_str:String;
            private var iconRow_int:int;
            private var iconColumn_int:int;
            public function BigIcon(iconImage_arg:String, iconRow_arg:int, iconColumn_arg:int)
                iconImage_str = iconImage_arg;
                iconRow_int = iconRow_arg;
                iconColumn_int = iconColumn_arg;
                this.addEventListener(Event.ADDED_TO_STAGE, Setup);
            function Setup(e:Event)
                this.y = iconRow_int;
                this.x = iconColumn_int;
                var ClassReference:Class = getDefinitionByName(iconImage_str) as Class;
                var thisIcon_mc:MovieClip = new ClassReference;
                this.addChild(thisIcon_mc);
                addEventListener("twitchupEvent", twitchUp);
            function twitchUp(e:Event)
                this.y +=  10;

    Ned Murphy wrote:
    You should be getting an error for the Main.as class due to missing a line to import the Event class...
    import flash.events.Event;
    My apologies, I should attempt to compile my example code before I ask for help...
    Alright, this compiles, gives me no errors, shows my 'book' and 'flowers' icons perfectly when ran, and prints 'addEventListener' to the output window as expected.  I get no errors when I press the button, 'dispatchEvent' is output (good), but the 'twitchUp' function is never called and 'EventTriggered' is never output. 
    How do I get the 'twitchUp' event to trigger?
    Main.as
    package
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        import flash.events.*;
        public class Main extends MovieClip
            var iconLayer_mc:MovieClip = new MovieClip();
            var iconString_array:Array = new Array(2);
            public function Main()
                Spin_btn.addEventListener(MouseEvent.CLICK,fl_MouseClickHandler);
                addChildAt(iconLayer_mc,0);
                buildStringArray();
                placeIcons();
            function buildStringArray():void
                var i:int;
                var j:int;
                for (i = 0; i < 2; i++)
                    iconString_array[i] = new Array(3);
                    for (j = 0; j < 3; j++)
                        if (Math.random() > .5)
                            //'flowers' is the name of an illustrator object that has been converted to a MovieClip and is in the library
                            iconString_array[i][j] = "flowers";
                        else
                            //'book' is the name of an illustrator object that has been converted to a MovieClip and is in the library
                            iconString_array[i][j] = "book";
            function placeIcons():void
                var i:int;
                var j:int;
                for (i = 0; i < 2; i++)
                    for (j = 0; j < 3; j++)
                        //iconString_array has the names of illustrator objects that have been converted to MovieClips and are in the library.
                        var placedIcon_mc:BigIcon = new BigIcon(iconString_array[i][j],i*50,j*50);
                        iconLayer_mc.addChild(placedIcon_mc);
            function fl_MouseClickHandler(event:MouseEvent):void
                dispatchEvent(new Event("twitchupEvent",true));
                trace("dispatchEvent");
    BigIcon.as
    package
        import flash.display.MovieClip;
        import flash.events.*;
        import flash.utils.getDefinitionByName;
        public class BigIcon extends MovieClip
            private var iconImage_str:String;
            private var iconRow_int:int;
            private var iconColumn_int:int;
            public function BigIcon(iconImage_arg:String, iconRow_arg:int, iconColumn_arg:int)
                iconImage_str = iconImage_arg;
                iconRow_int = iconRow_arg;
                iconColumn_int = iconColumn_arg;
                this.addEventListener(Event.ADDED_TO_STAGE, Setup);
            function Setup(e:Event)
                this.y = iconRow_int;
                this.x = iconColumn_int;
                var ClassReference:Class = getDefinitionByName(iconImage_str) as Class;
                var thisIcon_mc:MovieClip = new ClassReference;
                this.addChild(thisIcon_mc);
                addEventListener("twitchupEvent", twitchUp);
                trace("addEventListener");
            function twitchUp(e:Event)
                this.y +=  10;
                trace("EventTriggered");
    Output:
    [SWF] Untitled-1.swf - 40457 bytes after decompression
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    addEventListener
    dispatchEvent
    [UnloadSWF] Untitled-1.swf
    Test Movie terminated.

  • Troubles with custom events

    Background:
    8.2 version
    I'm trying to throw/receive a custom event but nothing is working for the receive to work. Below is the event information.
    I create a process that throws the event. I create another process that has the event as, I have tried both Start point and Receive. It will not trap no matter what I do. How do I debug this?
    Cheers,
    Event:
    Asynchronous
    Event Data Template:
    <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.ec.gc.ca/xsd/SampleData/" elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.ec.gc.ca/xsd/SampleData/">
        <element name="SendEmail">
        <complexType >
            <all>
                <element name="EmailTo" type="string" />
                <element name="EmailFrom" type="string" />
                <element name="EmailSubject" type="string" />
                <element name="EmailCC" type="string" />
                <element name="EmailBCC" type="string" />
                <element name="EmailBody" type="string" />
            </all>
        </complexType>
        </element>
    </schema>

    Hi Jasmin,
    I have a custom event set up with a schema for the message as well as the main event. When I dispatch the event, the listener event I have set up does not receive the message body and I get an adobe.workflow.template.document.TemplateNodeNotFoundException: Template object ER1319221392779 not found.
    The event thrower is using a schema for the message body and the event receiver also uses an INPUT variable of type xml set to the same schema.
    Any idea what I'm doing wrong?
    Thanks,
    Jack

  • Working with custom events

    I am trying to work with the EventDispatcher class to dispatch a custom event to stop a video from playing. The video plays inside a MovieClip with an attached class file called PlayerProfile. I want the video in the PlayerProfile MovieClip to stop playing when the user clicks on another MovieClip called ScrollBox. I'm getting no compile or runtime erros, but the code is not stopping the video. I have seen use of a public static constant to represent the custom event. Is that what I am missing here.
    Any help, as always, is much appreciated.
    Here is the code for the PlayerProfile MovieClip with relevant code in bold:
    package
        import flash.display.MovieClip;
        import gs.TweenLite;
        import flash.events.MouseEvent;  
        import flash.events.Event;
        public class PlayerProfile extends MovieClip
            public function PlayerProfile()
                this.ProfileButton_mc.buttonMode = true;
                this.StatisticsButton_mc.buttonMode = true;
                this.HomeButton_mc.buttonMode = true;
                this.VideoButton_mc.buttonMode = true;
                this.ProfileButton_mc.addEventListener(MouseEvent.CLICK, profileClickHandler);
                this.StatisticsButton_mc.addEventListener(MouseEvent.CLICK, statisticsClickHandler);
                this.HomeButton_mc.addEventListener(MouseEvent.CLICK, homeClickHandler);
                this.VideoButton_mc.addEventListener(MouseEvent.CLICK, videoClickHandler);
                TweenLite.from(this, .5, {alpha:0});
                //adds the listener to receive the stopVideo custom event
                this.addEventListener("stopVideo", stopVideoHandler);
           //method to stop the video
            private function stopVideoHandler(event:Event):void
                this.Video_mc.stop();
            private function profileClickHandler(event:MouseEvent):void
                this.Video_mc.stop();
                this.gotoAndStop("Profile");
                TweenLite.from(event.target, .5, {alpha:0});
            private function statisticsClickHandler(event:MouseEvent):void
                this.Video_mc.stop();
                this.gotoAndStop("Stats");
                TweenLite.from(event.target, .5, {alpha:0});
            private function homeClickHandler(event:MouseEvent):void
                this.Video_mc.stop();
                event.target.root.gotoAndStop("Home");
            private function videoClickHandler(event:MouseEvent):void
                this.gotoAndStop("Video");
                TweenLite.from(event.target, .5, {alpha:0});
    Here is the code on my Main Timeline that dispatches the event, again with relevant code in bold:
    stop();
    //adds listeners to call the profile functions
    this.ScrollBox.addEventListener(MouseEvent.CLICK, clickHandler);
    //functions to advance the movie to the profiles
    function clickHandler(event:MouseEvent):void
        gotoAndStop(event.target.name);
    //code to dispatch the custom event
    this.ScrollBox.addEventListener(MouseEvent.CLICK, stopVideoHandler);
    function stopVideoHandler(event:Event):void
        dispatchEvent(new Event("stopVideo"));

    you have a scope issue.   your PlayerProfile instance is listening for that custom event.  your PlayerProfile instance must dispatch that event for the listener to detect it.  ie, if pp is your PlayerProfile instance on your main timeline, use:
    pp.dispatchEvent(new Event("stopVideo"));

  • Trying to make a php file work with my email form

    Hello,
    Going slightly mad trying to link my php file with my html and actually getting it to work.
    It (the php file) keeps coming up with a syntax error on line 37 - code hinting may not work etc etc but there is no error from what I can see - can anyone else point out the obviously to me? This is driving me around the bend!
    my code:
    <?php
    /*Subject and Email Variables */
        $emailSubject = 'Website Form';
        $webMaster = '[email protected]';
    /* Gathering Data Variables */
        $nameField = $_POST['name'];
        $addressField = $_POST['address'];
        $telephone1Field = $_POST['telephone1'];
        $telephone2Field = $_POST['telephone2'];
        $emailField = $_POST['email'];
        $name2Field = $_POST['name2'];
        $ageField = $_POST['age'];
        $dobField = $_POST['dob'];
        $commsField = $_POST['comms'];
        $messageField = $_POST['message'];
        $body = <<<EOD
    <br><hr><br>
    Name: $name <br>
    Address: $address <br>
    Telephone (daytime): $telephone1 <br>
    Telephone (mobile): $telephone2 <br>
    Email: $email <br>
    Childs Name: $name2 <br>
    Start Age: $age <br>
    Childs Date of Birth: $dob <br>
    Preferred form of communication: $comms <br>
    Message: $message <br>
    EOD;
        $headers = "From: $email\r\n";
        $headers .= "Content-type: text/html\r\n";
        $success = mail{$webMaster, $emailSubject,$body, $headers};
    /* Results rendered as HTML */
        $theResults = <<<EOD
    <html>
    <head>
    <title>Xxx</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {
        background-color: #f1f1f1;
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 12px;
        font-style: normal;
        line-height: normal;
        font-weight: normal;
        color: #666666;
        text-decoration: none;
    -->
    </style>
    </head>
    <div>
      <div align="left">Thank you for your message, Your email will be answered very soon!</div>
    </div>
    </body>
    </html>
    EOD;
    echo "$theResults";
    ?>

    Line 37 is this:
        $success = mail{$webMaster, $emailSubject,$body, $headers};
    It should be this:
        $success = mail($webMaster, $emailSubject, $body, $headers);
    Also the header for the From: is this:$headers = "From: $email\r\n"; but I don't see the variable defined for $email
    Also you should know about email injection. Someone could inject your headers and add additional BCC: addresses to send emails to many undisclosed recipients through your mail script. You'd be using your script to turn your server into a host for spam! Sanitize your fields to prevent injection attacks! Security should be the firt priority followed by functionality. If it's unsecure it shouldn't function

  • HT201209 I am trying to make a purchase on iTunes with a gift card but it is not allowing me to because it wants to use my credit/debit card which I know have no funds in. My iTunes account has $30 on it but won't work as wants to use credit card.

    My itunes account will not let me use my $30 credit which is loaded on. It wants to use my credit card which I've previously used but which now has been cancelled. I've gone into manage my account and tried to find where to de select credit card but there is no 'none' button. I now can't purchase from itunes.

    I had a similar problem, except my phone was a new IPhone 5s, and it was my first purchase. I simply put money into my credit card account (only $2), and gave them my credit card details in the payment info section. I then tried purchasing again and it worked using the gift card I had previously redeemed, maybe they just need to know that if it doesn't work there's enough money on your card, as a guarantee.   

  • Trying to get in touch via email with customer ser...

    Dear Forum,
    I am currently more than 3 months into an unresolved fault with my service (originally logged 11th Dec 2014). I am trying to establish a means, in writing, to express my disappointment and concerns in this regard to the customer management team (CMT) who are nominally helping to resolve this. Sadly, BT has arranged its customer service provision (sic) in such a way that they can get in touch with me at any point and through a variety of means but there is no routine way for me to get in touch directly with the member of the CMT dealing with the fault. Fighting through switchboards and help desks who have to relay the message internally rather than transferrring me is all very frustrating.
    Does anyone know of a reliable means of getting in touch with the CMT directly via email / web-form? (I do now have the desk number of the lady in the CMT dealing with the fault but for a phonecall to be effective she has to be on shift; the email inbox is more convenient and the situation has really gone beyond where phonecalls are appropriate.)
    I signed up to the forums following a Google search for ‘Libby Barr’, the various comments and threads with her name in the title suggesting that there was some direct route to customer service / resolution support through forums. Entertainingly, I see that there is no board for ‘customer service issues’. 
    Further, the ‘welcome to forums’ / verification email that gets sent out closes with this line
    "If you need to contact us please email <this address>" (Evidently, I cannot quote the addess is a forum post, but you know what it.)
    So I thought that I’d make use of this email address, rather air dirty linen in public, and got
    "Thanks for trying to get in touch with us. Sorry but we don’t monitor this mailbox, so you won’t get a reply to your email."
    Thank you, BT, I did need a laugh.

    I have asked a moderator to provide assistance, they will post an invite on this thread.
    They are the only BT employees on this forum, and are a UK based team of people, who take personal ownership of your problem.
    Once you get a reply, make sure that you are logged into the forum, then click on their name, you will see a screen like this. Click on the link as shown below.
    Please do not send them a personal message, as they cannot deal with service issues that way.
    For your own security, do not post any personal details, on this forum. That includes any tracking number you are give.
    They will respond either by phone or e-mail, when its your turn in the queue.
    Please use the tracked e-mail, to reply, not via the forum. Thanks
    This is the form you should see when you click on the link. If you do not see this form, then you have selected the wrong link.
    When you submit the form, you will receive an enquiry number, so please keep a note of it
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

Maybe you are looking for

  • If your ipod is not recognized by itunes...

    One easy mechanical thing to check - sometimes the contacts between the docking cable and the ipod get dirty. Get some electrical contact cleaner (ProGold is the best), spray a bit on a clean toothbrush (which you should never again use for anything

  • PO approval problem

    Hi esperts I am starting in PCW, and I would like to have some help to on a process that I need to configure, Purchase orders created from shopping carts from Catalog do not need approval, so must be automatically approved. So I need to find a expres

  • I reinstalled OSX Lion and now safari will not open at all and sends a crash report to apple.

    I am unable to open safari after reinstalling osx lion. i checked for any software updates and installed them and still safari doesn't open and just says it will send a report to apple

  • Oracle BPEL Java Client API: Reading Configurations dynamically

    We have a requirement to use Oracle BPEL Java client API to control the BPEL instances at the runtime, from an ADF BC Application. is there any possibility to read the configurations/properties that are required to look up (using 'oracle.soa.manageme

  • Why won't my iPhone connect to my wifi?

    I have an iPhone 5S and it wouldn't find/connect to my wifi. I tried going and looking at connections available and my network wasn't listed, I also tried connecting manually and it would say "Unable to join network". Please help? P.S My cousin has a