youfeis / mad-components

Automatically exported from code.google.com/p/mad-components
0 stars 0 forks source link

Button within each list row not able to findViewById #45

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I don't necessarily think this is a BUG but there is no examples for this in 
the documentation and I can't get it to work with the obvious attemps.  The 
list has buttons in it to try to go to settings screens or other screens(kind 
of like your example with switches in the lists).  I can't get them to respond 
to anything.

What steps will reproduce the problem?
1. made list: LISTBRUSHES:XML = <list id="list0" colour="#FFFFFF" 
background="#CCCCCC,#FFFFFF">                       <horizontal>
    <image id="image">48</image>
        <vertical>
        <horizontal><label id="label"><font size="18"/></label>         <button id="brushsettings"><font size="12">SETTINGS</font></button>
    </horizontal>
    <label id="label2"><font color="#666666" size="11"/></label>
        </vertical>
        <label id="labelpurchase" alignH="right"><font color="#009900" size="18"/></label>
    <button id="button2" alignH="right" colour="#00FF00"/>
    </horizontal>
    </list>;
2. list works fine on all other accounts.  but this doesn't work... 

var settingBtn:UIButton = UIButton(UI.findViewById("brushsettings"));
settingBtn.addEventListener(MouseEvent.MOUSE_UP, goSettings);
settingBtn.addEventListener(UIButton.CLICKED, goSettings);
function goSettings(event:Event) :void {
    _styles.goToPage(1,UIPages.SLIDE_LEFT);
}

What is the expected output? What do you see instead?

TypeError: Error #1009: Cannot access a property or method of a null object 
reference.
    at photopaintFree_fla::MainTimeline/frame1()[photopaintFree_fla.MainTimeline::frame1:3276]

---shouldn't this work? or does it need some reference to the parent? not sure 
and documentation doesn't help on this.

What version of the product are you using? On what operating system?
windows 7, Flash Pro cS6 mad-components 0.7.6

Please provide any additional information below.

 The code I sent is dumbed down, eventually once I get it working I need it to use the list .index to tell it what row was clicked

Original issue reported on code.google.com by joelrei...@gmail.com on 11 Mar 2013 at 8:53

GoogleCodeExporter commented 9 years ago
Hi, I did find this in the code for UI
//Find the component that matches the id parameter.  Note optional row and 
group parameters to find a component within a specific list row.

This will probably solve it. Sorry to bother you, so my code changed to this:
var settingBtn:UIButton = UIButton(UI.findViewById("brushsettings", 1));
Which does work except that I'd have to make a different function for each 
button.  Is there a way to set it up for all rows and in the button function 
look for the list row index?

thank you for all your work!

Original comment by joelrei...@gmail.com on 11 Mar 2013 at 9:05