I am new to AS3.0 and am trying to create a reusable button class. I am working on a quiz game where I have multiple correct and incorrect buttons and instead of copying the same code over and over again I am trying to create a simple way to reuse the code. I am unaware how to do this. I have created various generic button classes and none have worked. I believe the best way would revolve around creating a generic class with a Boolean 'correct' and each button class extends this parent class and sets the correct Boolean true or false. In the parent class there would be a function saying if correct then go to next frame, if !correct go to lose frame. I have tried this but to no avail; any help?
If that's a design question, then no, a button should not know if it's "the correct one" in a given quiz. All logic should be handled by button's parents, whatever type they are. A simple design would do like this: Create a set of buttons with texts, then you addEventListener(MouseEvent.CLICK,someFunction) to each, where someFunction is one for the correct button, and another for wrong-answer buttons.
Related
Good afternoon everybody.
Let me better explain the situation.
In a myComp.html I got the instance of some dropdown-buttons from another component <app-myButtonsFromAnotherComponent></app-myButtonsFromAnotherComponent>.
The dropdown-buttons are being displayed correctly BUT when I try to get the script which they are originally connected myButtonsFromAnotherComponent.ts they do not seem to communicate at all with it (I am using a Getter function in the .ts but it doesn't retrieve the datas) and at the same time, because of the instance, I cannot access their values from myComp.html either, I can just display the buttons on the screen and display the values through {{theValueInQuestion}} int their original HTML file.
Can anyone, please, help me to get those values and use them in my script?
PS Why "reusable" in the title? Because in such a way I can keep those buttons in a separate component and let other components grab them without copy and paste a ton of code.
They are two separate components you need a way to communicate between components.
you can look more into :
Localstorage
Output() and EventEmitter
Parent to Child via Input
I am trying to make a product configurator for a website. I'm using MEAN but at this point I just have a problem with AngularJS.
I proceed to explain my program. In the application you have three buttons for the first step of the configuration.
When you click one, AngularJS send back to the web the next three buttons (the values of this buttons depends on the first one you click). And here arrives the problem, this last buttons doesnt seems to work.
After clicking the first button I call the function $scope.getOption2 and it returns this:
htmlsString= '<div><button id="btnS2-1" ng-click= getOption3(1)>1</button></div>'+
'<div><button id="btnS2-2" ng-click= getOption3(2)>2</button></div>'+
'<div><button id="btnS2-3" ng-click= getOption3(3)>3</button></div>';
And this is the way I print it on screen:
$scope.option2 = $sce.trustAsHtml(pruebaHTML);
But the function $scope.getOption3 is never called when I click in one of those buttons.
I have simplified the code, but the essential part is here. I hope somebody can see my problem.
Appending elements like this is not the Angular way, and is frowned upon. Angular does not know of your new buttons, because you cannot manipulate your DOM in this way. You could $compile your elements again, but maybe you should just have the buttons in your template to begin with, you could show them with ngShow. Maybe better yet, see if there is some directive out there that can do what you want - or roll your own.
Look http://docs.angularjs.org/api/ng.$compile for details on $compile.
I've already asked a similar question, but I really can't figure out how to connect these elements together. I'm still not very good with Handlers, and I guess my question is:
How can I access UI Widgets (and their children) while outside of the doGet() function?
My use case is this: I have a list of projects/IDs. I have all the data I want based on the ID that will populate the Project Details tab of this application. I created 'unique' Buttons for each of these Projects, and threw them into a Grid. Now, I want to generate the Project Details (detailPanel) Widgets specifically for each Button if/when it is clicked.
I have the Project ID attached to each Button (uniquely) through a Hidden, but I can't seem to attach the Project Details tab (detailPanel) to the Button so that, when clicked, I can set the values for the TextBox, DateBox, ListBox, etc. Widgets of the detailPanel.
I think I'm missing something obvious about this. I want to avoid attaching each child Widget of the detailPanel as a callbackElement of the Button at all costs. There are around 40 elements (I've lost count), and it seems really inefficient. I'm almost sure that if I can add one Widget as a callback element, that I get access to all child Widgets. But I tried, and that doesn't seem to be the case.
Here is the link to the public UiApp, which shows the UI. And the sister Script Project (uneditable).
You dont need to add callback elements that you will write to, callback elements are only for reading their data. If the detailspanel id is dynamic have a hidden that has its id stored inside and pass it to the handler. from your handler you getelementbyid and set its data.
I have several buttons coded with VBA behind an Access form. I will have a number of forms which will have these buttons in their footer (new, next, prev, duplicate etc). These buttons are not standard macros, but are simple enough to have the same code work across all of my forms.
How might I go about coding these buttons (which have the same names across all forms.. kind of template-like) so I don't have to copy-paste the code in all my forms? Is there a way to write these buttons in a Module and have the form import that module's text (kind of like most other languages)?
Just curious. Makes the code a lot cleaner/easier, as the beef of the programming is my own but others will be making small edits to the form code.
The simplest thing to do would be to create a Function for each button's functionality in a standard code module. Then change the Click property of each button from [Event Procedure] to the name of the function that corresponds with that button (eg, =MyPrevFunction([Form])).
Note that in order for this to work you must specifically use Function and not Sub. There is no requirement in VBA for a function to return anything, so simply substituting the word Function for Sub is all that is required to make the change.
A picture is worth a thousand words.
As well as the idea suggested by #mwolfe02, you can have your buttons in a subform, which means that only one set of buttons need to be edited, or better yet, set up your own custom menus. These can be invoked on a per form basis or as 'standard' menus for your application. You can even have your own right-click menus.
I have a basic ASP.Net MVC 3 application which has a number of controllers and a number of actions (and subsequently views)
A common feature of the application is to show a pop-up dialog window for basic user input. One of the key features of this dialog process is a faded mask that gets shown behind the dialog box.
Each of these dialog window controls is in a separate Partial View page.
Now, some view pages may use multiple dialog boxes, and therefore include multiple partial views in them - which as is would mean multiple instances of the "mask" element.
What I am trying to find a solution for is to only need to create one instance of a "mask" element regardless of the number of dialog partial views I include, and then the script in each partial dialog will have access to this element (so basically it just needs to be on the page somewhere)
The only real idea I have come up with so far is to add the "mask" element to the master page (or in the original view page) and this will mean it only gets added once. The problem here is that it will be added even when it is not needed (albeit one small single element)
I can live with this, but I would like to know if there is a better way to handle these kinds of scenarios?
A quick idea that came to mind is some kind of master page inheritance hierarchy, So I may have a DialogMasterPage that inherits from the standard current master page. How does that sound for an approach?
Thanks
To do something like this, where each module can register their need for a certain thing in the master page, you can use HttpContext to store a flag of whether you need to write the mask div, and just set that property in each partial. At the end of the master page, if the flag is set, you can then write the mask div if its set to true.
Obviously to make this cleaner you could wrap it all in an HtmlHelper extension or something.
My initial thought is for you to use something like jQuery UI where it handles the masking for you or if you are using something custom you can load the content for the dialog via ajax then show it in the single dialog on the master page.