+1

Object within an object

Lcdrgreg 12 years ago updated 12 years ago 10
Object within an object. Not supposed to work, but I am using it in an app I am building for a local high school. Question is should I be using it, why does it work and is it at risk for not working later?

Wire:

























Please use a code block to display < code > < /code >

<class name="bpanelweb">
<panel name="[param:panelname" alias="[param:panelalias]" width="33.33%" height="15%" align="[param:align]" xpos="[param:xpos]" ypos="[param:ypos]" background="#2f3a8e" borderwidth="2" bordercolor="#000000" onclickup="[param:onclickup]">
<text name="[param:textname]" alias="{param:txtalias]" width="100%" height="100%" font="helvetica" size="20" color="#BFC8C3" text="[param:text]" alignment="center" align="center" valign="center"/>
<panel name="[param:webname]" alias="[param:webalias]" height="100%" width="100%" ypos="0" alpha="0">
<web name="web-panel" alias="[param:webpanelalias]" width="100%" height="100%" valign="top" url="about:blank"></web>
</panel>
</panel>
</class>

<class name="pager">
<panel name="[param:rowname]" width="100%" height="20%" background="#2f3a8e" borderwidth="1" bordercolor="#000000">
<image name="[param:imgname]" source="[param:source]" align="left" valign="center"></image>
<text name="[param:pagertxt]" width="100%" height="20%" color="#bfc8c3" size="12" valign="center" xpos="3%" text="[param:pagertxt]"></text>
</panel>

</class>
</classes>

<main>

<panel name="main" alias="MAIN" style="100">

<panel name="logo" alias="LOGO" width="100%" height="68.5%" valign="top" background="#000000">
<panel name="twitter" alias="TWITTER" height="6.5%" width="8%" align="right" valign="top" background="#000000" onclickup="twitter">
<image name="twitterlogo" alias="TWITTERLOGO" source="twitterlogo.png" align="center" valign="center" contain="yes"></image>
</panel>
<image name="logo" alias="LOGOIMG" source="bvnlogo.png" width="55%" height="90%" contain="yes" align="center" ypos="16%" cornerradius="10"/>
<text name="bvn" alias="BVN" width="100%" height="fit" font="helvetica" size="34" color="#BFC8C3" alignment="center" text="Blue Valley North" align="center" ypos="10%"/>
</panel>

<panel name="divbar" alias="DIVBAR" width="100%" height="1.5%" bottomof="logo" background="#c2cdbc" borderwidth="2" bordercolor="#000000">
</panel>

<object class="bpanelweb" panelname="website" panelalias="WEBSITE" txtalias="WEBTXT" align="left" ypos="70%" textname="webtxt" text="BVN Website" webname="bvnweb" webalias="BVNWEBPANEL" webpanelalias="BVNWEB" onclickup="bvnweb"></object>
<object class="bpanelweb" panelname="cal" panelalias="CAL" txtalias="CALTXT" xpos="33.33%" ypos="70%" textname="caltxt" text="Calendar" webname="webcal" webalias="WEBCAL" webpanelalias="CALWEB" onclickup="webcal"></object>
<object class="bpanelweb" panelname="news" panelalias="NEWS" txtalias="NEWSTXT" xpos="66.67%" ypos="70%" textname="newstxt" text="News and Events" onclickup="events">
<panel name="events" alias="EVENTS" width="100%" height="8%" xpos="0" ypos="0" background="#BFC8C3" borderwidth="1" bordercolor="#000000" alpha="0" onclickup="home">
<image name="home" source="closeicon.png" xpos="4" valign="center" contain="yes" onclickup="home"></image>
<text name="newstxt" alias="NEWSTXT" width="100%" height="100%" font="helvetica" size="28" color="#2f3a8e" alignment="center" text="News and Events " align="center" valign="center"/>
</panel>
<pager name="contents" alias="EVENTSPAGER" width="100%" height="92%" orientation="vertical" align="center" ypos="8%" paginate="no" alpha="0">
<object class="pager" rowname="row1" imgname="thumb1" source="" pagertxt="1"/>
<object class="pager" rowname="row2" imgname="thumb2" source="" pagertxt="2"/>
<object class="pager" rowname="row3" imgname="thumb3" source="" pagertxt="3"/>
<object class="pager" rowname="row4" imgname="thumb4" source="" pagertxt="4"/>
<object class="pager" rowname="row5" imgname="thumb5" source="" pagertxt="5"/>
<object class="pager" rowname="row6" imgname="thumb6" source="" pagertxt="6"/>
<object class="pager" rowname="row7" imgname="thumb7" source="" pagertxt="7"/>
<object class="pager" rowname="row8" imgname="thumb8" source="" pagertxt="8"/>
<object class="pager" rowname="row9" imgname="thumb9" source="" pagertxt="9"/>
<object class="pager" rowname="row10" imgname="thumb10" source="" pagertxt="10"/>
<object class="pager" rowname="row11" imgname="thumb11" source="" pagertxt="11"/>
<object class="pager" rowname="row12" imgname="thumb12" source="" pagertxt="12"/>
<object class="pager" rowname="row13" imgname="thumb13" source="" pagertxt="13"/>
<object class="pager" rowname="row14" imgname="thumb14" source="" pagertxt="14"/>
<object class="pager" rowname="row15" imgname="thumb15" source="" pagertxt="15"/>
<object class="pager" rowname="row16" imgname="thumb16" source="" pagertxt="16"/>
<object class="pager" rowname="row17" imgname="thumb17" source="" pagertxt="18"/>
<object class="pager" rowname="row19" imgname="thumb19" source="" pagertxt="19"/>
<object class="pager" rowname="row20" imgname="thumb20" source="" pagertxt="20"/>
</pager>
There is also a on the next line... Also in this app, when I try to add platform tags to change the font between Ipad and iphone, it starts doing all kinds of strange things like pager not working, alphas not working in some of the actions. Are platforms in classes a problem?
Sorry forgot to code block, there is a </object> on the next line.
I do not understand. Looking at the code you pasted here, I do not see an object living as a child of another object.
object class bpanelweb has multiple children from object class pager...
It looks like your 'contents' pager that contains all of the objects from the pager class is a sibling to your bpanelweb objects. Am I missing something here?
Marty had asked me to post this to the community after the advanced class last night... here is a shorter version...


<object class="bpanelweb" panelname="news" panelalias="NEWS" txtalias="NEWSTXT" xpos="66.67%" ypos="70%" textname="newstxt" text="News and Events" onclickup="events">
<panel name="events" alias="EVENTS" width="100%" height="8%" xpos="0" ypos="0" background="#BFC8C3" borderwidth="1" bordercolor="#000000" alpha="0" onclickup="home">
<image name="home" source="closeicon.png" xpos="4" valign="center" contain="yes" onclickup="home"></image>
<text name="newstxt" alias="NEWSTXT" width="100%" height="100%" font="helvetica" size="28" color="#2f3a8e" alignment="center" text="News and Events " align="center" valign="center"/>
</panel>
<pager name="contents" alias="EVENTSPAGER" width="100%" height="92%" orientation="vertical" align="center" ypos="8%" paginate="no" alpha="0">
<object class="pager" rowname="row1" imgname="thumb1" source="" pagertxt="1"/>
<object class="pager" rowname="row2" imgname="thumb2" source="" pagertxt="2"/>
<object class="pager" rowname="row3" imgname="thumb3" source="" pagertxt="3"/>
<object class="pager" rowname="row4" imgname="thumb4" source="" pagertxt="4"/>
<object class="pager" rowname="row5" imgname="thumb5" source="" pagertxt="5"/>
<object class="pager" rowname="row6" imgname="thumb6" source="" pagertxt="6"/>
<object class="pager" rowname="row7" imgname="thumb7" source="" pagertxt="7"/>
<object class="pager" rowname="row8" imgname="thumb8" source="" pagertxt="8"/>
<object class="pager" rowname="row9" imgname="thumb9" source="" pagertxt="9"/>
<object class="pager" rowname="row10" imgname="thumb10" source="" pagertxt="10"/>
<object class="pager" rowname="row11" imgname="thumb11" source="" pagertxt="11"/>
<object class="pager" rowname="row12" imgname="thumb12" source="" pagertxt="12"/>
<object class="pager" rowname="row13" imgname="thumb13" source="" pagertxt="13"/>
<object class="pager" rowname="row14" imgname="thumb14" source="" pagertxt="14"/>
<object class="pager" rowname="row15" imgname="thumb15" source="" pagertxt="15"/>
<object class="pager" rowname="row16" imgname="thumb16" source="" pagertxt="16"/>
<object class="pager" rowname="row17" imgname="thumb17" source="" pagertxt="18"/>
<object class="pager" rowname="row19" imgname="thumb19" source="" pagertxt="19"/>
<object class="pager" rowname="row20" imgname="thumb20" source="" pagertxt="20"/>
</pager>
</object>

Ok, I see now, the last line was missing before. Sorry.

Because classes are driving your object tags, it is certainly possible to explode code into an object within another object, however it will always create the object at the bottom of the z-order of the parent. So as a best practice this isn't something that we do. As classes get complex, it is hard to predict where the second object will live.

In this case you might be okay to leave it as is, but in other scenarios you probably could crash the app if the object builds a class that doesn't fit just right.

I would recommend that you take the pager and put in it your bpanelweb class and then call your pager class there so you only have one object tag in your main block. It is much more predictable.
I would have done that but not every bpanel needs or uses a pager, so that made me nervous.