Flash/Actionscript2 - Can't get comboBox "change" event to fire - actionscript

I'm trying to use the combobox component for Flash. I can't get the change event to fire. My code is pretty much straight of of the adobe site (link below). The box gets populated but changing the value produces no trace output. What am I doing wrong?
http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00002149.html#3138459
myCombo.addItem("hi1", "hi5");
myCombo.addItem("h2", "hi6");
myCombo.addItem("hi3", "hi7");
myCombo.addItem("h4", "hi8");
var form = new Object();
form.change = function(eventObj){
trace("Value changed to " + eventObj.target.value);
}
myCombo.addEventListener("change", form);

I pasted your code into an AS2 project and it worked as expected for me. No other output? Try adding a trace before and after the addEventListener to make sure it's getting called. Try using a name other than form for your object. Try running it in debug and set a breakpoint in the change function.

Related

Adding components to BorderLayout

I'm trying to implement BorderLayout within IntelliJ and am having trouble getting it to work. It compiles fine, but when it runs I see the viewer for a second and then it crashes. The code I currently have is
Button Next=new Button("Next");
Button Back=new Button("Back");
Container panel1=new Container();
Container panel2=new Container();
home = new Form("Home");
home.setLayout(new BorderLayout());
panel1.setLayout(new BorderLayout());
panel2.setLayout(new BorderLayout());
home.addComponent(BorderLayout.EAST,panel1);
home.addComponent(BorderLayout.WEST,panel2);
panel1.addComponent(Next);
panel2.addComponent(Back);
The error I get after it crashes is "Cannot add component to BorderLayout Container without constraint parameter". I tried researching a constraint parameter and also working with BorderLayout in IntelliJ, but any texts I found were either not helpful or too complicated to understand. Thanks so much!
The error message is telling you that if you want to add a component to a border layout you have to specify where to put it. You've done this when adding components to home, but you haven't when you add components to panel1 and panel2. You need to add BorderLayout.EAST (or WEST, or whatever) to get:
panel1.addComponent(BorderLayout.EAST, Next);
panel2.addComponent(BorderLayout.WEST, Back);
However, I think you're using this wrong. You probably don't want a border layout in panel1 or panel2 -- they're fine with the default flow layout, so if you remove the panel1/2.setLayout() lines your code should work fine.
BTW: In java we don't use capital letters at the start of variables, so Next and Back should be next and back. Also, panel1 should be something like nextPanel, and panel2 should be something like backPanel.
To add one more thing -- nobody uses awt any more. We've all moved on (mostly to html5). So, trying this in swing, you would get:
import javax.swing.*;
...
JButton next = new JButton("Next");
JButton back = new JButton("Back");
JFrame home = new JFrame("Home");
home.setLayout(new BorderLayout());
home.add(back, BorderLayout.WEST);
home.add(next, BorderLayout.EAST);

bwu_datagrid in paper-action-dialog messes up columns 2nd time dialog is opened

I am using bwu_datagrid in my Dart/Polymer webapp. In a paper-action-dialog, I am using the "grouping" grid to show a tree-table. The first time the dialog is opened, the grid looks fine. The second time the dialog is opened, it is fine in Chrome, but when I use Firefox or Safari, the columns in the non-grouped rows are scrunched to the left (overlapping each other), and the column headers have disappeared.
This was also happening in Chrome until I added the following code in the dialog's core-overlay-open-completed event handler:
grid.setColumns = columns;
grid.invalidate();
grid.render();
It appears that someone reported a similar issue back in November. Was this issue ever resolved and/or fixed?
I have come up with a workaround, that at least works for me and for the "issue 97 reattach" example that has been posted elsewhere. I don't know why it works, but I added a new method to bwu_datagrid.dart, called reshowGrid(). This new method is a stripped down version of "setColumns". I think the real key may be the commented out "style append".
void reshowGrid() {
if (_initialized) {
invalidateAllRows();
_createColumnHeaders();
_removeCssRules();
_createCssRules();
resizeCanvas();
_applyColumnWidths();
//this.shadowRoot.append(_style);
_handleScroll();
}
}
I call grid.reshowGrid() instead of grid.setColumns.

.trigger('create') cannot create a listview

Here are the codes I have to dynamically create and enhance a page. The similar pattern has been working for many other kinds, such as text field, button, grid-view, etc. But I found it cannot work with a listview.
$(document).bind("pagebeforechange", function route(e, data) {
...
$content = $page.children(":jqmData(role=content)");
var markup = '<ul id="calendarList" data-role="listview"><li>HELLO</li></ul>';
$content.html(markup);
$page.trigger('create');
$.mobile.changePage($page);
});
I would always get an error message like,
Cannot read property 'jQuery16409763167318888009' of undefined
Through debugging using Chrome, I found it always fails on the line of $page.trigger('create');
I found the solution myself. It works fine if I replaced the line,
$page.trigger('create');
with,
$page.page();
$content.find( ":jqmData(role=listview)" ).listview();
However, I still don't understand why. I thought the former was a newer, simpler syntax to replace the latter. A single call of $page.trigger('create'); can enhance the entire page at one shot. Does anyone know the difference of these two?

can't get a ff extension to work in v3.0.5

Does anyone know what might have changed since v3.0.5 that would enable extensions to work? Or, maybe I'm missing a setting somewhere? I wrote this add-on that works fine with newer versions, but I can't get it to launch in older ones. Specifically, I can't even get this part to work (this is in my browser overlay.xul):
<html:script>
<![CDATA[
var Cc = Components.classes;
var Ci = Components.interfaces;
var obSvc = Cc["#mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
gBrowser.consoleService = Cc["#mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
gBrowser.log = function(msg){
this.consoleService.logStringMessage(msg);
}
gBrowser.newObj= new MyAddOn();
gBrowser.log("initializing...");
function regListener()
{
obSvc.addObserver(gBrowser.newObj, "http-on-modify-request", false);
}
function unregListener()
{
obSvc.removeObserver(gBrowser.newObj, "http-on-modify-request");
}
window.addEventListener("load", regListener, false);
window.addEventListener("unload", unregListener, false);
]]>
This should attach listeners to the new obj (defined by a linked .js) However, I'm not even getting the "initializing..." message in the console. Any ideas?
Don't use <html:script>, use <script> (assuming you have xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" on your root <overlay> element).
Don't register an application-global listener (http-on-modify-request) from a window overlay. Doing so will make your code run one time in each window the user may have open. Use an XPCOM component instead - https://developer.mozilla.org/en/Setting_HTTP_request_headers
Don't pollute common objects (like gBrowser or the global object (with var Cc)) with your own properties. If everyone did that, no two extensions would work together. Put all your code properties on your own object with a unique name.
accessing gBrowser before the load event is probably what's causing your specific problem.
Set up your environment and check the Error Console to debug problems.
Don't waste time trying to support Firefox 3. It's not supported by Mozilla itself for over a year and shouldn't be used to access the web.
It looks like gBrowser.log is not defined, or at least is not a function, as the error console will probably tell you. I've never heard of it either. Maybe it was added in Fx 3.5?

WatiN: Print Dialog

I have a screen that pops up on load with a print dialog using javascript.
I've just started using WatiN to test my application. This screen is the last step of the test.
What happens is sometimes WatiN closes IE before the dialog appears, sometimes it doesn't and the window hangs around. I have ie.Close() in the test TearDown but it still gets left open if the print dialog is showing.
What I'm trying to avoid is having the orphaned IE window. I want it to close all the time.
I looked up DialogHandlers and wrote this:
var printDialogHandler = new PrintDialogHandler(PrintDialogHandler.ButtonsEnum.Cancel);
ie.DialogWatcher.Add(printDialogHandler);
And placed it before the button click that links to the page, but nothing changed.
The examples I saw had code that would do something like:
someDialogHandler.WaitUntilExists() // I might have this function name wrong...
But PrintDialogHandler has no much member.
I initially wasn't trying to test that this dialog comes up (just that the page loads and checking some values on the page) but I guess it would be more complete to wait and test for the existence of the print dialog.
Not exactly sure about your situation, but we had a problem with a popup window that also displayed a print dialog box when loaded. Our main problem was that we forgot to create a new IE instance and attach it to the popup. Here is the working code:
btnCoverSheetPrint.Click(); //Clicking this button will open a new window and a print dialog
IE iePopup = IE.AttachToIE(Find.ByUrl(new Regex(".+_CoverPage.aspx"))); //Match url ending in "_CoverPage.aspx"
WatiN.Core.DialogHandlers.PrintDialogHandler pdhPopup = new WatiN.Core.DialogHandlers.PrintDialogHandler(WatiN.Core.DialogHandlers.PrintDialogHandler.ButtonsEnum.Cancel);
using (new WatiN.Core.DialogHandlers.UseDialogOnce(iePopup.DialogWatcher, pdhPopup)) //This will use the DialogHandler once and then remove it from the DialogWatcher
{
//At this point the popup window will be open, and the print dialog will be canceled
//Use the iePopup object to manage the new window in here.
}
iePopup.Close(); // Close the popup once we are done.
This worked for me:
private void Print_N_Email(Browser ie)
{
//Print and handle dialog.
ie.Div(Find.ById("ContentMenuLeft")).Link(Find.ByText(new Regex("Print.*"))).Click();//orig
Browser ie2 = Browser.AttachTo(typeof(IE), Find.ByUrl(new Regex(".*Print.*")));
System.Threading.Thread.Sleep(1000);
PrintDialogHandler pdh = new PrintDialogHandler(PrintDialogHandler.ButtonsEnum.Cancel);
new UseDialogOnce(ie2.DialogWatcher, pdh);
ie2.Close();
}
You still might want to check your browser AutoClose property ie.AutoClose

Resources