Problems with events in flex

Hi there. I'm a AS2 and Flash CS3 guy. I started to learn AS3 and transfer to Flex 3. But I got a problem w/ Events in AS3. I'm adding a canvas component to the stage. On that canvas, I added 3 different events: mouse down, mouse move, and mouse up. When mouse move is fired, there is no way for me to get mouse up event fired, and viceversa, when mouse up is fired, there is no way to get the mouse move event fired. Is there any one to help this newbie with this particular problem? Any help will be very appreciated.
Code:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:canvas id="myCanvas" x="50" y="50" width="500" height="500" click="event_1();" mouseMove="event_2();" mouseUp="event_3();">
</mx:Canvas>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.events.*;
public function event_1():void
{ Alert.show("First event fired"); }
public function event_2():void
{ Alert.show("Second event fired"); }
public function event_3():void
{ Alert.show("third event fired); }
</mx:Script>
</mx:Application>

Hi Greg. Thank you for your replay. The question is I didnt want to bother you with the complete code and post it with the minimal expression. But here I give you the full code w/corresponding package. What I'm trying to do is drawing a line over an empty canvas (I got it very easily in Flash AS2)
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="addChild(p1)">
<mx:Canvas id="wrapper" x="10" y="10" width="600" height="600">
  <mx:Canvas x="50" y="50" width="500" height="500" id="imageView" backgroundColor="#F8F3F3" click="startDraw();" mouseMove="drawLine();" mouseUp="noDrawLine();" >
  </mx:Canvas>
</mx:Canvas>
<mx:Button x="263" y="618" label="Draw Line" click="prepToDraw();"/>
<mx:Script>
<![CDATA[
  import com.myDomain.Lines.Main;
   import mx.graphics.*;
   import mx.binding.utils.BindingUtils;
   import flash.events.IOErrorEvent;
   import flash.events.Event;
   import flash.display.*;
   import mx.controls.Alert;
   import com.myDomain.Lines.Main;
   public var p1:Main = new Main();
   public var pre:Number = 0;
   public function prepToDraw():void
    pre = 1;
   public function startDraw():void
    if(pre == 1)
    p1.graphics.clear();
    var newColor:int = 0xFF00FF;
    var iniX:Number = mouseX;
    var iniY:Number = mouseY;
    var lineWidth:Number = 10;
    p1.graphics.lineStyle(lineWidth, newColor);
    p1.graphics.moveTo(iniX, iniY);
   public function drawLine():void
    if(pre == 1)
     p1.graphics.lineTo(mouseX, mouseY);
   public function noDrawLine():void
    if(pre == 1)
     Alert.show("noLine");
]]>
</mx:Script>
</mx:Application>
The package:
package com.myDomain.Lines
import flash.display.Shape;
import flash.display.Stage;
import flash.events.MouseEvent;
import mx.core.UIComponent;
public class Main extends UIComponent
  public function Main()
   super();
  public var p1:Shape = new Shape();
If you go apply the code, you will see: 1) The first event to fire is mouseUp, then you eill start drawing the line, but again, you will not be able to stop this event with mouseUp. If you can help me, I will be very appreciated. Thanks. 

Similar Messages

  • Problem with event handling

    Hello all,
    I have a problem with event handling. I have two buttons in my GUI application with the same name.They are instance variables of two different objects of the same class and are put together in the one GUI.And their actionlisteners are registered with the same GUI. How can I differentiate between these two buttons?
    To be more eloborate here is a basic definition of my classes
    class SystemPanel{
             SystemPanel(FTP ftp){ app = ftp};
             FTP app;
             private JButton b = new JButton("ChgDir");
            b.addActionListener(app);
    class FTP extends JFrame implements ActionListener{
               SystemPanel rem = new SystemPanel(this);
               SystemPanel loc = new SystemPanel(this);
               FTP(){
                       add(rem);
                       add(loc);
                       pack();
                       show();
           void actionPerformed(ActionEvent evt){
            /*HOW WILL I BE ABLE TO KNOW WHICH BUTTON WAS PRESSED AS THEY
               BOTH HAVE SAME ID AND getSouce() ?
               In this case..it if was from rem or loc ?
    }  It would be really helpful if anyone could help me in this regard..
    Thanks
    Hari Vigensh

    Hi levi,
    Thankx..
    I solved the problem ..using same concept but in a different way..
    One thing i wanted to make clear is that the two buttons are in the SAME CLASS and i am forming 2 different objects of the SAME class and then putting them in a GUI.THERE IS NO b and C. there is just two instances of b which belong to the SAME CLASS..
    So the code
    private JButton b = new JButton("ChgDir");
    b.setActionCommand ("1");
    wont work as both the instances would have the label "ChgDir" and have setActionCommand set to 1!!!!
    Actually I have an array of buttons..So I solved the prob by writting a function caled setActionCmdRemote that would just set the action commands of one object of the class differently ..here is the code
    public void setActionCommandsRemote()
         for(int i = 0 ; i <cmdButtons.length ; i++)
         cmdButtons.setActionCommand((cmdButtons[i].getText())+"Rem");
    This just adds "rem" to the existing Actioncommand and i check it as folows in my actionperformed method
         if(button.getActionCommand().equals("DeleteRem") )          
                        deleteFileRemote();
          else if(button.getActionCommand().equals("Delete") )
                     deleteFileLocal();Anyway thanx a milion for your help..this was my first posting and I was glad to get a prompt reply!!!

  • Problems with event import on iMovie 10.0.3

    My complete movie libraries works fine with iMovie 9.0.9. There are no other malfunctions. The filessystem is clean.
    After upgrading to iMovie 10.0.3 the initial startup event and project update process fails on serveral older events and I have problems to import this events folders.
    Why does V. 10.0.3 has problems with some older events ?  What to do to get this files properly ?
    Thanks in advance for any help.
    Alexander

    when i try to move them together this happens..?

  • EEM Applet Problem With: event syslog pattern ".*" priority 2

    I went to create a EEM applet that would be invoked whenever any syslog message of priority 0-2 was invoked. I figured  the following event statement would work
           event syslog pattern ".*" priority 2
    I never really used the priority optional argument before but thought I understood from the docs that messages at or numerically lower than the specified level are matched.
    Well it doesn't seem to work as documented.  Seems to me that only messages at the specified level are beng matched and not messages numerically lower than the specified level.
    Anyway I did what I wanted differently but wanted to post this in case this is a bug in the syslog ed.

    Actually, it's a problem with the documentation.  The priority option only matches the specified severity.  What you could do is adjust pattern to do this:
    event syslog pattern "*-[012]-"

  • Problem with Events Manager: 'slct'

    I set up an Events Manager item to run a script whenever the event "Selection" ( 'slct' ) is activated. The script works beautifully and I'm having no problem with the script itself. I am, however, having problems with what happens after the script finishes. I have this problem even if I completely comment out the script or delete everything inside the script file and leave it blank. The purpose of the script is to automate things when I select specific layers. That works and the script has some checks to prevent anything from happening unless one of those specified layers is selected.
    The problem is, when I select a tool using the keyboard shortcuts, it will revert back to the previous tool upon the next keypress. It basically acts as if I am using toggle mode for that tool by holding down the key for that tool.
    I wiped out my preferences but that did not solve the problem. It makes no difference how my keyboard shortcuts are mapped...either default or user defined. So for an example, here is how some of my keys are mapped:
    B-Paintbrush tool
    S-Brush Size Increase
    So if I'm using the Clone Stamp tool and want to switch to the Paintbrush tool, I will press the "B" key. The tool switches as it's supposed to. If I need to change the size or hardness of the brush, I press one of the corresponding keys...let's say "S" to increase size. When I press "S" nothing will happen until I release that key. Once I do release it, the tool switches back to the Clone Stamp tool. You can get this same effect yourself if you hold down the key of the tool you are switching to (use the toggle mode) and then try to change size/hardness using the keyboard shortcut for that function while still holding that tool's key down.
    If I select the tool from the Tools Palette, I do not have this problem. If the tool is selected from within my script, I do not have this problem. The only time I have this problem is when using the keyboard shortcuts to select the tool.
    Keep in mind that I have tried this with the script code completely bypassed/erased so no script code actually exedutes. When I turn of the Events Manager or remove the 'slct' item from Events Manager, I do not have this problem at all. If I hold the <SHIFT> key down while selecting the tool, I do not have this problem (this is the same as if you were to hold down the <SHIFT>+<tool key> and press the key to change size/hardness).
    To me, it seems as though if there is a 'slct' event item in Events Manager and the keyboard is used to select a tool, Photoshop treats it as if that key is being held down (toggled) until another key is pressed (or even the same key).
    If anyone knows how to get around this problem, I would greatly appreciate it. Thank you.

    I'm having the same problem where a keystroke (like changing size "[ or "]") will revert to a previous tool rather than change size. Particularly annoying when you left your previously selected eraser slightly larger or smaller than your brush size and don't realize it till you've erased.
    So far, from reading across quite a number of forums, it seems the event listener istelf causing the issue
    At the moment I've just been thinking of "BB" as my shortcut instead of "B" so when it reverts it reverts back to the brush anyway.
    I'll come back if I find a real solution to this annoyance ;P
    CS5
    Wacom Intuos4
    Windows7

  • Problem with NetConnection in Flex using Flash Media Server

    I'm attempting to place a function on a NetConnection instance, and from everything I've read, I should be able to do that. Unfortunately, I'm getting an error when I compile. Here's my code, and my error is below the code, please let me know if you have a solution. Thanks for the help!
    import mx.rpc.events.ResultEvent
    import flash.net.NetConnection;
    import flash.net.navigateToURL;
    import flash.events.NetStatusEvent;
    import flash.events.StatusEvent;
    import flash.text.TextField;
    public var nc:NetConnection;
    // init is called on creationComplete
    public function init():void{
         nc = new NetConnection;
         nc.addEventListener(NetStatusEvent.NET_STATUS,onConnect);
         nc.connect("rtmp://localhost/FMSTesting");
    public function onConnect(event:NetStatusEvent):void{
            myText.text = nc.connected + event.info.code;
    //nc.myFunction is the function that will be called
    //from the main.asc server side file and this is where I get
    // the red x in Flex Builder 3 telling me there's an error
    nc.myFunction = function():void{
    error generated by the nc.myFunction line is:
    1119:Access of possibly undefined property myFunction through a reference with static type flash.net:NetConnection
    I tried putting the function declaration inside the onConnect handler and inside the init function, niether will remove the error.

    Can you write piece of code which you can trigger on click of button. I mean put a button on your swf file say name it "btnstopPublish" and click on it. Write below code snippet in click handler of the button and see if it works for you,
    btnstopPublish.addEventListener(MouseEvent.CLICK, stopPublish);
    function stopPublish_Play(eventObj:MouseEvent){
      ns.publish(false);
      ns.close();
    nsPlayer.play(false);
    nsPlayer.close();

  • Problem with event based scheduling

    Hi,
    We are having a ETL job running everynight, so i need to have daily
    report as soon as my ETL job is finished. For that we have run some
    script to create a event file after completion of ETL job. And by using
    this event file we have scheduled a report that runs after this event
    file is created. Now the problem is that the scheduled report is
    generated before the ETL job is finished. This seems to be working fine
    till last month, but this month we are facing this issue. my question
    is why the scheduler is triggered before the event file is created
    (event file is created after the completion of ETL job)
    Do anybody faced this iss
    FYI
    We are on BO XI 3.1 with no SP's and FP's and on windows environment.
    Do anybody faced this issue?Any advise is appreciated.
    Thanks,

    Hi,
    We are also on BO XI 3.1 with no SP's and FP's. We create Event files after the ETL jobs are completed. These files are used to create BO Events (File), which are used as scheduling criteria before the Reports can run. These files are deleted daily before the next files are created, something you might want check.
    Mike

  • Problem with Event Dates in iMovie '08

    Ok, here's the problem: I bought my Mac in August and moved over a lot of video clips shot with my camera into my iPhoto library. The metadata all displays correctly in iPhoto. However, when I look at the events in iMovie, they are all listed as Dec. 31, 1903.
    I did check the board and saw that there are others with this problem. I looked at the original files in the Finder and discovered that they are all missing a piece of data in the Get Info window: none of them have a "Created:" date. I'm thinking this is probably where the problem is coming from.
    The next question is whether anyone knows a way to fix it? I can't modify "Created:" from the Get Info window. My guess is that if I match the created date to the actual other metadata that should correct the problem and get the events to display correctly.
    It's just a guess, but I'd appreciate any help.

    I've answered my own problem. It has to do with the "created" date; most of these clips came over from my PC, so they all have the same date. By modifying that, you resolve the problem and it reorders the clips.

  • A problem with events

    Hi, first of all, sorry for my poor english :(
    My problem is:
    Have a page jsf with 2 SelectOneMenu and 1 commandButton like this
    <h:selectOneMenu binding="#{nuevoExpediente.cbObra}" valueChangeListener="# {bean.cbObra_OnChange}" onchange="submit()" >
    <f:selectItem itemLabel="Nuevo" itemValue="-1" itemDescription="Introducir nuevo poseedor" />
    <f:selectItems binding="#{bean.listobras}" />
    </h:selectOneMenu>
    <h:selectOneMenu binding="#{bean.cbCliente}" valueChangeListener="# {bean.cbCliente_OnChange}" onchange="submit()" >
    <f:selectItem itemLabel="Nuevo" itemValue="-1" itemDescription="Introducir nuevo poseedor" />
    <f:selectItems binding="#{bean.listclientes}" />
    </h:selectOneMenu>
    <h:commandButton id="cmdInsertar" value="Aceptar" action="#{bean.cmdInsertar_OnClick}" />
    Cool, now, when the pages FIRST time that i select one item on selectonemenu or click button, page fires ALL events. I think this it because when initialize SelectOneMenu with value="#....", an one event onChange wait on a queue and when any object of form make submit() all event on a queue are throws.
    this is:
    1º time when page load
    - click on a button
    - cbObra_OnChange fire ( on queue for give values? )
    - cbCliente_OnChange fire ( on queue for give values? )
    - cmbInsertar_OnClick fire ( yes, im clicked :D )
    how i can do this? i want that when click on the button first time, only event of button fires.
    thanks for all

    When you submit a form, the valueChangeListener will be invoked if the new value of the input component differs from the initial value of the input component. If the initial value of the dropdown was for example null and the default option of the dropdown contains another value, then the valueChangeListener will also be invoked. If you preset the initial value of the dropdown with the value of the default option, then the valueChangeListener will not be invoked -simply because the value has not changed. You can preset it in for example the constructor of the bean or during filling of the selectitems.
    E.g.private String selectedItem; // +getter +setter
    private List<String> selectItems; // +getter
    public MyBean() {
        fillSelectItems();
    private void fillSelectItems() {
        selectItems = new ArrayList<SelectItem>();
        for (SomeObject someObject : someDAO.list()) {
            if (selectedItem == null) {
                selectedItem = someObject.getValue();
            selectItems.add(new SelectItem(someObject.getValue(), someObject.getLabel()));
    }

  • Problem with java and flex web service

    Hi,
    I have a basic web service written in java using jax ws 2.1
    ri. I need to call it from Flex using the WebService class
    Annotations for the java web method :
    @WebMethod
    public void Login(
    @WebParam(name="server") String serverURL,
    @WebParam(name=AUTHENTICATE_HEADER,header=true,mode=WebParam.Mode.INOUTHolder<Authenticate Header>
    authHeader)
    When I try and call the service from Flex , it can't find the
    login method and attempts to call it fail. If I set the web service
    to RPC based using @SOAPBinding , the method is found but then
    there are issues with the authentication header.
    What do I need to do to get flex web services communicating
    succesfully with java ?
    Are there are any known compatibility issues ? Or guidelines
    for going about this ?
    Any help would be appreciated

    well Shay,
    i've used JDev's tools to developer and to deploy the web service: the war and ear files are automatically generates you to the end of the process.
    I have included all the files java and the compiled classes, but I do not have files jar.
    But don't works: if i create only one java class with all code inside then it works fine!!
    Daniele

  • Problems with events in Photo app on upgrading to iOS8

    Yes we understood that iPhoto & Aperture were to be discontinued on the desktop OS sometime in the future but it was a shock to find without warning when upgrading to iOS 8 that iPhoto would not work. Why didn't Apple tell us this!
    The new version of iOS 8 Photos app. is better then the previous but just doesn't have the features when I have spent hours tagging, editing and sorting all my photos in iPhoto on my iPad and  desktop.
    On migrating to iOS8 all my photos transferred fine but the Events are now in a random order in the Photos app on my iPad rather then in the date created order as is the norm and is reflected in iPhoto on the desktop. They appeared in the correct order in the Photo app before the update. I cannot seem to change that, so I am unable to easily find the photos I wish to view by scrolling through the Events. Has anyone any suggestions of how to sort this? Removing photos and re-syncing them did not help neither has a complete update, restore and re-sync!
    Even trying to find a photo using the new improved search function does not help me find the photos. Even though I give each Event a name "Lisa's Wedding" etc. the search function in the Photos app in iOS 8 fails to find events or most keywords which I had hoped it would. From what I have seen so far the search finds titles of individual photos, albums and geo tags, however even the geo tags seem to be named differently to what show up in iPhoto on the desktop.
    Presently I have had to downgrade to iOS 7.1.2 so that I can carry on working the way that I did as do need to work!
    I have raised a complaint with apple regarding the dumping of the iPhoto now and a bug report regarding the ordering of Events on the Photos app. (I seemed to recall that happened with a very early version of the Photos app.) However if anyone has any suggestions of work arounds or if I am just missing something, then all and any advice would be very welcome.
    Thank you
    Simon

    but just doesn't have the features when I have spent hours tagging, editing and sorting all my photos in iPhoto on my iPad and  desktop.
    You cannot add tags and captions in Photos iOS 8, and you cannot see them when opening a photo. But the tags you added previously are still there when you migrate the iPhoto library to Photos. You will see that, when you use the search field and enter one of your tags or a caption. This will find all photos with this tagged you then can create an album of all tagged photos for each tag. Creating albums with distinctive names is the new way of tagging. You can search for album names.
    I share your sentiments entirely, and I hope Apple will provide an update to Photos soon or offer app extensions to add the missing features.

  • EEM problem with "event timer absolute time"

    Hi
    I wanted to execute a EEM script at a certain time, 2015-05-04 03:00:00 GMT+2:00. So I used the "event timer absolute time" command.
    But the switch executed the script immediately. Is there something wrong with the script? Is there another way to execute a few commands at a certain time like this?
    Script:
    event manager applet CHANGE_TO_RAPID-PVST_v2
    event timer absolute time 1430701200
    action 1.0 cli command "enable"
    action 1.1 cli command "config t"
    action 2.0 cli command "spanning-tree mode rapid-pvst"
    action 2.1 cli command "end"
    action 3.0 syslog msg "Changed to Rapid-PVST by EEM script CHANGE_TO_RAPID-PVST_v2"
    Switch: WS-C3560X-24T-S
    IOS: 15.0(2)SE4
    EEM version 3.2
    #show event manager history events
    No. Job Id Proc Status Time of Event Event Type Name
    2 2 Actv success Thu Apr30 09:25:02 2015 timer absolute applet: CHANGE_TO_RAPID-PVST_v2
    I used this link to calcute the timer value. http://www.epochconverter.com/

    I honestly have never seen anyone use this timer.   You'd be better off using cron and removing the applet when it's done.
    That said, this does look like a bug.  Given the little use we've seen of this timer, it's likely a new one.  I recommend opening a TAC case so it can be tracked.

  • ICal problem with events

    iCal - since installing Lion, when I enter an event, it defaults to "all day" and the default end time is 8 hours later rather than 1.

    Yes, it's a problem that many people have reported. The notes in the calendar do not wrap around; it's just one long line of text that goes off-screen. Also, any notes you have in "contacts" don't show up at all. I hope this is corrected in future software updates.

  • JSF Problem with events

    4 comboboxes need to be used in several JSF pages.
    This cbo are stored in the jspf file :
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    <f:subview id="cboSearch">
        <p>
            <h:selectOneMenu id="cboSites" value="#{searchFormMB.siteChoisi}"
                              onchange="submit()" valueChangeListener="#{searchFormMB.eventCboSitesChanged}">
                <f:selectItems id="siteItem" value="#{searchFormMB.siteItems}"/>
            </h:selectOneMenu>
        </p>
        <p>
            <h:selectOneMenu id="cboPeriodes" value="#{searchFormMB.periodeChoisie}"
                             onchange="submit()" valueChangeListener="#{searchFormMB.eventCboPeriodesChanged}">
                <f:selectItems id="periodeItem" value="#{searchFormMB.periodeItems}"/>
            </h:selectOneMenu>
        </p>
        <p>
            <h:selectOneMenu id="cboPersonnels" value="#{searchFormMB.auteurChoisi}"
                             onchange="submit()" valueChangeListener="#{searchFormMB.eventCboPersonnelsChanged}">
                <f:selectItems id="personnelItem" value="#{searchFormMB.personnelItems}"/>
            </h:selectOneMenu>
        </p>
        <p>
            <h:selectOneMenu id="cboEssais" value="#{searchFormMB.essaiChoisi}" binding="#{searchFormMB.cboEssai}"
                             onchange="submit()" valueChangeListener="#{searchFormMB.eventCboEssaiChanged}">
                <f:selectItems id="essaiItem" value="#{searchFormMB.essaiItems}"/>
            </h:selectOneMenu>
        </p>
    </f:subview>The problem is with the last cbo (id="cboEssais") since "#{searchFormMB.eventCboEssaiChanged}" is called for the active page and for all previous pages. That means it is called once for the first page visited, twice for the second page visited, three time for the third page visited, ...
    Any idea about this problem ? Thanks

    When i change page valueChangeListener fired at stage RENDER_RESPONSE 6 and when cbo is change valueChangeListener fired at stage PROCESS_VALIDATIONS 3.
    In both cases the number of successive fires (call of valueChangeListener) is equal to the number of (re)visited pages since beginning of the session.

  • Problem with events in LOV

    Hello,
    how can I call events in a LOV?
    I have an LOV which display data in a BC4J Table using SingleSelection. The rangeSize is set to 10, so only the first 10 rows are displayed and a navigationBar to move to the next ten. If I move to the next rows, the lov seems to send information to my parent window and the callback Method executes. When I chose a row of the next set nothing happens.
    The documentation says that it is possible to move data in the table, and search over the data of the table.
    Can anybody help me with that?
    Thanks Christian

    First, I'm assuming you mean you are using a listOfValues element when you say "I have an LOV which display data in a BC4J Table."
    There is nothing LOV-centric about the table in the contents of the listOfValues. It's just a table, managed by you, the client, as you would any other table. So if you pull the table code out of the LOV, it should work (if not, it gives you an easier environment in which to debug).
    When you finally have the set of rows that contain the value you are interested in, clicking the single select radio button will not fire an event, this merely notes which row you are interested in (and you can change you mind an pick another on the same or another rowset). When you really do want to send your selection, you have to click the "Select" button. This will fire the lovSelect event with the data from the LOV window, and finally the lovUpdate event in the main window.

Maybe you are looking for

  • Re:trackpad and keyboard not working on my MBP

    Over the past few days, my track pad on my laptop has stopped working and same with the keyboard. I have had to plug in an external keyboard and I am using a bluetooth mouse. This problem seems to occur randomly and frequently lately. I have to logou

  • No variant found when running payment program

    Dear all, When I executed F110, ran proposal then ran payment but no payment medium was generated. Of course I did not forget to make a check in pop up windows which say "Create payment medium." Here is what display in proposal log: No variants found

  • AcroForm FDF Template functionality broken by updates

    We have many cases where we build an FDF file that went sent to the browser causes a PDF to be assembled (and form fields filled in) from multiple PDFs containing acroForm templates.  Each time an Acrobat patch is applied by my company, this function

  • Where can I purchase a replacement power cord for my mid2010 mac mini?

    I cannot seem to find it in the store. Also, would it be unsafe to keep the cord plugged it but disconnected to the mac mini itself?

  • Setup WRT160N only for business hours

    I looking to set up my Wireless router to be only Active wireless signal from 6 am to 6 pm Monday thru friday. I want to do this keep my Work network more secure. Does any one know how to set this up. Thanks Jim