Extended Canvas, Event Listener - drag enter

I'm trying to add an eventListener to my extended Canvas
Class but seem to be having a slight problem.
I've created a loop which runs 16 times, adds an instance of
the canvas to a container and sets an drag enter event listener for
each one, however when i drag over only one of the canvas' reacts
to the drag enter (the last instance) - regardless of where i drag
the object.
heres some example code
for(var i = 0; i < 16;i++)
var foo:extendedCanvasObj = new extendedCanvasObj();
foo.setstyle.......
foo.addEventListener(dragEvent.DRAG_ENTER,function(event:DragEvent){
change the canvas backgroundcolour };
container.addChild(foo);
}

Thanks for the quick reply,
I understand what you mean, but how would i stop it from doing this?  I want the "new boxes" to know when a drag proxy has entered them but i don't want them to accept a drop.
Basically i'm building a form builder and the boxes represent fields.  I want them to know when the proxy has just enter them to i can perform a collision detection and move them to create space to drop the new field. 
Tom

Similar Messages

  • How to remove an event listener of Enter Frame

    basically, i doing a three level game. 1st level is dodging the stone from sky, Secondly, samsh the wolf head. However, when i enter leve1 2 game, it show me an error.
    TypeError: Error #2007: Parameter hitTestObject must be non-null.as:113  Cant access to null object or reference.as.83
    I think due to when i enter level 2, the object is not available anymore, so happen this errors,izzit? how i gonna fix this?
    package
              import flash.display.MovieClip;
              import flash.events.KeyboardEvent;
              import flash.ui.Keyboard;
              import flash.events.Event;
              import flash.events.MouseEvent;
              import flash.ui.Mouse;
              import flash.utils.Timer;
              import flash.events.TimerEvent;
              import flash.events.Event;
              public class level1 extends MovieClip
                        var vx:int;
                        var vy:int;
                        var collisionHasOccurred:Boolean;
                        var score:uint;
                        public function level1()
                                  init();
                        function init():void
                                  //Initialize variable
                                  vx=0;
                                  vy=0;
                                  collisionHasOccurred=false;
                                  stone.stop();
                                  score=0;
                                  optionPage.visible=false;
                        //Add event listeners
                        stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
                        stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
                        addEventListener(Event.ENTER_FRAME, onEnterFrame);
                        wolf2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
                        function onKeyDown(event:KeyboardEvent):void
                                  if(event.keyCode==Keyboard.LEFT)
                                            vx=-5;
                                  else if (event.keyCode==Keyboard.RIGHT)
                                            vx=5;
                                  else if (event.keyCode==Keyboard.UP)
                                            vy=-5;
                                  else if (event.keyCode==Keyboard.DOWN)
                                            vy=5;
                        function onKeyUp(event:KeyboardEvent):void
                                  if (event.keyCode==Keyboard.LEFT || event.keyCode==Keyboard.RIGHT)
                                            vx=0;
                                  else if (event.keyCode==Keyboard.DOWN || event.keyCode==Keyboard.UP)
                                  vy=0;
                        function onEnterFrame(event:Event):void
                                  trace(player);
                                  trace(cursor);
                                  trace(aaa);
                                  trace(wolf2);
                                  trace(wolf);
                                  //Move the player
                                  player.x+=vx;  <-------------------------------------------------------------this is line 83
                                  player.y+=vy;
                                  //collision detection
                                  if (stone.hitTestObject(player))
                                  player.gotoAndStop(3);
                                  health.meter.width-=2;
                                  if (! collisionHasOccurred)
                                            score++;
                                            messageDisplay.text=String(score);
                                            collisionHasOccurred=true;
                        else
                                  player.gotoAndStop(1);
                                  collisionHasOccurred=false;
                        if (health.meter.width <=1)
                                  New.text="Game Over!";
                                  stop();
                                  fl_CountDownTimerInstance_3.stop();
                        if (player.hitTestObject(wall))   <-------------------------------------------------this is line 113
                                  player.x-=vx;
                                  player.y-=vy;
                        if (player.hitTestObject(wallA))
                                  player.x-=vx;
                                  player.y-=vy;
                        if (player.hitTestObject(wallB))
                                  player.x-=vx;
                                  player.y-=vy;
                        if (player.hitTestObject(wallC))
                                  player.x-=vx;
                                  player.y-=vy;
                        if (player.hitTestObject(wallD))
                                  player.x-=vx;
                                  player.y-=vy;
                        if (player.hitTestObject(wallE))
                                  player.x-=vx;
                                  player.y-=vy;
                        if (player.hitTestObject(wallF))
                                  player.x-=vx;
                                  player.y-=vy;
                        if (player.hitTestObject(wallG))
                                  player.x-=vx;
                                  player.y-=vy;
                        if (player.hitTestObject(wallH))
                                  player.x-=vx;
                                  player.y-=vy;
                        function fl_MouseClickHandler(event:MouseEvent):void
                        score++;
                        aaa.text=String(score);
                        trace("Mouse clicked");

    instead of:
    if (player.hitTestObject(wall))
    use:
    if(player&&wall){
    if (player.hitTestObject(wall))

  • Adding an event listener to combo box

    I am working on a mortgage calculator and I cannot figure out how to add an event listener to a combo box.
    I want to get the mortgage term and interest rate to calucate the mortgage using the combo cox. Here is my program.
    Modify the mortgage program to allow the user to input the amount of a mortgage
    and then select from a menu of mortgage loans: 7 year at 5.35%, 15 year at 5.50%, and
    30 year at 5.75%. Use an array for the different loans. Display the mortgage payment
    amount. Then, list the loan balance and interest paid for each payment over the term
    of the loan. Allow the user to loop back and enter a new amount and make a new
    selection, with resulting new values. Allow user to exit if running as an application
    (can't do that for an applet though).
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.NumberFormat;
    import java.util.Locale;
    //creates class MortgageCalculator
    public class MortgageCalculator extends JFrame implements ActionListener {
    //creates title for calculator
         JPanel row = new JPanel();
         JLabel mortgageCalculator = new JLabel("MORTGAGE CALCULATOR", JLabel.CENTER);
    //creates labels and text fields for amount entered          
         JPanel firstRow = new JPanel(new GridLayout(3,1,1,1));
         JLabel mortgageLabel = new JLabel("Mortgage Payment $", JLabel.LEFT);
         JTextField mortgageAmount = new JTextField(10);
         JPanel secondRow = new JPanel();
         JLabel termLabel = new JLabel("Mortgage Term/Interest Rate", JLabel.LEFT);
         String[] term = {"7", "15", "30"};
         JComboBox mortgageTerm = new JComboBox(term);
         JPanel thirdRow = new JPanel();
         JLabel interestLabel = new JLabel("Interest Rate (%)", JLabel.LEFT);
         String[] interest = {"5.35", "5.50", "5.75"};
         JComboBox interestRate = new JComboBox(interest);
         JPanel fourthRow = new JPanel(new GridLayout(3, 2, 10, 10));
         JLabel paymentLabel = new JLabel("Monthly Payment $", JLabel.LEFT);
         JTextField monthlyPayment = new JTextField(10);
    //create buttons to calculate payment and clear fields
         JPanel fifthRow = new JPanel(new GridLayout(3, 2, 1, 1));
         JButton calculateButton = new JButton("CALCULATE PAYMENT");
         JButton clearButton = new JButton("CLEAR");
         JButton exitButton = new JButton("EXIT");
    //Display area
         JPanel sixthRow = new JPanel(new GridLayout(2, 2, 10, 10));
         JLabel displayArea = new JLabel(" ", JLabel.LEFT);
         JTextArea textarea = new JTextArea(" ", 8, 50);
    public MortgageCalculator() {
         super("Mortgage Calculator");                     //title of frame
         setSize(550, 350);                                             //size of frame
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container pane = getContentPane();
         GridLayout grid = new GridLayout(7, 3, 10, 10);
         pane.setLayout(grid);
         pane.add(row);
         pane.add(mortgageCalculator);
         pane.add(firstRow);
         pane.add(mortgageLabel);
         pane.add(mortgageAmount);
         pane.add(secondRow);
         pane.add(termLabel);
         pane.add(mortgageTerm);
         pane.add(thirdRow);
         pane.add(interestLabel);
         pane.add(interestRate);
         pane.add(fourthRow);
         pane.add(paymentLabel);
         pane.add(monthlyPayment);
         monthlyPayment.setEnabled(false);
         pane.add(fifthRow);
         pane.add(calculateButton);
         pane.add(clearButton);
         pane.add(exitButton);
         pane.add(sixthRow);
         pane.add(textarea); //adds texaarea to frame
         pane.add(displayArea);
         setContentPane(pane);
         setVisible(true);
         //Adds Listener to buttons
         calculateButton.addActionListener(this);
         clearButton.addActionListener(this);
         exitButton.addActionListener(this);
         mortgageTerm.addActionListener(this);
         interestRate.addActionListener(this);
    public void actionPerformed(ActionEvent event) { 
         Object command = event.getSource();
         JComboBox mortgageTerm = (JComboBox)event.getSource();
         String termYear = (String)mortgageTerm.getSelectedItem();
    if (command == calculateButton) //calculates mortgage payment
         int year = Integer.parseInt(mortgageTerm.getText());
         double rate = new Double(interestRate.getText()).doubleValue();
         double mortgage = new Double(mortgageAmount.getText()).doubleValue();
         double interest = rate /100.0 / 12.0;
         double monthly = mortgage *(interest/(1-Math.pow(interest+1,-12.0 * year)));
                   NumberFormat myCurrencyFormatter;
                   myCurrencyFormatter = NumberFormat.getCurrencyInstance(Locale.US);
                   monthlyPayment.setText(myCurrencyFormatter.format(monthly));
         if(command == clearButton) //clears all text fields
                   mortgageAmount.setText(null);
                   //mortgageTerm.setText(null);
                   //interestRate.setText(null);
                   monthlyPayment.setText(null);
              if(command == exitButton) //sets exit button
                        System.exit(0);
         public static void main(String[] arguments) {
              MortgageCalculator mor = new MortgageCalculator();

    The OP already did this to both JComboBoxes.
    mochatay, here is a new actionPerformed method for you to use.
    I've improved a few things here and there...
    1) You can't just cast the ActionEvent's source into a JComboBox!
    What if it was a JButton that fired the event? Then you would get ClassCastExceptions (I'm sure you did)
    So check for all options, what the source of the ActionEvent actually was...
    2) You can't assume the user will always type in valid data.
    So enclose the Integer and Double parse methods in try-catch brakcets.
    Then you can do something when you know that the user has entered invalid input
    (like tell him/her what a clumsy idiot they are !)
    3) As soon as user presses an item in any JComboBox, just re-calculate.
    I did this here by programmatically clicking the 'Calculate' button.
    Alternatively, you could have a 'calculate' method, which does everything inside the
    if(command==calculateButton) if-block.
    This will be called when:
    a)calculateButton is pressed
    b)when either of the JComboBoxes are pressed.
    public void actionPerformed (ActionEvent event)
            Object command = event.getSource ();
            if (command == calculateButton) //calculates mortgage payment
                int year = 0;
                double rate = 0;
                double mortgage = 0;
                double interest = 0;
                /* If user has input invalid data, tell him so
                and return (Exit from this method back to where we were before */
                try
                    year = Integer.parseInt (mortgageTerm.getSelectedItem ().toString ());
                    rate = new Double (interestRate.getSelectedItem ().toString ()).doubleValue ();
                    mortgage = new Double (mortgageAmount.getText ()).doubleValue ();
                    interest = rate / 100.0 / 12.0;
                catch (NumberFormatException nfe)
                    /* Display a message Dialogue box with a message */
                    JOptionPane.showMessageDialog (this, "Error! Invalid input!");
                    return;
                double monthly = mortgage * (interest / (1 - Math.pow (interest + 1, -12.0 * year)));
                NumberFormat myCurrencyFormatter;
                myCurrencyFormatter = NumberFormat.getCurrencyInstance (Locale.US);
                monthlyPayment.setText (myCurrencyFormatter.format (monthly));
            else if (command == clearButton) //clears all text fields
                /* Better than setting it to null (I think) */
                mortgageAmount.setText ("");
                //mortgageTerm.setText(null);
                //interestRate.setText(null);
                monthlyPayment.setText ("");
            else if (command == exitButton) //sets exit button
                System.exit (0);
            else if (command == mortgageTerm)
                /* Programmatically 'clicks' the button,
                As is user had clicked it */
                calculateButton.doClick ();
            else if (command == interestRate)
                calculateButton.doClick ();
            //JComboBox mortgageTerm = (JComboBox) event.getSource ();
            //String termYear = (String) mortgageTerm.getSelectedItem ();
        }Hope this solves your problems.
    I also hope you'll be able to learn from what I've indicated, so you can use similar things yourself
    in future!
    Regards,
    lutha

  • DataGroup Drag Enter Issue/Question (FB4)

    I'm working with Flash Builder 4, Flex 4 and I'm having difficulty in getting the drag events to fire, in particular the Drag Enter event. I have 2 dataGroups with a custom layout and itemRenderer. I'm attempting to drag an element from one DataGroup and drop it into the other DataGroup. In Flex 3, when I dragged something over a container, the event.CurrentTarget was the container, and I could then tell the container to accept the dragged item. In Flex 4, the dragEnter event isn't firing when I drag something over the DataGroup. It ONLY fires when I drag something over one of the rendered items in the DataGroup. Below is the code for the application, DataGroup, CustomLayout, and itemRenderer. If you debug the application and drag an item in the first DataGroup over the second DataGroup, note that you don't get the trace statements. If you drag the item so that the mouse passes over one of the elements in the second DataGroup, THEN the DragEnter events fires.
    Application:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application
    xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="
    library://ns.adobe.com/flex/spark" xmlns:mx="
    library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:ns1="*" >
    <fx:Script>
    <![CDATA[
    import mx.events.DragEvent; 
    private function dragEnterHandler(event:DragEvent):void { 
    trace ("Drag Enter"); 
    trace (" Target: "+event.target.id); 
    trace (" Current Target: "+event.currentTarget.id);}
    private function dragDropHandler(event:DragEvent):void { 
    trace (event.currentTarget.id);}
    ]]>
    </fx:Script>
    <s:SkinnableContainer top="0" left="0" right="0" bottom="0" id="dgContainer" >
    <ns1:myDataGroup left="5" id="dgOne" top="5" bottom="5" width="200" depth="1" dragEnter="dragEnterHandler(event)" dragDrop="dragDropHandler(event)"/>
    <ns1:myDataGroup left="226" id="dgTwo" top="5" bottom="5" width="200" depth="1" dragEnter="dragEnterHandler(event)" dragDrop="dragDropHandler(event)"/>  
    <mx:VRule left="213" top="0" bottom="0"/>
    </s:SkinnableContainer></s:Application>
    DataGroup:
    <?xml version="1.0" encoding="utf-8"?><s:DataGroup xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="
    library://ns.adobe.com/flex/spark" xmlns:mx="
    library://ns.adobe.com/flex/mx" dataProvider="{myAC}" width="
    100%" height="100%" xmlns:myLayout="myLayout.*" itemRenderer="iRenderer"creationComplete="addEventListener(RESIZE_CLICK, resizeHandler,
    false, 0, true);" initialize="cLayout.setLayout();" name="
    myDGroup" >
     <fx:Declarations>
     <!-- Place non-visual elements (e.g., services, value objects) here -->
     </fx:Declarations>
     <fx:Script>
    <![CDATA[
     import mx.collections.ArrayCollection; 
    import mx.events.DragEvent; 
    Bindable] 
    public var myAC:ArrayCollection = new ArrayCollection([{Height: 100, Label:
    "Test # 1", xPos: 0},{Height: 200, Label:
    "Test # 2", xPos: 0}]);
    public static const RESIZE_CLICK:String = "resizeClick"; 
    protected var resizingElement:iRenderer; 
    protected var initX:Number; 
    protected var initY:Number; 
    public var itemID:Number; 
    public function resizeHandler(event:MouseEvent):void { 
    if (event.target.name == 'iRenderer') {resizingElement = iRenderer(event.target);
    initX = event.localX;
    initY = event.localY;
    itemID = Number(resizingElement.uid);
    systemManager.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler,
    true);systemManager.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler,
    true);}
    protected function mouseMoveHandler(event:MouseEvent):void {event.stopImmediatePropagation();
    if (resizingElement.height + event.stageY - initY > 49) {myAC[itemID].Height = myAC[itemID].Height + event.stageY - initY;
    resizingElement.height = resizingElement.height + event.stageY - initY;
    initY = event.stageY;
    protected function mouseUpHandler(event:MouseEvent):void {cLayout.setLayout();
    this.invalidateDisplayList();systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler,
    true);systemManager.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler,
    true);}
    ]]>
    </fx:Script>
     <s:layout>
     <myLayout:customLayout id="cLayout" />
     </s:layout>
     </s:DataGroup>
    CustomLayout:
    package 
    myLayout {
     import mx.collections.ArrayCollection; 
    import mx.core.ILayoutElement; 
    import spark.components.DataGroup; 
    import spark.components.supportClasses.GroupBase; 
    import spark.components.supportClasses.ItemRenderer; 
    import spark.layouts.supportClasses.LayoutBase; 
    public class customLayout extends LayoutBase { 
    public var layoutTarget:GroupBase; 
    public var count:int; 
    public var dataProvider:ArrayCollection; 
    public var maxHeight:Number = 0; 
    public var maxWidth:Number; 
    public var x:Number; 
    public var y:Number; 
    public function setLayout():void {layoutTarget =
    this.target;dataProvider = ArrayCollection(DataGroup(target).dataProvider);
    count = layoutTarget.numElements;
    dataProvider.source.sortOn([
    "Height"], [Array.NUMERIC | Array.DESCENDING]); 
    if (dataProvider[0].Height > dataProvider[1].Height) {dataProvider[0].xPos = 0;
    dataProvider[1].xPos = 60;
    else if (dataProvider[1].Height > dataProvider[0].Height) {dataProvider[1].xPos = 0;
    dataProvider[0].xPos = 60;
    override public function updateDisplayList(containerWidth:Number, containerHeight:Number):void {  
    for (var ii:int = 0; ii < count; ii++) { 
    // get the current element, we're going to work with the 
    // ILayoutElement interface 
    var element:ILayoutElement = layoutTarget.getElementAt(ii); 
    var item:ItemRenderer = target.getElementAt(ii) as ItemRenderer; 
    // Resize the element to its preferred size by passing 
    // NaN for the width and height constraintselement.setLayoutBoundsSize(NaN, NaN);
    // Find out the element's dimensions sizes. 
    // We do this after the element has been already resized 
    // to its preferred size. 
    var elementWidth:Number = element.getLayoutBoundsWidth(); 
    var elementHeight:Number = element.getLayoutBoundsHeight();item.uid = String(ii);
    y = 0;
    x = dataProvider[ii].xPos;
    // Find maximum element extents. This is needed for 
    // the scrolling support.maxWidth = 50;
    maxHeight = dataProvider[ii].Height;
    // Position the elementelement.setLayoutBoundsPosition(x, y);
    element.setLayoutBoundsSize(maxWidth, maxHeight);
    // Scrolling support - update the content sizelayoutTarget.setContentSize(maxWidth, maxHeight);
    ItemRenderer:
    <?xml version="1.0" encoding="utf-8"?><s:ItemRenderer focusEnabled="false" xmlns:fx="
    http://ns.adobe.com/mxml/2009" xmlns:s="
    library://ns.adobe.com/flex/spark"height="
    100%" width="100%" alpha="1.0" buttonMode="true" useHandCursor="
    true" xmlns:mx="library://ns.adobe.com/flex/halo"mouseOut="mouseOutHandler(event)"
    mouseMove="mouseMoveHandler(event);"
    mouseDown="mouseDownHandler(event);"
    name="
    iRenderer" depth="1" xmlns:ns="library://ns.adobe.com/flex/mx">
     <s:states>
     <s:State name="State1"/>
     <s:State name="modify"/>
     </s:states> 
    <fx:Script>
    <![CDATA[
     import mx.core.DragSource; 
    import mx.managers.CursorManager; 
    import mx.managers.DragManager; 
    Embed(source="images/reSize.gif")]  
    public var reSize:Class; 
    public static const RESIZE_CLICK:String = "resizeClick"; 
    private function mouseDownHandler(event:MouseEvent):void { 
    if (event.localY >= (this.height - 10) && event.localY <= this.height && event.currentTarget.name == 'iRenderer') {CursorManager.setCursor(reSize, 0, 0, -8);
    var rbEvent:MouseEvent = new MouseEvent(RESIZE_CLICK, true);rbEvent.localX = event.stageX;
    rbEvent.localY = event.stageY;
    dispatchEvent(rbEvent);
    private function mouseOutHandler(event:MouseEvent):void { 
    if (event.buttonDown == false) {CursorManager.removeAllCursors();
    private function mouseMoveHandler(event:MouseEvent):void { 
    var target:String = event.currentTarget.toString(); 
    var target2:String = event.target.toString(); 
    if (event.buttonDown == true && event.currentTarget.name == 'iRenderer' && event.localY < (this.height - 10)) { 
    var dragInitiator:ItemRenderer = ItemRenderer(event.currentTarget); 
    var ds:DragSource = new DragSource();DragManager.doDrag(dragInitiator, ds, event);
    else if (event.localY >= (this.height - 10) && event.localY <= this.height && event.currentTarget.name == 'iRenderer') {CursorManager.setCursor(reSize, 0, 0, -8);
    else {CursorManager.removeAllCursors();
    ]]>
    </fx:Script>
     <s:SkinnableContainer id="apPanel" top="0" bottom="0" left="0" right="0" >
     <!-- layer 1: border -->
     <s:Rect left="0" right="0" top="0" bottom="0">
     <s:stroke>
     <s:SolidColorStroke color="#5E7788" alpha="1.0" weight="2" />
     </s:stroke>
     </s:Rect>
     <!-- layer 2: background fill -->
     <s:Rect id="background" left="1" top="1" right="1" bottom="1">
     <s:fill>
     <s:SolidColor color="0x5E7788" id="bgFill" alpha="1.0" />
     </s:fill>
     </s:Rect>
     <!-- layer 3: title bar fill -->
     <s:Rect left="2" right="2" top="2" height.State1="15" height.modify="30">
     <s:fill>
     <s:SolidColor color="white" alpha="1.0"/>
     </s:fill>
     </s:Rect>
     <s:Label id="titleDisplay" text="{data.Label}" top="3" left="2" right="2" height="15" verticalAlign="middle" fontWeight="bold" includeIn="State1" fontSize="10"/>
     </s:SkinnableContainer>
     </s:ItemRenderer> 

    DataGroup and SkinnableDataContainer do have all the necessary drag events, so I should be able to use them for manual drag & drop. I actually do think this could be a bug. However, I found an odd workaround. If I add a mouseOver event that does absolutely nothing, then it appears that I can drag and drop without issue. See following code:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="library://ns.adobe.com/flex/spark"xmlns:mx="library://ns.adobe.com/flex/mx"height="100%" width="100%" xmlns:ns1="*">
    <fx:Script><![CDATA[
    import mx.events.DragEvent;import mx.managers.DragManager; 
    import spark.components.DataGroup; 
    private function dragEnterHandler(event:Event):void {trace ("Drag Enter");trace (event.currentTarget.id);DragManager.acceptDragDrop(DataGroup(event.currentTarget));
    private function mouseOverHandler(event:MouseEvent):void {//Without this function added, drag & drop stops working.
    private function dragDropHandler(event:DragEvent):void {trace ("Drag Drop");trace (" Target: "+event.currentTarget.id);trace (" y: "+event.localY);}
    ]]>
    </fx:Script>
    <ns1:myDataGroup id="dgOne" left="5" top="5" width="200" bottom="5" dragEnter="dragEnterHandler(event);" mouseOver="mouseOverHandler(event)" dragDrop="dragDropHandler(event)" /><ns1:myDataGroup id="dgTwo" left="220" top="5" width="200" bottom="5" dragEnter="dragEnterHandler(event);" mouseOver="mouseOverHandler(event)" dragDrop="dragDropHandler(event)" /><mx:VRule left="210" top="0" bottom="0" /></s:Application>

  • AWT Event Listener not listening...

    Hi,
    I'm having problems with an AWT Event Listener on a JFrame.
    Basically, im making a tank game, so the first screen to appear is an inventory screen. The when you click start on this screen, you create a GameScreen which extends JFrame. i have an AWT Event Listener added to this frame using this code:
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener(){
    public void eventDispatched(AWTEvent e) {
    if(((KeyEvent)e).getKeyCode() == KeyEvent.VK_DOWN && e.getID() == KeyEvent.KEY_PRESSED)
    It's checking events on the arrow keys and the tab and enter keys.
    So when the this round of the game has finished, i setVisible to false, and make the inventory visible again.
    The problem is, when i set make the GameScreen visible again, the listeners aren't working.
    It seems to be working fine for 'enter', that is VK_ENTER, but not for the arrow keys...
    Any1 have any ideas??
    Any help would be great!
    Thanks,
    D.

    I am willing to bet that your problem lies in that once you return the main game screen from the inventory screen that you need to set the focus back to the main game screen. I believe, as events go, the component that has the focus is the one that will receive the events and process them according to their listener code. As I am not sure where your focus goes once you close the inventory screen and open the main screen, it could be that the wrong component has the focus.
    As far as getting the focus to the correct component is concerned, I remember myself and Malohkan having a discussion as to how to get this to work, and he came up with a work-around. That thread is somewhere in this forum. I'm not sure if it will solve your problem, but it might be something worth looking into.
    -N.

  • Cell event listener

    Hi,
    Assume I have jtable which have three column: numberone, numbertwo, and result.....
    I put value 1 into numberone column ( row one ), and put value 2 into numbertwo column (row one).... and when I press Enter or change the cell to down or left or right, suddenly result column is put value 3. This is simple addition jtable. How do I make such event listener. When I change the cell( after putting value in numberone column and numbertwo column ), the result column compute the value in numberone column and numbertwo column.

    what's wrong????My testing stinks.import java.awt.*;
    import javax.swing.event.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      JTable jt = new JTable(10,3);
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.getModel().addTableModelListener(new TableModelListener() {
          public void tableChanged(TableModelEvent tme) {
            int col=tme.getColumn(), row=tme.getFirstRow();
            if (col!=2) {
              try {
                int val0 = Integer.parseInt(jt.getValueAt(row, 0).toString()),
                    val1 = Integer.parseInt(jt.getValueAt(row, 1).toString());
                jt.setValueAt(new Integer(val0 + val1), row, 2);
              } catch (Exception e) {
                jt.setValueAt("Error", row, 2);
        setSize(300,300);
        setVisible(true);
      public static void main(String[] args) { new Test3(); }
    }

  • Command or Canvas Events for Recording ?? Please Help..

    Hi I am Abhijith I am a total newbie to the j2me world, And I am learning it now,
    My project topic is "Bluetooth Walkie Talkie " , And I am trying my best and putting
    all my efforts to code incrementally by learning , Before I could implement bluetooth,
    I thought let me complete the recording The audio and playing part first,
    The recording and playing of audio is working fine , But i would like to do it a real manner as Real Walkie talkie does, I want to record audio ONLY when the Key is being
    pressed , and when its released it should exit the player hence saving the recorded file,
    (Actually i dont want to save it in future,i would be sending the bytearray though the bluetooth , but for now , I want the Current module to be ready)
    I tried my best searching online to implement my requirement but the couldnot find
    such events I found Canva's KEYPRESS, KEYRELEASE , etc events but they dint not
    serve my purpose, Let me clearly tell where I am stuck , After the midlet starts(by launching it) then i would like to press a key( keypressed say No 5) for certain
    amount of time and the audio should be recorded only for the keypressed duration ,
    after I release , it should stop recording and save as a wav file .
    Whats happening is When i keep the key pressed , The midlet asks whether to allow
    the recording , for this purpose when I release key the control is going out, and
    i am not able to achieve the needed , I am posting the code here, Please Help me.
    I am not asking for the complete spoon feeding or ready made code, But as a beginner
    I need help from you all to learn and implement it.(at least it should satisfy me,i would feel i have learnt something then)
    Here below is my code ( i AM using WTK 2.5 )
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.*;
    import java.io.*;
    import javax.microedition.media.control.*;
    import java.util.*;
    import javax.microedition.io.*;
    import javax.microedition.io.file.*;
    public class Key extends MIDlet{
      private Display  display;
      private KeyCodeCanvas canvas;
      public Key(){
        display = Display.getDisplay(this);
        canvas  = new KeyCodeCanvas(this);
      protected void startApp(){
        display.setCurrent(canvas);
      protected void pauseApp(){}
      protected void destroyApp( boolean unconditional ){
        notifyDestroyed();
    class KeyCodeCanvas extends Canvas implements CommandListener{
      private Command exit;
         public StringItem message ;
         private Player player;
         private byte[] recordedAudioArray = null;
      private String keyValue = null;
      private Key midlet;
         Thread t = null;
         private String eventType = null;
      public KeyCodeCanvas(Key midlet){
        this.midlet = midlet;
        exit = new Command("Exit", Command.EXIT, 1);
        addCommand(exit);
        setCommandListener(this);
      protected void paint(Graphics g){
          g.setColor(255, 0, 0);
          g.fillRect(0, 0, getWidth(), getHeight());
        if (keyValue != null){
          g.setColor(0, 0, 255);
           g.drawString(keyValue + eventType+message, getWidth() / 2, getHeight() / 2,
         Graphics.TOP | Graphics.HCENTER);
      public void commandAction(Command c, Displayable d){
        String label = c.getLabel();
        if(label.equals("Exit"))
          midlet.destroyApp(true);
      protected void keyPressed(int keyCode){
         eventType = "pressed";
        keyValue = getKeyName(keyCode);
        repaint();
      public void keyReleased(int keyCode)
           try
                eventType = "released";
                keyValue = getKeyName(keyCode);
                repaint();
           catch (Exception e)
                System.out.print(e);
      public void keyRepeated(int keyCode)
           eventType = "repeated";
           keyValue = getKeyName(keyCode);
           try
                Thread t1 = new Thread()
                     public void run()
                          try
                               player = Manager.createPlayer("capture://audio?encoding=pcm");
                               player.realize();
                               RecordControl rc = (RecordControl)player.getControl("RecordControl");
                               ByteArrayOutputStream output = new ByteArrayOutputStream();
                               rc.setRecordStream(output);
                               rc.startRecord();
                               player.start();
                               eventType = "Recording";
                               message.setText("Recording...");
                               Thread.sleep(5000);
                               message.setText("Recording Done!");
                               rc.commit();
                               recordedAudioArray = output.toByteArray();
                               player.close();
                          catch (Exception e)
                }; t1.start();
           catch (Exception e)
           repaint();
         //Runnable r1 = new Runnable()
         //    public void run()
         //        try
         //            System.out.print(" here 1");
         //            message.setText(" here 1 ");
         //            player = Manager.createPlayer("capture://audio?encoding=pcm");
         //            player.realize();
         //            RecordControl rc = (RecordControl)player.getControl("RecordControl");
         //            ByteArrayOutputStream output = new ByteArrayOutputStream();
         //            rc.setRecordStream(output);
         //            rc.startRecord();
         //            player.start();
         //            eventType = "Recording";
         //            message.setText("Recording...");
         //            Thread.sleep(5000);
         //            message.setText("Recording Done!");
         //            rc.commit();
         //            recordedAudioArray = output.toByteArray();
         //            player.close();
         //        catch (Exception e)
    }I am really sorry at the end I messed with the code and its altered a Lot, But hope the
    logic Will is clear which is my requirement . I know the code for recording and
    playing is not complete as said, i Messed around a working code and tried adding Canavs
    for keyrepeat method,tried putting a thread around , AT last totally messed,
    I tried working on this for two days but couldn't be successfull , Please Help me!!
    The control goes out when midlet asks whether to allow recording ,
    I thank you anticipation ...
    -Abhijith Rao

    Midlet asking whether to allow the recording are typical permissions prompts specified by MIDP security policy. You need to sign the MIDlet and give it proper permissions.
    Problems like this were discussed in an older thread at WTK forum: *[MIDlet keeps asking for permission.|http://forums.sun.com/thread.jspa?threadID=5347313]* According to one of the posters in the thread, +"...I got it to work on the emulator by setting the permission to 'manufacturer'. It runs smoothly without annoying questions..."+
    If you're interested, check documentation and tutorials on MIDP security policy for more details.
    For events to record audio only when the key is being pressed, consider GameCanvas API, method getKeyStates.
    I am not certain though if doing it this way is a good idea. I doubt that phone users have same habits as those of walkie-talkies; for them it might be indeed more comfortable to use single simple key presses to start and finish recording.

  • Help with event listener

    I'm having some trouble trying to figure out how this event listener will work.
    The main application is building an arrayCollection of a calendarDay custom components which is displayed by a DataGroup.
    Within each calendarDay custom component i may create an arrayList of a DriverDetailComponent custom components displayed within the calendarDay by a DataGroup.
    If a user double clicks on the DriverDetailComponent that is two layers in I would like to change states of the main application.  I'm having trouble figuring out what item in the main application to set the listener on.  Please help.
    I can't figure out how to post the below as scrollable code snips so this is very long.
    Main application code:
    <code><?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="components.*"
                   preinitialize="readDataFile()"
                   creationComplete="buildRowTitles()"
                   width="1024" height="512"  backgroundColor="#A4BDD8">
        <s:states>
            <s:State name="State1"/>
            <s:State name="driverDetailState"/>
        </s:states>
        <!--
        <fx:Style source="EventCalendar.css"/>
        creationComplete="readDataFile()"    creationComplete="driversList.send()"-->
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->       
            <mx:DateFormatter id="myDateFormatter"
                              formatString="EEE, MMM D, YYYY"/>
            <!--<s:HTTPService id="driversList"
                           url="files/drivers.xml"
                           result="driversList_resultHandler(event)"
                           fault="driversList_faultHandler(event)"/>
            <s:HTTPService id="postDriversList"
                           url="files/drivers.xml"
                           method="POST"
                           result="postDriversList_resultHandler(event)"
                />-->
            <!--<s:Move id="expandTab"
                    target="{labelTab}"
                    xBy="250"/>-->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import components.CalendarDay;
                import components.TruckDriver;
                import components.calendarDay;
                import events.CancelChangeDriversEvent;
                import events.ChangeDriversEvent;
                import events.EditDriverEvent;
                import mx.collections.ArrayCollection;
                import mx.collections.ArrayList;
                import mx.containers.Form;
                import mx.controls.Alert;
                import mx.controls.CalendarLayout;
                import mx.core.FlexGlobals;
                import mx.core.IVisualElement;
                import mx.core.WindowedApplication;
                import mx.printing.FlexPrintJob;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.xml.SimpleXMLEncoder;
                import spark.components.Application;
                import utilities.FormatUtil;
                import utilities.ObjectToXML;
                /* public var prefsFile:File; */ // The preferences prefsFile
                [Bindable] public var driversXML:XML; // The XML data
                public var stream:FileStream; // The FileStream object used to read and write prefsFile data.
                public var fileName:String="driversArrayCollection";
                public var directory:String = "AceTrackerData";
                public var dataFile:File = File.documentsDirectory.resolvePath(directory + "\\" + fileName);
                [Bindable]
                public var drivers:ArrayCollection=new ArrayCollection();
                private var fileStream:FileStream;
                [Bindable]
                public var calendarDayArray:ArrayCollection = new ArrayCollection;
                public var i:int;
                [Bindable]
                public var weekOneTitle:String;
                [Bindable]
                public var weekTwoTitle:String;
                [Bindable]
                public var weekThreeTitle:String;
                [Bindable]
                public var weekFourTitle:String;
                public var day:Object;
                protected function readDataFile():void
                    if(dataFile.exists)
                        fileStream = new FileStream();
                        fileStream.open(dataFile, FileMode.READ);
                        drivers = fileStream.readObject() as ArrayCollection;
                        fileStream.close();
                    else
                        drivers = new ArrayCollection();
                        var driver:TruckDriver = new TruckDriver("New", "Driver", 000);
                        drivers.addItem(driver);
                        saveData(drivers);
                    buildCalendarArray();
                protected function buildCalendarArray():void
                    calendarDayArray.removeAll();
                    for (i=0; i<28; i++)
                        var cd:calendarDay = new calendarDay;
                        cd.dateOffset= i-7
                        cd.drivers=drivers;
                         cd.addEventListener("editDriverEvent",editDriverEvent_Handler);
                        calendarDayArray.addItem(cd);
              private function saveData(obj:Object):void//this is called on the postDriversList result handler to create and write XML data to the file
                    var fs:FileStream = new FileStream();
                    fs.open(dataFile, FileMode.WRITE);
                    /* fs.writeUTFBytes(myXML); */
                    fs.writeObject(drivers);
                    fs.close();
                protected function driverschedule1_changeDriversHandler(event:ChangeDriversEvent):void
                    saveData(drivers); 
                    readDataFile();//i read the drivers file again, this refreshes my data, and removes any temporary data that may have been stored in the drivers array
                    buildCalendarArray();
                    currentState = 'State1';//this hides the driversdetail window after we've clicked save
                    /* postDriversList.send(event.driverInfo); */  //this needs to be different
                    /* Alert.show("TEST"); */
                protected function driverschedule1_cancelChangeDriversHandler(event:CancelChangeDriversEvent):void
                    /* Alert.show("Changes have been canceled."); */
                    readDataFile();//this re-reads the saved data file so that the changes that were made in the pop up window
                    // are no longer reflected if you reopen the window
                    buildCalendarArray();
                    currentState = 'State1';  //this hides the driversdetail window after we've clicked cancel
                protected function buildRowTitles():void
                    var calendarDay0:Object;
                    var calendarDay6:Object;
                    calendarDay0=calendarDayArray.getItemAt(0);
                    calendarDay6=calendarDayArray.getItemAt(6);
                    weekOneTitle = calendarDay0.getDayString() + " - " + calendarDay6.getDayString();
                    weekTwoTitle=calendarDayArray.getItemAt(7).getDayString()+ " - " + calendarDayArray.getItemAt(13).getDayString();
                    weekThreeTitle=calendarDayArray.getItemAt(14).getDayString()+ " - " + calendarDayArray.getItemAt(20).getDayString();
                    weekFourTitle=calendarDayArray.getItemAt(21).getDayString()+ " - " + calendarDayArray.getItemAt(27).getDayString();
            ]]>
        </fx:Script>
        <s:Group height="100%" width="100%">
            <s:layout>
                <s:BasicLayout/>  <!--This is the outermost layout for the main application MXML-->
            </s:layout>
        <s:Scroller width="95%" height="100%"  >
        <s:Group height="100%" width="100%"  ><!--this groups the vertically laid out row titles hoizontally with the large group of calendar days and day titles-->
            <s:layout>
                <s:HorizontalLayout/>
            </s:layout>
        <s:Group height="95%" width="50" ><!--this is the group of row titles layed out vertically-->
            <s:layout>
                <s:VerticalLayout paddingLeft="40" paddingTop="35"/>
            </s:layout>
            <s:Label text="{weekOneTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
            <s:Label text="{weekTwoTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center" />
            <s:Label text="{weekThreeTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
            <s:Label text="{weekFourTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
        </s:Group>
        <s:Group height="100%" width="100%" >
            <!--this vertically groups together the horizontal day names group and the tile layout datagroup of calendar days-->
            <s:layout>
                <s:VerticalLayout paddingLeft="5"/>
            </s:layout>
        <s:Group width="100%" >
            <s:layout><!--this group horizontal layout is for the Day names at the top-->
                <s:HorizontalLayout paddingTop="10"/>
            </s:layout>
            <s:Label id="dayNames" text="Sunday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Monday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Tuesday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Wednesday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Thursday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Friday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Saturday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
        </s:Group>
            <!--<s:SkinnableContainer width="16%">-->
                <s:DataGroup id="calendarDataGroup"
                             dataProvider="{calendarDayArray}"
                             itemRenderer="{null}"  resizeMode="scale"
                              height="100%" width="100%"
                              >  <!--  I had to use a null renderer because otherwise each instance is added in a group container renderers.DriverScheduleRenderer-->
                    <s:layout >
                        <s:TileLayout requestedColumnCount="7" />
                    </s:layout>
                </s:DataGroup>
            <!--</s:SkinnableContainer>-->
        <!--<mx:FormItem label="Today's Date:">
            <s:TextInput id="dateToday"
                         text="{myDateFormatter.format(testDate)}"/>
        </mx:FormItem>-->
        <!--<components:DriverSchedule drivers="{drivers}"
                                   changeDriversEvent="driverschedule1_changeDriversHandler(event)"/>-->
            <s:HGroup>  <!--this groups together my drivers button and my print button at the bottom of the calendar-->
            <s:Button id="showDriverDetailButton"
                      label="Driver List"
                      click="currentState = 'driverDetailState'">
                <!--</s:Button>
                <s:Button id="printButton"
                    label="Print"
                    >  click="printButton_clickHandler(event)"-->
                </s:Button>
            </s:HGroup>    <!--this is the end of the small hgroup which pairs my drivers button with the print button-->                  
        </s:Group><!--this ends the vertical grouping of the day names and the tile layout calendar-->   
    </s:Group>        <!--this ends the horizontal grouping of the calendar (names and days) with the week labels at the left-->
        </s:Scroller>
            <s:SkinnableContainer includeIn="driverDetailState"
                                  width="95%" height="95%"  horizontalCenter="0" verticalCenter="0"
                                  backgroundColor="#989898" backgroundAlpha="0.51">
                <s:BorderContainer horizontalCenter="0" verticalCenter="0">
                <components:DriverSchedule id="driverSchedule"
                                            drivers="{drivers}"
                                           changeDriversEvent="driverschedule1_changeDriversHandler(event)"
                                           cancelChangeDriversEvent="driverschedule1_cancelChangeDriversHandler(event)"
                                           />
                </s:BorderContainer>
            </s:SkinnableContainer>
        </s:Group>  <!--end of basic layout group-->
    </s:WindowedApplication>
    </code>
    calendarDay.mxml code:
    <code>
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx"
             creationComplete="initDay()"
              width="100%">  <!--width="16%" height="25%"  width="160" height="112"-->
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <mx:DateFormatter id="myDateFormatter"
                              formatString="MMM D"/>
        </fx:Declarations>
        <fx:Metadata>
            [Event(name = "editDriverEvent", type="events.EditDriverEvent")]
        </fx:Metadata>
        <fx:Script>
            <![CDATA[
                import components.CalendarDay;
                import components.DriverDetailComponent;
                import events.EditDriverEvent;
                import mx.collections.ArrayCollection;
                import mx.collections.ArrayList;
                import mx.controls.CalendarLayout;
                import mx.controls.DateField;
                [Bindable]
                public var todayCollection:ArrayCollection = new ArrayCollection;
                [Bindable]
                public var todayList:ArrayList=new ArrayList; //arraylist created as data provider for dataGroup, this is where all drivers with an arrival date of today are added
                [Bindable]
                public var currDate:Date =new Date; //this will be used to contain the current real world date
                [Bindable]
                public var calDate:Date = new Date; //this is used below to determine the date of the calender day that is being created
                [Bindable] 
                public var todaysDate:CalendarDay;
                [Bindable]
                public var currDay:int;
                [Bindable]
                public var dateOffset:int;
                public var drivers:ArrayCollection= new ArrayCollection();
                   public var driver:Object;  
                public var rowLabel:String;
                public function initDay():void
                    todaysDate  = new CalendarDay(currDate, currDate.day, dateOffset)//currDate represents the day the operating system says today is
                        currDay=todaysDate.returnDate().getDate();//currDay is an int representing the day of the month
                        calDate=todaysDate.returnDate();//calDate represents the actual date on the calendar (MM-DD-YYY) that is currently being evaluated
                        /* if (currDay ==currDate.getDate()) //i want to highlight the day if it is in fact today
                            cont.styleName="Today";
                            if (calDate.getDate() == currDate.getDate())
                            calDayBorder.setStyle("backgroundColor", "#FFFF00");
                        else
                            calDayBorder.setStyle("backgroundColor", "#EEEEEE");
                         addDrivers(); 
                    return;
                  public function addDrivers():void
                       var count:int = 0;
                      /*var driverDetail:DriverDetailComponent;
                      var driver =  */
                    for each (driver in drivers)
                    {//i check the date value based on data entry of mm-dd-yy format against the calculated date for the day
                        //the calender is building and if it is equal the drivers information is added to this day of the calendar
                        if (DateField.stringToDate(driver.arrivalDate,"MM/DD/YYYY").getDate() == calDate.getDate())
                                var driverDetail:DriverDetailComponent = new DriverDetailComponent; //i create a new visual component that adds the id and destination to the calendar day
                                driverDetail.driverid = drivers[count].id; //i feed the id property which is the truck# - firstName
                                driverDetail.driverToLoc=drivers[count].toLoc; //i feed the toLoc which is the current destination of the driver
                                driverDetail.driverArrayLocation=count;   //here i feed the location of this driver in the "drivers" array so i know where it's at for the click listener
                                todayList.addItem(driverDetail);
                            //this concatenates the drivers truck number first name and destination to display in the calendar day
                                /* todayList.addItem(driver.truckNumber + " - " + driver.firstName + " - " + driver.toLoc); */
                    count ++;
                public function getDayString():String
                    rowLabel =myDateFormatter.format(calDate);
                    return rowLabel;
            ]]>
        </fx:Script>
        <s:BorderContainer id="calDayBorder" width="160" styleName="Today" cornerRadius="2" dropShadowVisible="true" height="100%">
            <s:layout>
                <s:BasicLayout/>   
            </s:layout>
            <!--I need to make a custom item renderer for my calendar days that limits the height and width of the day, and also puts the items
            closer together so i can fit maybe 5 drivers on a single day-->
            <s:DataGroup dataProvider="{todayList}"
                         itemRenderer="spark.skins.spark.DefaultComplexItemRenderer"
                         bottom="-2"
                         width="115" left="2">  <!--width="94%"  width="100"  width="16%"-->
                <s:layout >
                    <s:VerticalLayout gap="-4"/> <!--The reduced gap pushes the drivers together if there are serveral on one day. This helps cleanly show several drivers on one day-->
                </s:layout>
            </s:DataGroup >
            <s:Label  text="{currDay}" right="3" top="2" fontSize="14" fontWeight="bold"/>
        </s:BorderContainer>
    </s:Group>
    </code>
    DriverDetailComponent code:
    <code><?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Metadata>
            [Event(name = "editDriverEvent", type="events.EditDriverEvent")]
        </fx:Metadata>
        <fx:Script>
            <![CDATA[
                import events.EditDriverEvent;
                import mx.controls.Alert;
                [Bindable]
                public var driverid:String;
                [Bindable]
                public var driverArrayLocation:int;
                [Bindable]
                public var driverToLoc:String;
                protected function label1_doubleClickHandler(event:MouseEvent):void
                    Alert.show("You have selected " +driverid +" at location "  + driverArrayLocation.toString() +" in the drivers ArrayCollection.");
                    var eventObject:EditDriverEvent = new EditDriverEvent("editDriverEvent",driverArrayLocation);
                    dispatchEvent(eventObject);
            ]]>
        </fx:Script>
        <s:Label id="driverDetailLabel" text="{driverid} - {driverToLoc}"  doubleClick="label1_doubleClickHandler(event)" doubleClickEnabled="true"/>
    </s:Group>
    </code>

    lkb3 wrote:
    I'm trying to add a listener to [this JOptionPane pane dialog box|http://beidlers.net/photos/d/516-1/search_screenshot.JPG|my dialog box], so that when it pops up, the cursor is in the text box, but then if the user clicks a button other than the default, the cursor reverts back into the text box.
    The code I have is this:
      // BUILD DIALOG BOX
    JLabel option_label = new JLabel("Select a search option:");
    // Create the button objects
    JRadioButton b1 = new JRadioButton("Search PARTS by name");
    JRadioButton b2 = new JRadioButton("Search ASSEMBLIES by name");
    JRadioButton b3 = new JRadioButton("Search DRAWINGS by name");
    JRadioButton b4 = new JRadioButton("Search all by DESCRIPTION");
    b1.setSelected(true);
    // Tie them together in a group
    ButtonGroup group = new ButtonGroup();
    group.add(b1);
    group.add(b2);
    group.add(b3);
    group.add(b4);
    // Add them to a panel stacking vertically
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
    panel.add(b1);
    panel.add(b2);
    panel.add(b3);
    panel.add(b4);
    JLabel name_label = new JLabel("Enter a search term (add *'s as required)");
    JTextField name = new JTextField(30);
    name.addComponentListener(new ComponentListener() {
    public void componentHidden(ComponentEvent ce) { }
    public void componentMoved(ComponentEvent ce) { }
    public void componentResized(ComponentEvent ce) {
    ce.getComponent().requestFocus();
    public void componentShown(ComponentEvent ce) { }
    Object[] array = { option_label, panel, name_label, name };
    // GET INPUT FROM USER
    int res = JOptionPane.showConfirmDialog(null, array, "Select", JOptionPane.OK_CANCEL_OPTION);
    String searchTerm = name.getText();This sucessfully has the focus in the text box when opened; is there a way to get the focus to go back into the text box after the user clicks a radio button?
    Thanks!
    [this JOptionPane pane dialog box|http://beidlers.net/photos/d/516-1/search_screenshot.JPG|dialog Joption]
    you will need to add ItemListener to the JRadioButtons

  • Validators - Event Listening

    I need to change the trigger event for a validator so it
    checks as soon as information is entered in a text area.
    1. Currently I have to click on something else before the
    Validator checks to see if anything is in the text area. I would
    like it to check as soon as data is entered into the text area.
    (like somehow linking it to the dataChange event of the text Area)
    NB The Validator is attached to a custom component that is
    dynamically created when the application is run.
    2. I have a group of labels which change color based on the
    validator when it is clicked on. Likewise each label only updates
    when I click on another label and then click back on the original
    label. I am somewhat new to Flex 2 so I am a bit confused about how
    event listening works and how events can be handled.
    My code follows below:
    // Event listener for the valid and invalid events - in
    script
    public function
    handleValid(eventObj:ValidationResultEvent):Boolean
    if(eventObj.type==ValidationResultEvent.VALID){
    isValid = true;
    else
    isValid = false;
    return isValid;
    // Constructor
    <mx:Validator id="reqValid" required="true"
    source="{feedbackText}" property="text"
    valid="handleValid(event)" invalid="handleValid(event)"/>

    I think you should use a midware, like CORBA. If your applications are simulations, use pRTI and study some High Level Architecture before. Then your applications can communicate through the midware. This is for programs written on different platforms. Will take you some time..

  • Creating custom event listener ?

    Hello,
    Is there anyone that have a link to a tutorial or have some information on what is needed to be able to create a custom event listener on a component ?
    I am creating an interactive JSF chart library (JSFlot) and I would like to have events such as ChartDraggedEvent and ChartClickedEvent. I can create the events fine (and I can even queue them fine throught the standard action and actionListener interfaces), but I would like for the component to have attributes like chartDraggedListener and chartClickedListener, so that I can fire off the appropriate event to the appropriate listener.
    Any help would be very much appreciated!

    Well, that is what I am doing. The Renderer:
    if (event != null && event.equalsIgnoreCase("drag")) {
                        String componentValue = request.getParameter("componentValue");
                        //Cut out logic irrelevant for this example
                        FlotChartDraggedEvent dragEvent = new FlotChartDraggedEvent(component, dragValue);
                        dragEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
                        dragEvent.queue();
                   } else if (event != null && event.equalsIgnoreCase("click")) {
                        //Cut out logic irrelevant for this example                    
                        FlotChartClickedEvent clickEvent = new FlotChartClickedEvent(component, clickedPoint, clickIndexInt, clickSeriesIndexInt, clickSeriesLabel);
                        clickEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
                        clickEvent.queue();
                   }The problem though, is that both of these events gets delivered to the actionListener attribute of my component. What I assume is missing is functionality to register a custom listener for each event, and some code in the Tag-class and TLD to supply these listeners, and its these issues that I am unsure how is done. I may be missing something very basic here though :)

  • Event Listener dispatcher giving an ClassCast Exception in C++ 3.6.1

    Hi,
    I have attached a Event listener to underlying NamedCache and when I update the cache entry I didn't get any alerts. But When I checked the
    coherence log I found following Exception available. But I'm not doing any sort of Casting as mentioned below.
    2012-01-17 11:12:55.793/0.320 Oracle Coherence for C++ RTC 3.6.1.0 <Info> (thread=main): Connected Socket to 169.52.37.237/169.52.37.237:9099
    2012-01-17 11:13:04.859/9.386 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): An exception occurred while dispatching the following event:
    coherence::component::util::RunnableCacheEvent: coherence::util::MapListenerSupport::FilterEvent{coherence::component::net::extend::RemoteNamedCache::BinaryCache[source=coherence::component::net::extend::RemoteNamedCache::BinaryCache@0x69f090c4] updated: key=Binary(length=19), old value=Binary(length=713), new value=Binary(length=713), filters=[NULL]}
    2012-01-17 11:13:04.860/9.387 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): The following exception was caught by the event dispatcher:
    2012-01-17 11:13:04.860/9.387 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): NULL
    coherence::lang::ClassCastException: attempt to cast from a "gce::coherence::CoherenceEventHandler" to a "coherence::util::MapListener" at void coherence::lang::coh_throw_class_cast(const std::type_info&, const std::type_info&)(ClassCastException.cpp:27)
    at coherence::lang::coh_throw_class_cast(std::type_info const&, std::type_info const&)
    at coherence::lang::TypedHandle<coherence::util::MapListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::util::MapListener>, coherence::lang::Object>(coherence::lang::TypedHandle<coherence::lang::Object> const&, bool)
    at coherence::lang::TypedHandle<coherence::util::MapListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::util::MapListener>, coherence::lang::Object>(coherence::lang::TypedHolder<coherence::lang::Object> const&, bool)
    at coherence::lang::TypedHandle<coherence::util::MapListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::util::MapListener>, coherence::lang::Object>(coherence::lang::MemberHolder<coherence::lang::Object> const&, bool)
    When I wrote a sample application It works without any problem. Only difference of above exception coming program is this c++ library is loaded true JNI and relevant event listener is added during a JNI method call. Please explain me why this exception is coming. I have attached the relevant code as well.
    CoherenceEventListener.hpp
    * File: CoherenceEventHandler.hpp
    * Author: srathna1
    * Created on 05 January 2012, 10:15
    #ifndef COHERENCEEVENTHANDLER_HPP
    #define     COHERENCEEVENTHANDLER_HPP
    #include "coherence/util/MapEvent.hpp"
    #include "coherence/util/MapListener.hpp"
    #include <iostream>
    //#include <map>
    #include "coherence/lang.ns"
    #include "mihelper.hpp"
    #include "MiCoherence.hpp"
    #include <string>
    #include "MICoherenceDataObject.hpp"
    using coherence::util::MapEvent;
    using coherence::util::MapListener;
    using namespace coherence::lang;
    * A MapListener implementation that prints each event as it receives
    * them.
    namespace gce {
    namespace coherence {
    class CoherenceEventHandler
    : public class_spec<CoherenceEventHandler,
    extends<Object>,
    implements<MapListener> > {
    friend class factory<CoherenceEventHandler>;
    public:
    CoherenceEventHandler(CMiCoherence * miCoh) : mi(miCoh), msgSeqNo(1) {
    virtual void entryInserted(MapEvent::View vEvent) {
    Object::View vKey = vEvent->getKey();
    String::View key = cast<String::View > (vKey);
    Object::View vValue = vEvent->getNewValue();
    char topic[100];
    strcpy(topic, key->getCString());
    Managed<gce::coherence::MICoherenceDataObject>::View pos = cast<Managed<gce::coherence::MICoherenceDataObject>::View > (vValue);
    std::cout << key << " = " << pos << std::endl;
    virtual void entryUpdated(MapEvent::View vEvent) {
    Object::View vKey = vEvent->getKey();
    String::View key = cast<String::View > (vKey);
    Object::View vValue = vEvent->getNewValue();
    char topic[100];
    strcpy(topic, key->getCString());
    Managed<gce::coherence::MICoherenceDataObject>::View pos = cast<Managed<gce::coherence::MICoherenceDataObject>::View > (vValue);
    std::cout << key << " = " << pos << std::endl;
    gce::coherence::MICoherenceDataObject msg = *pos;
    virtual void entryDeleted(MapEvent::View vEvent) {
    private:
    CMiCoherence * mi;
    int msgSeqNo;
    #endif     /* COHERENCEEVENTHANDLER_HPP */
    Event Registration code
    NamedCache::Handle miCoherenceCache = NULL;
    try {
    String::View cacheName = szConnect;
    miCoherenceCache = CacheFactory::getCache(cacheName);
    } catch (const std::exception& e) {
    LOGERR("initializing coherence middleware cache error: %s", e.what());
    return MI_ERR_BADSTATE;
    nConnectState = miCoherenceCache->getCacheService()->isRunning() == true ? 1 : 0;
    miCoherenceCache->addFilterListener(gce::coherence::CoherenceEventHandler::create(this));
    Please give me a clue why Cohrence Internal Event Dispatcher giving exception.....
    Thanks and regards,
    Sura

    Hi,
    Even when I try to to test the MemberListener while closing the Coherene Java Cache Cluster I can see following Exception. Something similar to EventListener.
    2012-01-18 20:06:18.868/44.346 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): The following exception was caught by the event dispatcher:
    2012-01-18 20:06:18.868/44.346 Oracle Coherence for C++ RTC 3.6.1.0 <Error> (thread=ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher): NULL
    coherence::lang::ClassCastException: attempt to cast from a "gce::coherence::CoherenceMemberListener" to a "coherence::net::MemberListener"
    at void coherence::lang::coh_throw_class_cast(const std::type_info&, const std::type_info&)(ClassCastException.cpp:27)
    at coherence::lang::coh_throw_class_cast(std::type_info const&, std::type_info const&)
    at coherence::lang::TypedHandle<coherence::net::MemberListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::net::MemberListener>, coherence::lang::Object>(coherence::lang::TypedHandle<coherence::lang::Object> const&, bool)
    at coherence::lang::TypedHandle<coherence::net::MemberListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::net::MemberListener>, coherence::lang::Object>(coherence::lang::TypedHolder<coherence::lang::Object> const&, bool)
    at coherence::lang::TypedHandle<coherence::net::MemberListener> coherence::lang::cast<coherence::lang::TypedHandle<coherence::net::MemberListener>, coherence::lang::Object>(coherence::lang::MemberHolder<coherence::lang::Object> const&, bool)
    at coherence::net::MemberEvent::dispatch(coherence::lang::TypedHandle<coherence::util::Listeners const>) const
    at coherence::component::util::ListenerCallback::translateMemberEvent(coherence::lang::TypedHandle<coherence::net::MemberEvent const>)
    at coherence::component::util::ListenerCallback::memberLeaving(coherence::lang::TypedHandle<coherence::net::MemberEvent const>)
    at coherence::net::MemberEvent::dispatch(coherence::lang::TypedHandle<coherence::util::Listeners const>) const
    at coherence::component::net::extend::RemoteService::dispatchMemberEvent(coherence::net::MemberEvent::Id)
    at coherence::component::net::extend::RemoteService::connectionError(coherence::lang::TypedHandle<coherence::net::messaging::ConnectionEvent const>)
    at coherence::component::net::extend::RemoteCacheService::connectionError(coherence::lang::TypedHandle<coherence::net::messaging::ConnectionEvent const>)
    at coherence::net::messaging::ConnectionEvent::dispatch(coherence::lang::TypedHandle<coherence::util::Listeners const>) const
    at coherence::component::util::Peer::DispatchEvent::run()
    at coherence::component::util::Service::EventDispatcher::onNotify()
    at coherence::component::util::Daemon::run()
    at coherence::lang::Thread::run()
    on thread "ExtendTcpCacheService:coherence::component::util::TcpInitiator:coherence::component::util::Service::EventDispatcher"
    Seems to be like loading with JNI will giving some exceptions.
    Please help me on this...
    Thanks and regards,
    Sura

  • Passing a string as the name of a Mouse Event Listener function?

    Hello,
    I am trying to essentially pass a string as a function name into an event listener, but I am not sure how to approach this.  Is there a way to convert a string into a function?  I am not sure how to word my question, so I apologize.
    Here is some code I have for me to show you what I am doing.
    package{
         //some import statements
         public class changes extends MovieClip{
              var functionName:String
              var aBox:Sprite;
              public function changes(){
                       functionName = "testThis";
                       createButtonBox(16, 16, 32, 32,  functionName);
              public function createButtonBox(anX:Number, aY:Number, aWidth:Number, aHeight:Number, aFunction:String){
                   aBox = new Sprite();
                   //Some drawing box code
                   aBox.addEventListener(MouseEvent.CLICK,[aFunction]()?)
                   addChild(aBox)
              public function aFunction(event:MouseEvent){
                   trace("test");
    Am I on the right track or is this not possible?
    Anyhow, thank you in advance.

    I guess I misworded my question.  Essentially what I am trying to do is create buttons that have functions called to from an event listener, referenced by a string like this:
    public class Document{
         var functionName:String;
         public function Document(){
                 createAButton("Test Button A", 32, 32, "testThis");
                 createAButton("Test Button B", 64, 64, "testThis2");
         public function createAButton(textOnButton:String, anX:Number, aY:Number, functionToCallTo:String){
                   var aButton:Sprite = new Sprite();
                   //draw the button
                   //set a textfieldup for the button to have
                  aButton.addEventListener(MouseEvent.CLICK, functionToCallTo)
         public function testThis(event:MouseEvent){
                   trace("testA");
         public function testThis2(event:MouseEvent){
                    trace("testB");
    Unfortunately aButton.addEventListener(MouseEvent.CLICK, functionToCallTo) gives me a coercian error, which is a given.
    aButton.addEventListener(MouseEvent.CLICK, [functionToCallTo]()) gives me TypeError: Error #1006: value is not a function.
    I mean I could create a bunch of if statements, but for the number of functions I plan to call to, like about 25 or so, that is pretty tedious.

  • Error trying to register a Java event listener

    I'm trying to register a java event listener in 11g with the following piece of code:
    DECLARE
    b BOOLEAN := FALSE;
    BEGIN
    b := DBMS_XDB.createFolder('/public/resconfig');
    b := DBMS_XDB.createResource(
    '/public/resconfig/hr_event.xml',
    '<ResConfig xmlns="http://xmlns.oracle.com/xdb/XDBResConfig.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.oracle.com/xdb/XDBResConfig.xsd
    http://xmlns.oracle.com/xdb/XDBResConfig.xsd">
    <event-listeners default-language="Java">
    <listener>
    <description>Category application</description>
    <schema>HR</schema>
    <source>xdbproject.OpenOfficeEventHandler</source>
    <language>Java</language>
    <events>
    <Post-Create/>
    <Post-LinkIn/>
    </events>
    </listener>
    </event-listeners>
    <defaultChildConfig>
    <configuration>
    <path>/public/resconfig/hr_event.xml</path>
    </configuration>
    </defaultChildConfig>
    </ResConfig>');
    END;
    This results in the following error message
    ORA-31146: Ugyldig lytterkilde HR.xdbproject.OpenOfficeEventHandler
    ORA-06512: ved "XDB.DBMS_XDB", line 174
    ORA-06512: ved line 5
    which translates to Invalid listener source.
    My class is loaded in the HR schema, and implements the XDBRepositoryEventListener
    Does anybody have a suggestion to what I'm doing wrong, or how I can find out what makes my class invalid as a listener source?

    Check if it validates against the restrictions set in the XML Schema (Appendix A, Oracle XMLDB Developers Guide):
    XDBResConfig.xsd: XML Schema for Resource Configuration
    This section presents the Oracle XML DB supplied XML schema used to configure repository resources. This is accessible in Oracle XML DB Repository at path /sys/schemas/PUBLIC/xmlns.oracle.com/xdb/XDBResConfig.xsd.
    XDBResConfig.xsd
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://xmlns.oracle.com/xdb/XDBResConfig.xsd"
            xmlns:xdb="http://xmlns.oracle.com/xdb"
            xmlns:rescfg="http://xmlns.oracle.com/xdb/XDBResConfig.xsd"
            elementFormDefault="qualified" xdb:schemaOwner="XDB" version="1.0" >
      <annotation>
        <documentation>
          This XML schema declares the schema of an XDB resource configuration,
          which includes default ACL, event listeners and user configuration.
          It lists all XDB repository events that will be supported.
          Future extension can be added to support user-defined events and
          XML events.
        </documentation>
      </annotation>
      <simpleType name="language">
        <restriction base="string">
          <enumeration value="Java" />
          <enumeration value="C" />
          <enumeration value="PL/SQL" />
        </restriction>
      </simpleType>
      <complexType name = "existsNode">
         <all>
           <element name="XPath" type = "string" minOccurs="1" maxOccurs="1" />
           <element name="namespace" type = "string" minOccurs="0" maxOccurs="1" />
         </all>
      </complexType>
      <!-- listener pre-condition element  -->
      <complexType name = "condition">
         <all>
           <element name="existsNode" type = "rescfg:existsNode" minOccurs="0" maxOccurs="1" />
         </all>
      </complexType>
      <complexType name = "events">
        <all>
          <element name="Render" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-Create" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-Create" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-Delete" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-Delete" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-Update" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-Update" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-Lock" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-Lock" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-Unlock" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-Unlock" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-LinkIn" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-LinkIn" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-LinkTo" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-LinkTo" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-UnlinkIn" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-UnlinkIn" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-UnlinkFrom" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-UnlinkFrom" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-CheckIn" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-CheckIn" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-CheckOut" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-CheckOut" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-UncheckOut" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-UncheckOut" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-VersionControl" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-VersionControl" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-Open" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-Open" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Pre-InconsistentUpdate" type="string" minOccurs="0" maxOccurs="1"/>
          <element name="Post-InconsistentUpdate" type="string" minOccurs="0" maxOccurs="1"/>
        </all>
      </complexType>
      <!-- event listener element  -->
      <complexType name = "event-listener">
        <all>
          <element name="description" type = "string" minOccurs="0" maxOccurs="1"/>
          <element name="schema" type = "string" minOccurs="0" maxOccurs="1"/>
          <element name="source" type = "string" minOccurs="1" maxOccurs="1"/>
          <element name="language" type = "rescfg:language" minOccurs="0" maxOccurs="1"/>
          <element name="pre-condition" type = "rescfg:condition" minOccurs="0" maxOccurs="1"/>
          <element name="events" type = "rescfg:events" minOccurs="0" maxOccurs="1"/>
        </all>
      </complexType>
      <complexType name="event-listeners">
        <sequence>
          <element name="listener" type = "rescfg:event-listener" minOccurs="1" maxOccurs="unbounded"/>
        </sequence>
        <attribute name = "default-schema" type = "string" xdb:baseProp="true" use="optional"/>
        <attribute name = "default-language" type = "rescfg:language" xdb:baseProp="true"
                   use="optional"/>
        <attribute name = "set-invoker" type = "boolean" xdb:baseProp="true" default="false" />
      </complexType>
      <complexType name="defaultPath">
        <all>
          <element name="pre-condition" type = "rescfg:condition" minOccurs="0" maxOccurs="1"/>
          <element name="path" type="string" minOccurs="0" maxOccurs="1" xdb:transient="generated"/>
          <element name = "resolvedpath" type = "string" minOccurs="1" maxOccurs="1"
                   xdb:baseProp="true" xdb:hidden="true"/>
          <element name = "oid" type = "hexBinary" minOccurs="1" maxOccurs="1" xdb:baseProp="true"
                   xdb:hidden="true"/>
        </all>
      </complexType>
      <complexType name="defaultACL">
        <sequence>
          <element name="ACL" type="rescfg:defaultPath" minOccurs="1" maxOccurs="unbounded"/>
        </sequence>
      </complexType>
      <complexType name = "defaultConfig">
        <sequence>
          <element name="configuration" type="rescfg:defaultPath" minOccurs="1" maxOccurs="unbounded"/>
        </sequence>
      </complexType>
      <simpleType name="link-type">
        <restriction base="string">
          <enumeration value="None"/>
          <enumeration value="Hard"/>
          <enumeration value="Weak"/>
          <enumeration value="Symbolic"/>
        </restriction>
      </simpleType>
      <simpleType name="path-format">
        <restriction base="string">
          <enumeration value="OID"/>
          <enumeration value="Named"/>
        </restriction>
      </simpleType>
      <simpleType name="link-metadata">
        <restriction base="string">
          <enumeration value="None"/>
          <enumeration value="Attributes"/>
          <enumeration value="All"/>
        </restriction>
      </simpleType>
      <simpleType name="unresolved-link">
        <restriction base="string">
          <enumeration value="Error"/>
          <enumeration value="SymLink"/>
          <enumeration value="Skip"/>
        </restriction>
      </simpleType>
      <simpleType name="conflict-rule">
        <restriction base="string">
          <enumeration value="Error"/>
          <enumeration value="Overwrite"/>
          <enumeration value="Syspath"/>
        </restriction>
      </simpleType>
       <simpleType name="section-type">
         <restriction base="string">
           <enumeration value="None"/>
           <enumeration value="Fragment"/>
           <enumeration value="Document"/>
         </restriction>
       </simpleType>
      <!-- XLinkConfig complex type -->
        <complexType name="xlink-config">
         <sequence>
          <element name="LinkType" type = "rescfg:link-type"/>
          <element name="PathFormat" type = "rescfg:path-format" minOccurs="0" default="OID"/>
          <element name="LinkMetadata" type = "rescfg:link-metadata" minOccurs="0" default="None"/>
         </sequence>
         <attribute name="UnresolvedLink" type = "rescfg:unresolved-link" default="Error"/>
        </complexType>
      <!-- XIncludeConfig element -->
        <complexType name="xinclude-config">
         <sequence>
          <element name="LinkType" type = "rescfg:link-type"/>
          <element name="PathFormat" type = "rescfg:path-format" minOccurs="0" default="OID"/>
          <element name="ConflictRule" type = "rescfg:conflict-rule" minOccurs="0" default="Error"/>
         </sequence>
         <attribute name="UnresolvedLink" type = "rescfg:unresolved-link" default="Error"/>
        </complexType>
      <!-- SectionConfig element -->
      <complexType name="section-config">
       <sequence>   
        <element name="Section" maxOccurs="unbounded">
          <complexType>
            <sequence>
             <element name="sectionPath" type="string"/>
             <element name="documentPath" type="string" minOccurs="0"/>
             <element name="namespace" type="string" minOccurs="0"/>
            </sequence>
            <attribute name="type" type="rescfg:section-type" default="None"/>
          </complexType>
        </element>
       </sequence>
      </complexType>
      <!-- ContentFormat element -->
      <simpleType name="content-format" >
        <restriction base="string">
          <enumeration value="text"/>
          <enumeration value="binary"/>
        </restriction>
       </simpleType>
      <!-- resource configuration element  -->
      <complexType name = "ResConfig">
        <all>
          <element name="defaultChildConfig" type="rescfg:defaultConfig" minOccurs="0"  maxOccurs="1"/>
          <element name="defaultChildACL" type="rescfg:defaultACL" minOccurs="0" maxOccurs="1"/>
          <element name="event-listeners" type = "rescfg:event-listeners" minOccurs="0" maxOccurs="1"/>
          <element name="XLinkConfig" type="rescfg:xlink-config" minOccurs="0" maxOccurs="1"/>
          <element name="XIncludeConfig" type="rescfg:xinclude-config" minOccurs="0" maxOccurs="1"/>
          <element name="SectionConfig" type="rescfg:section-config" minOccurs="0" maxOccurs="1"/>
          <element name="ContentFormat" type="rescfg:content-format" minOccurs="0" maxOccurs="1"/>
          <!-- application data -->
          <element name="applicationData" minOccurs="0" maxOccurs="1" >
             <complexType>
               <sequence>
                 <any namespace="##other" maxOccurs="unbounded" processContents="lax"/>
               </sequence>
             </complexType>
         </element>
        </all>
        <attribute name = "enable" type = "boolean" xdb:baseProp="true" default="true" />
        <attribute name = "copy-on-inconsistent-update" type = "boolean" use="optional" />
      </complexType>
      <element name="ResConfig" type="rescfg:ResConfig" xdb:defaultTable = "XDB$RESCONFIG" />
    </schema>
    acl.xsd: XML Schema for ACLs
    This section presents the Oracle Database supplied XML schema used to represent access control lists (ACLs).
    acl.xsd
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://xmlns.oracle.com/xdb/acl.xsd" version="1.0"
            xmlns:xdb="http://xmlns.oracle.com/xdb"
            xmlns:xdbacl="http://xmlns.oracle.com/xdb/acl.xsd"
            elementFormDefault="qualified">
       <annotation>
         <documentation>
            This XML schema describes the structure of XDB ACL documents.
            Note : The "systemPrivileges" element below lists all supported
              system privileges and their aggregations.
              See dav.xsd for description of DAV privileges
            Note : The elements and attributes marked "hidden" are for
              internal use only.
         </documentation>
         <appinfo>
           <xdb:systemPrivileges>
            <xdbacl:all>
              <xdbacl:read-properties/>
              <xdbacl:read-contents/>
              <xdbacl:read-acl/>
              <xdbacl:update/>
              <xdbacl:link/>
              <xdbacl:unlink/>
              <xdbacl:unlink-from/>
              <xdbacl:write-acl-ref/>
              <xdbacl:update-acl/>
              <xdbacl:link-to/>
              <xdbacl:resolve/>
              <xdbacl:write-config/>
            </xdbacl:all>
           </xdb:systemPrivileges>
         </appinfo>
       </annotation>
      <!-- privilegeNameType (this is an emptycontent type) -->
      <complexType name = "privilegeNameType"/>
      <!-- privilegeName element
           All system and user privileges are in the substitutionGroup
           of this element.
        -->
      <element name = "privilegeName" type="xdbacl:privilegeNameType"
               xdb:defaultTable=""/>
      <!-- all system privileges in the XDB ACL namespace -->
      <element name = "read-properties" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "read-contents" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "read-acl" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "update" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "link" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "unlink" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "unlink-from" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "write-acl-ref" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "update-acl" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "link-to" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "resolve" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <element name = "all" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
      <!-- privilege element -->
      <element name = "privilege" xdb:defaultTable="">
        <complexType>
          <sequence>
            <any maxOccurs="unbounded" processContents="lax"/>
          </sequence>
        </complexType>
      </element>
      <!-- ace element -->
      <element name = "ace" xdb:defaultTable="">
        <complexType>
          <sequence>
            <element name = "grant" type = "boolean"/>
            <choice>
              <element name="invert" xdb:transient="generated">
                <complexType>
                  <sequence>
                    <element name="principal" type="string"
                             xdb:transient="generated" />
                  </sequence>
                </complexType>
              </element>
              <element name="principal" type="string" xdb:transient="generated"/>
            </choice>
            <element ref="xdbacl:privilege" minOccurs="1"/>
            <!-- "any" contain all app info for an ACE e.g.reason for creation -->
            <any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
            <!-- HIDDEN ELEMENTS -->
            <choice minOccurs="0">
              <element name = "principalID" type = "hexBinary"
                       xdb:baseProp="true" xdb:hidden="true"/>
              <element name = "principalString" type = "string"
                       xdb:baseProp="true" xdb:hidden="true"/>
            </choice>
            <element name = "flags" type = "unsignedInt" minOccurs="0"
                     xdb:baseProp="true" xdb:hidden="true"/>
          </sequence>
          <attribute name = "collection" type = "boolean"
                     xdb:transient="generated" use="optional"/>
          <attribute name = "principalFormat"
                     xdb:transient="generated" use="optional">
            <simpleType>
              <restriction base="string">
                <enumeration value="ShortName"/>
                <enumeration value="DistinguishedName"/>
                <enumeration value="GUID"/>
                <enumeration value="XSName"/>
              </restriction>   
            </simpleType>
          </attribute>
          <attribute name = "start_date" type = "dateTime" use = "optional"/>
          <attribute name = "end_date" type = "dateTime" use = "optional"/>    
        </complexType>
      </element>
      <!-- acl element -->
      <complexType name="inheritanceType">
        <attribute name="type" type="string" use="required"/>
        <attribute name="href" type="string" use="required"/>
      </complexType>
      <complexType name="aclType">
       <sequence>
        <element name = "schemaURL" type = "string" minOccurs="0"
                 xdb:transient="generated"/>
        <element name = "elementName" type = "string" minOccurs="0"
                 xdb:transient="generated"/>
        <element name = "security-class" type = "QName" minOccurs="0"/>
        <choice minOccurs="0">
          <element name="extends-from" type="xdbacl:inheritanceType"/>
          <element name="constrained-with" type="xdbacl:inheritanceType"/>
        </choice>
        <element ref = "xdbacl:ace" minOccurs="1" maxOccurs = "unbounded"/>
        <!-- this "any" contains all application specific info for an ACL,
             e.g., reason for creation  -->
        <any minOccurs="0" maxOccurs="unbounded" namespace="##other" />
        <!-- HIDDEN ELEMENTS -->
        <element name = "schemaOID" type = "hexBinary" minOccurs="0"
                 xdb:baseProp="true" xdb:hidden="true"/>
        <element name = "elementNum" type = "unsignedInt" minOccurs="0"
                 xdb:baseProp="true" xdb:hidden="true"/>
       </sequence>
       <attribute name = "shared" type = "boolean" default="true"/>
       <attribute name = "description" type = "string"/>
      </complexType>
      <complexType name="rule-based-acl">
        <complexContent>
          <extension base="xdbacl:aclType">
            <sequence>
              <element name = "param" minOccurs="0" maxOccurs="unbounded">
                <complexType>
                  <simpleContent>
                    <extension base="string">
                      <attribute name = "name" type = "string" use = "required"/>
                    </extension>
                  </simpleContent>
                </complexType>
              </element>
            </sequence>
          </extension>
        </complexContent>
      </complexType>
      <element name = "acl" type="xdbacl:aclType" xdb:defaultTable = "XDB$ACL"/>
      <element name = "write-config" type="xdbacl:privilegeNameType"
               substitutionGroup="xdbacl:privilegeName" xdb:defaultTable=""/>
    </schema>Message was edited by:
    Marco Gralike

  • Stage event listener in actionscript won't wait in captivate

    I have an SWF file that is done in AS3. It works fine both in Flash and published as an SWF.
    Problem shows up when I bring it into captivate.
    I need the the event listener attached to the stage because it's an if/else statement that has the student click either one specific button or get an error message if there's a click ANYWHERE else. The problem is "stage" is not restricted to the area of the flash animation. It uses the whole screen in captivate to mean stage. As soon as captivate displays the animation, it acts as if moving into the slide was a click and shows the error message before the user has done anything. I suspect this has something to do with Captivates using its stage which becomes the parent stage but I'm not sure how to fix it. Any ideas?
    Please don't ask me to build the interactives directly in Captivate 5. We tried that and after the 4th one in the module, feedback captions lag so long they are completely useless for learning. Yes, I broke out the module into smaller sections and tried publishing as chapters. It made no difference. Any interactive after the 4th one, when built in captivate, would not change the response rate of feedback captions even when it was a slide alone in its own swf file.

    well I have a sort-of-work-around if anyone else is running into this.
    I extended the timeline by about 10 frames in my Flash file and placed the actions keyframe at the 10th with a stop(); in the first line.
    When I brought the published swf into captivate 5 I put it on the stage alone with another text button for moving to the next slide so the slide will pause until the learner wishes to move on. I made the timeline about 5 seconds long and placed the button in the center of its layer with the swf above going the duration of the slide. Placing the pauser in the center allows the movie to display fully and the interactions in the animation now wait patiently for the user to do something. I'm sure there a code based solution, but there's only so much time in the world.

  • Can't remove event listener from Image

    I'm clearly missing something and would appreciate some help.  I'm trying to run an event handler when an Image completes loading,  then remove the handler so that it won't  run again should the image be reloaded later.
    The problem that I'm having is that the event handler simply wont' go away, despite calling removeEventListener on the Image object.
    The following example demonstrates the problem (the example doesn't actually do anything useful...it's just the shortest example to demonstrate the problem).  (To run the  app, you'll have to provide any ol' JPEG file named "myImage.jpg" in the "src" directory of your project).
    What I expect to happen is :
         1) on startup, the image loads and loadComplete() runs.
         2)  loadComplete removes the event Listener so that subsequent re-loads won't re-fire the handler.  I only want the handler to  run once.
         3) "loadComplete" shoudl  be displayed in the Debug console.
         4) A button click should display only "Changing  Image" in the Debug console
    What I get instead is that the loadComplete handler isn't  removed, and every  time I click the button, loadComplete runs when the image is re-loaded   (i.e., every button click results in both "Change Image" AND "loadComplete"  being displayed in the Debug console).
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Image width="655" height="181" source="myImage.jpg" id="myImage" autoLoad="true" scaleContent="true" complete="loadComplete()" x="100" y="100"/>
        <mx:Button x="100" y="341" label="Button" click="click(event)"/>
        <mx:Script>
            <![CDATA[
                private function loadComplete():void
                    trace ("loadComplete");
                    myImage.removeEventListener("complete", loadComplete);
                private function click(evt:Event):void
                    trace ("Changing Image");
                    myImage.load("myImage.jpg");    //  Reload same image; it's just an example
            ]]>
        </mx:Script>
    </mx:Application>

    Hi,
    You can remove only event listeners that you added with the addEventListener() method in an ActionScript block. You cannot remove an event listener  that was defined in the MXML tag, even if it was registered using a call  to the addEventListener()method that was made inside a tag attribute.
    Check this page for reference.
    http://livedocs.adobe.com/flex/3/html/help.html?content=events_05.html
    You can modify the code a bit a get it working
    <mx:Image width="655" height="181" id="myImage" scaleContent="true"
              x="100" y="100"
              creationComplete="myImage_creationCompleteHandler(event)"/>
    private function myImage_creationCompleteHandler(event:FlexEvent):void
         myImage.addEventListener("complete",myImage_completeHandler);
         myImage.load("myImage.jpg");
    private function myImage_completeHandler(event:Event):void
         myImage.removeEventListener("complete",myImage_completeHandler);

Maybe you are looking for

  • Internal table in shared memory

    I'm using an internal table in a shared memory area. Depending on the existance of rows i would like to modify these rows or appending new rows. So i need read and write access. I tried to use attach_for_write( ) but after that i cannot read the tabl

  • EJB question: How to use abstract class in writing a session bean?

    I had written an abstract class which implements the session bean as follow: public abstract class LoggingSessionBean implements SessionBean { protected SessionContext ctx; protected abstract Object editRecord(Object obj) throws Exception; public Log

  • PHP form handler

    Hi, I've found a PHP form handler in one of the forums to process my feedback page. All works well but one thing I can't work out is when a visitor to the site fills in the info and clicks the submit button, that comes back to my mail box as expected

  • Fill the screen

    is there anyway to get a dvd played in itunes to fill the screen ? Not full screen , the movie filling the screen it has borders left and right even if a widescreen movie Thank you

  • 2Wire Router Issues - How to Turn off Security

    There appears to be an ongoing issue with MacBook wireless and the 2Wire routers (via AT&T/SBC). My wireless was working fine until I downloaded the recent Apple updates. I saw one fix for this posted here: http://discussions.apple.com/thread.jspa?th