How to raise an event when the user have clicked all the buttons (in random order)?

Greetings,

I want to trigger an event (frame 2 goto and stop) after all my 3 user buttons were clicked in no particular order.

I have 3 buttons on the stage, image1. (instence names: MCBlue, MCRed, MCYellow)

How can I write my code?

Here's what I have, but it does not at all. I'm so confused.

I thank very you much for your time.

[code]:

import flash.events.Event;
import flash.events.MouseEvent; 

stop();  

MCRed.addEventListener(MouseEvent.CLICK,redReady);
MCBlue.addEventListener(MouseEvent.CLICK,blueReady);
MCYellow.addEventListener(MouseEvent.CLICK,yellowReady);

function redReady(event:MouseEvent):void
{
          MCRed.MouseEvent.CLICK();
}

function blueReady(event:MouseEvent):void
{
          MCBlue.MouseEvent.CLICK();
}


function yellowReady(event:MouseEvent):void
{
          MCBlue.MouseEvent.CLICK();
}


var buttons:Array = [redReady, blueReady, yellowReady];
var sequence:Array = [];
var correct:int;


addEventListener(Event.ENTER_FRAME, gotoFrame);


function gotoFrame(e:MouseEvent):void {
          if (buttons.indexOf(e.target) == sequence[correct]){
                    gotoAndStop(2);
          }
}

If the buttons are movieclip symbols, then a way to solve it would be to set a property of each button to be true, when everyone gets clicked and then have a function that you call who checks this property for all buttons.  When all the true test is when you switch to the 2 structure.  Something like...

import flash.events.Event;
import flash.events.MouseEvent;

stop();  

MCRed.addEventListener(MouseEvent.CLICK,redReady);
MCBlue.addEventListener(MouseEvent.CLICK,blueReady);
MCYellow.addEventListener(MouseEvent.CLICK,yellowReady);

MCRed.clicked = false;
MCBlue.clicked = false;
MCYellow.clicked = false;

function redReady(event:MouseEvent):void
{
          MCRed.clicked = true;
          gotoFrame();

}

function blueReady(event:MouseEvent):void
{
          MCBlue.clicked = true;
          gotoFrame();
}

function yellowReady(event:MouseEvent):void
{
          MCYellow.clicked = true;
          gotoFrame();
}

function gotoFrame():void {
          if(MCRed.clicked && MCBlue.clicked && MCYellow.clicked){
                    gotoAndStop(2);
          }
}

Tags: Adobe Animate

Similar Questions

  • How to add multiple lines when the button is clicked

    How to add multiple lines when the click on button now is just add a row .plz give me idea how... waiting for answer

    / public final class screen extends MyScreen
    {
    /**
    * Creates a new object of MyScreen
    */
    ObjectChoiceField obj1 obj2, obj3, obj4.
    Table of String() = {'101 ', ' 102'};
    String of shadow [] = {"Shade1", "Shade2"};
    Rolls of string [] = {'101 ', ' 102'};
    String cutting [] = {"100-150", "150-200"};
    Chain of selectedindex1, selectedindex2, selectedindex3, selectedindex4;
    LabelField lbl1 lbl2, lbl3, lbl4;
        
    GFM LinedGridFieldManager;
    HFM HorizontalFieldManager, hfm1, hfm2 hfm3;
    VerticalFieldManager vfmMain;
        
    public MyScreen()
    {
        
    Set the displayed title of the screen
    hfm1 = new HorizontalFieldManager (HorizontalFieldManager.NO_VERTICAL_SCROLL |) HorizontalFieldManager.NO_VERTICAL_SCROLLBAR);
    hfm2 = new HorizontalFieldManager (HorizontalFieldManager.NO_VERTICAL_SCROLL |) HorizontalFieldManager.NO_VERTICAL_SCROLLBAR);
    hfm3 = new HorizontalFieldManager (HorizontalFieldManager.NO_VERTICAL_SCROLL |) HorizontalFieldManager.NO_VERTICAL_SCROLLBAR);
    HFM = new HorizontalFieldManager (HorizontalFieldManager.FIELD_RIGHT);
    vfmMain = new VerticalFieldManager (Manager.NO_VERTICAL_SCROLL |) Manager.NO_HORIZONTAL_SCROLLBAR);
            
    obj1 = new ObjectChoiceField ("", graph, 0, FIELD_LEFT);
    obj2 = new ObjectChoiceField ("", blind, 0, FIELD_LEFT);
    Obj3 = new ObjectChoiceField ("", rolls, 0, FIELD_LEFT);
    Obj4 = new ObjectChoiceField ("", cuts, 0, FIELD_LEFT);
            
    LBL1 = new LabelField("");
    LBL2 = new LabelField("");
    lbl3 = new LabelField("");
    lbl4 = new LabelField("");
            
    ButtonField btnAdd = new ButtonField ("ADD", FIELD_RIGHT);
            
    GFM = new LinedGridFieldManager (4, LinedGridFieldManager.VERTICAL_SCROLL);
            
    hfm1.setMargin (20, 0, 10, 0);
    hfm1. Add (new LabelField ("Chart"));
    hfm1. Add (obj1);
    hfm1. Add (new LabelField ("Shade"));
    hfm1. Add (obj2);
            
    hfm2. Add (new LabelField ("Rolls"));
    hfm2. Add (Obj3);
    hfm2. Add (new LabelField ("Cuts"));
    hfm2. Add (Obj4);
    HFM. Add (btnAdd);
            
    GFM. Add (new LabelField ("Chart"));
    GFM. Add (new LabelField ("Shade"));
    GFM. Add (new LabelField ("Rolls"));
    GFM. Add (new LabelField ("Cuts"));
            
    vfmMain.add (hfm1);
    vfmMain.add (hfm2);
    vfmMain.add (hfm3);
    vfmMain.add (hfm);
    vfmMain.add (new SeparatorField());
    vfmMain.add (gfm);
    Add (vfmMain);
            
    btnAdd.setChangeListener (new FieldChangeListener()
    {
    ' Public Sub fieldChanged (field field, int context) {}
    TODO self-generating method stub
    selectedindex1 = chart [obj1.getSelectedIndex ()];
    selectedindex2 = shade [obj2.getSelectedIndex ()];
    selectedindex3 = rolls [obj3.getSelectedIndex ()];
    selectedindex4 = cuts [obj4.getSelectedIndex ()];
                    
    While (LBL1. GetText(). Equals("") | LBL2. GetText(). Equals("") | lbl3. GetText(). Equals("") | lbl4. GetText(). Equals(""))
    {
    LBL1. SetText (selectedindex1);
    LBL2. SetText (selectedindex2);
    lbl3. SetText (selectedindex3);
    lbl4. SetText (selectedindex4);
                    
    GFM. Add (LBL1);
    GFM. Add (LBL2);
    GFM. Add (lbl3);
    GFM. Add (lbl4);
                    
    }
    }
    });
    }
    }

    Hi Piya,

    I run your code, and according to your logic that it works correctly.

    It's adding that line only once because according to your logic that one line can be added to MDT, if you do not want to add line on each click on the button, follow these steps:

    selectedindex1 = chart [obj1.getSelectedIndex ()];
    selectedindex2 = shade [obj2.getSelectedIndex ()];
    selectedindex3 = rolls [obj3.getSelectedIndex ()];
    selectedindex4 = cuts [obj4.getSelectedIndex ()];

    Lbl1 LabelField = new LabelField("");
    Lbl2 LabelField = new LabelField("");
    LabelField lbl3 = new LabelField("");
    LabelField lbl4 = new LabelField("");
    If (LBL1. GetText(). Equals("") | LBL2. GetText(). Equals("") | lbl3. GetText(). Equals("") | lbl4. GetText(). Equals(""))
    {
    LBL1. SetText (selectedindex1);
    LBL2. SetText (selectedindex2);
    lbl3. SetText (selectedindex3);
    lbl4. SetText (selectedindex4);
                    
    GFM. Add (LBL1);
    GFM. Add (LBL2);
    GFM. Add (lbl3);
    GFM. Add (lbl4);
                    
    }

  • How to raise an event when all the sounds in a soundchannel ends

    I have a soundchannel and I play a lot of sounds in there, but I need the fulfillment of any audio file within this channel to be followed by a two second wait, and then trigger an event. How can I do this?

    When the SoundChannel object is complete, there is a soundComplete event gets dispatched (Event.SOUND_COMPLETE).  Its assign a listener for the event.  If you need more information, the Flash help documentation has everything.

  • How to raise an event when a file is created.

    Hello!
    I need labview wait until a file is created in a certain folder (by the other program) and then to perform a task.

    Is this possible?

    I have no idea how to implement it.

    Thank you!

    Use the file Info feature.  From time to time, repeat until you do not get an error.

    I saw an example somewhere where someone used .NET to get an event when a file has changed.  I have no idea where he is or how it was done however.

  • How to raise an event (in the structure of the event) comparison function output

    Hello

    I want to triger specific event from a structure of event with the release of the comparison function. I tried several times but the output of the comparison function is not triggered. Please, propose solutions.

    Kind regards

    Mlad

    If you want to use a structure of the event, you must react on the digital inputs, for example as follows:

    Notice that the VI is inactive unless a change control (x, y, stop), date on which Boolean values are updated, comparison made, his played if necessary, and VI stopped if you press stop.

  • How do I add text when the button is in short

    Hi friends,

    I am the third party application.

    This header contains the BitmapFields when the focus moves to this imageat the bottom of the image, I want to mention the name of the image.

    Please tell me how to do this.

    Thank you in advance.

    Hello

    The descriptor, you're trying to find is known as ToolTip.

    Try this link.

    http://supportforums.BlackBerry.com/rim/attachments/rim/java_dev/163809/1/ToolTip_1.txt

    Thank you

    Krishnan

  • How to perform an action when the button is clicked reply all in BB email?

    I find the solution on below scenario, any help appriciated.

    User open a receipt email and click the 'reply to all' "."

    It is possible to perform any action on the button 'reply to all '?

    Thank you

    You can not interact with native applications except for adding your own menu entry (entries).

  • How to raise an event during the double click on a tree node

    I have this code that creates the new tab in a remote Java class.

    treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>()
       {
       @Override
       public void changed(ObservableValue<? extends TreeItem<String>> observable, TreeItem<String> oldValue, TreeItem<String> newValue)
       {
       System.out.println("Selected Text : " + newValue.getValue());
       // Create New Tab
       Tab tabdata = new Tab();
       Label tabALabel = new Label("Test");
      tabdata.setGraphic(tabALabel);
    
       DataStage.addNewTab(tabdata);
       }
       });
    

    Can you tell me how I can change the code to open a new tab when I double click a tree node. In my code, the tab opens when I click once. What event handler do I need?

    import java.util.Arrays;
    
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.control.TreeCell;
    import javafx.scene.control.TreeView;
    import javafx.scene.control.TreeItem;
    import javafx.scene.control.SelectionMode;
    import javafx.util.Callback;
    
    public class TreeTest extends Application {
    
      public static void main(String[] args) {
        launch(args);
      }
    
      @Override
      public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("TreeView Test");
        primaryStage.setScene(createScene());
        primaryStage.show();
      }
    
      private Scene createScene() {
        final StackPane stackPane = new StackPane();
        final TreeView treeView = new TreeView();
        treeView.setRoot(createModel());
        treeView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    
        treeView.setCellFactory(new Callback, TreeCell>() {
          @Override
          public TreeCell call(TreeView treeView) {
            return new ClickableTreeCell();
          }
        });
        stackPane.getChildren().add(treeView);
        return new Scene(stackPane);
      }
    
      private TreeItem createModel() {
        TreeItem root = new TreeItem("RootNode");
        TreeItem packageA = new TreeItem("package A");
        packageA.getChildren().addAll(
            Arrays.asList(new TreeItem("A1"), new TreeItem("A2"), new TreeItem("A3"))
        );
        TreeItem packageB = new TreeItem("package B");
        packageB.getChildren().addAll(
            Arrays.asList(new TreeItem("B1"), new TreeItem("B2"), new TreeItem("B3"))
        );
        root.getChildren().addAll(Arrays.asList(packageA, packageB));
        return root;
      }
    
      private class ClickableTreeCell extends TreeCell {
        ClickableTreeCell() {
          setOnMouseClicked(new EventHandler() {
            @Override
            public void handle(MouseEvent event) {
              // Handle double-clicks on non-empty cells:
              if (event.getClickCount()==2 && ! isEmpty()) {
                System.out.println("Mouse double-clicked on: " + getItem());
              }
            }
          });
        }
    
        @Override
        protected void updateItem(String item, boolean empty) {
          super.updateItem(item, empty);
          if (empty) {
            setText(null);
          } else {
            setText(item);
          }
        }
      }
    }
    
  • How to raise an event from the arrayCollection collection?

    I'm passing data from a model to a view in the following files. It works fine, but I want to send a message on the screen when an arrayCollection collection is filled. I know that I could create a custom event, but I do not understand why the eventhandler I created will not work. Please tell me what I'm doing wrong.

    Thank you.

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"creationComplete =" init () "> "
    < mx:Script >
    <! [CDATA]
    Import mx.collections.ArrayCollection;
    Import mx.events.CollectionEvent;
    Import mx.rpc.events.ResultEvent;
    [Bindable] private var databaseDataArrayCollection:ArrayCollection = new ArrayCollection collection;
    [Bindable] private var: model = new modele();
    [Bindable] private var: controller = new Controller();
    private function init (): void {}
    model.databaseDataArrayCollection.addEventListener (CollectionEvent.COLLECTION_CHANGE, chan ge)
    model = Model.createInstance ();
    controller.getData ();
    }
    private void change(e:Event):void {}
    trace ("changed in sight")
    }
    []] >
    < / mx:Script >
    < mx:DataGrid dataProvider = "{model.databaseDataArrayCollection}" > "
    < mx:columns >
    < mx:DataGridColumn id = "first name" dataField = "first name" headerText = "FIRSTNAME" / >
    < mx:DataGridColumn id = "lastName" dataField = "lastName" headerText = "LAST NAME" / >
    < / mx:columns >
    < / mx:DataGrid >
    < / mx:Application >

    Model.As

    package {}
    Import mx.collections.ArrayCollection;
    [Bindable]
    public class {model
    public var databaseDataArrayCollection:ArrayCollection = new ArrayCollection();
    private static var: model = new model;
    private static var num:Number = 0;
    public void modele() {}
    }
    Public Shared function createInstance (): model {}
    NUM ++
    if(Model == null) {}
    model = new modele();
    }
    return the template;
    }
    }
    }

    Controller.As

    package {}
    import com.simon.cms.UrlString;

    import flash.events.Event;

    Import mx.collections.ArrayCollection;
    Import mx.events.CollectionEvent;
    Import mx.rpc.events.ResultEvent;
    Import mx.rpc.http.HTTPService;
    Import mx.utils.StringUtil;

    [Bindable]
    public class {controller
    private var: model = new modele();
    public var httpService:HTTPService = new HTTPService;
    private var login_string:UrlString = new UrlString();
    public void Controller() {}
    model = Model.createInstance ();
    }
    public void getData (): void {}
    var params: Object = new Object();
    httpService.url = login_string.login;
    httpService.method = "GET";
    httpService.addEventListener (ResultEvent.RESULT, extractData);
    httpService.send (params)
    }
    private void extractData(event:ResultEvent):void {}
    httpService.removeEventListener (ResultEvent.RESULT, extractData);
    model.databaseDataArrayCollection.addEventListener (CollectionEvent.COLLECTION_CHANGE, chan ge)
    model.databaseDataArrayCollection = event.result.student.task;
    }
    private void change(e:CollectionEvent):void {}
    trace ("Changed in the collection")
    }
    }
    }

    You use "=" this is a reversal/replacement.  There is no chip

    assignment that will update.

    You could do

    model.databaseDataArrayCollection.source =

    Event.Result.Student.Task.source;

    That should translate into a CollectionEventKind.RESET in original HQ as it

    now a new set of data.

  • How to register for an event when the device is connected to the PC in USB mode or sync

    I develop application on blackberry with phonegap.

    I want to hear event when the BlackBerry device is connected to the PC by USB MODE or sync.
    I saw mediagallery and applications Filemanager showing the dialogue that the application cannot be used when connected to the PC in USB mode.
    I want to display dialog similar to my request.
    Can anyone please help on how to do it.

    I saw blackberry webworks API

    public static Boolean blackberry.system.isMassStorageActive)

    who says if massstorage is active or not.

    But I can't keep on request this API every time. I'm looking for an API that gives me the reminder.

    Can you please help.

    On the side of Java, this can be done by implementing a FileSystemListener and the rootChanged method:

    public void rootChanged(final int state, String rootName) {
        if (rootName.equalsIgnoreCase("sdcard/")) {
            if (state == FileSystemListener.ROOT_ADDED) {
                /* SD Card is available. */
            } else if (state == FileSystemListener.ROOT_REMOVED) {
                /* SD Card is not available. */
            }
        }
    }
    

    I was not able to find a corresponding WebWorks API or API community well, so I think you need to create your own custom extension to implement this feature of the listener.
    https://developer.BlackBerry.com/HTML5/documentation/using_javascript_extensions_1866976_11.html

  • Intercept touch green application event when the device is locked

    Hi, I'm new to blackberry. What I want is I want to take a key event (green or red button) when the device is locked and do specific tasks in my application that runs in the background if this button is pressed. Is this possible? How can I do?

    Just to be 100% accurate, it is possible for a keyListener (look to the top of the class) to pick up some events even when running in the background.  It can be different events when the device is locked.  Indeed, the events may be different depending on whether the "locked" screen is currently displayed or not. And the entire lot is dependent on operating system level, in other words, the same device running two different levels of OS will possess differently in terms of what keys can detect a listener in the background.

    So if you have a BONE and a specific device, so it might be something you can do, especially if it is an older operating system.  However if you try to create something that works generically, then know that I've tried and failed!.

  • Is there an event when the model color depth/pixel format is changed?

    Is there a way I can detect the change in depth of color in a composition?
    I know that I can react differently by calling PF_GetPixelFormat() on render for the format/bit depth of current, but I was wondering if there is a way to detect and react to the event when a user changes the number of colors in the publication manual?
    Basically, what I want to do is hide/change settings in the ECW according to the bit depth.

    Any help appreciated :-)

    You can use PF_UpdateParamUI during the call to render to force AE to refresh the user interface.

    You can also hide/show params at any time using AEGP_SetDynamicStreamFlag and AEGP_DynStreamFlag_HIDDEN.

  • How to validate an entry when the focus leaves the intensity absorbed in

    How to validate an entry when the focus leaves the intensity absorbed in a form?

    "Ansury" wrote in message
    News:garo90$L71$1@forums. Macromedia.com...
    > Not AFAIK. Event.Target has a reference to the object that sent the
    > event. In livedocs:
    >
    > "Every event object has a goal and a currentTarget property that help."
    > you
    > Hold where it is being spread. The target
    > property
    "> return to the sender of the event.
    "
    >
    > BUT...
    > Your if statement will never evaluate true because you compare one
    > UITextField to a TextInput. A UITextField (stored internally in a
    (> TextInput, it makes the text) actually dispatches the event.

    currentTarget gives you the object on which the event actually listener
    attached to...

  • If time machine is incremental how it removes previous versions when the disk is full, without breaking the chain, so do not be able to restore all changes since the first full file

    If time machine is incremental how it removes previous versions when the disk is full, without breaking the chain, so do not be able to restore the file with any changes made since the full backup first file...

    If the TM drive storage is full TM automatically deletes the version the oldest files for the new incremental backups can be made. Thus, in this case you cannot restore the versions that TM deleted because it takes more storage.

  • How to solve a problem when the windows setup program does not open a program, says I need to install it. and an error message 1706

    How to solve a problem when the windows setup program does not open a program, says I need installation cd and a 1706 error message happens.

    Hi PAtwoodwu,

    1. what program are you trying to install?

    2. did you of recent changes on the computer?

    3 does happen with all programs?

    Check and make sure that the Windows service install is running on the computer.

    (a) click on start to reduce this includes this image, click run , type services.msc , and then press enter to open Services.

    (b) right click on the Windows Installer service and then click Properties.

    (c) if the box Startup type is set to Disabled, change it to Manual.

    (d) click on OK to close the Properties window.

    (e) right click on the Windows Installer service and then click Start. The service should start without errors.

    (f) click on the file menu, and then click exit.

Maybe you are looking for

  • How can I delete an email stuck in my iPhone Mail cannot send to send a video?

    How can I delete an email stuck in my iPhone Mail cannot send to send a video? Actually Mail attempts to send the e-mail and the ball rotates constantly. I have a feeling that it uses resources constantly. I do not have email.  It can be removed. I j

  • Satellite L350 - 172 (PSLD8E) - drivers and tools for Windows 7

    Hi all After 3 years using this laptop with Windows XP, I decided to install Windows 7 Professional 32 bit. It was very easy and because of 3 GB of RAM it works fast (faster than XP). Download area of Toshiba in the web offer of many drivers and utli

  • Cannot hear sound on Skype

    I'm on voice chat on Skype and my friend can't hear me but I can hear it. We all have two controls sound and everything is going well. Need a solution to this thank you

  • How to fix update 0x800B0001 error code

    How to resolve the update code error 0x800B0001 .i have mirosoft windows smart xp before it was work .i see this error first time thts y I can't update my window.kindly send me the solution of this problem.

  • questions about my lollipop ZR?

    (1) the LED Strip does not work in the album app(2) walkman app not to change the background color according to the lollipop and the led Strip light purpleAny solution? Tried: installation layout, fresh, firm in stamina mode...