Adobe Dreamweaver Forums



Last 10 THreads :         Creating a boundry in the stage... (Last Post : Rob Dillon - Replies : 1 - Views : 2 )           »          Re: Mouse capture won't activate (Last Post : robertnagle - Replies : 0 - Views : 1 )           »          help! my FB3 has gone insane! (Last Post : peteandrus - Replies : 0 - Views : 1 )           »          help! my FB3 has gone insane! (Last Post : peteandrus - Replies : 0 - Views : 1 )           »          How come the html is being displayed, and not the link (Last Post : Skaterstu - Replies : 0 - Views : 1 )           »          Another way to accomplish this (Last Post : Andy-K - Replies : 2 - Views : 3 )           »          HELP! Cannot upload files in DW CS4 (Last Post : dan@hoppernet.org - Replies : 6 - Views : 7 )           »          Adobe Flash 10 kills Wimpy (Last Post : m77ty8uu - Replies : 32 - Views : 208 )           »          How do I unlock all files in site at once (Last Post : Alan - Replies : 1 - Views : 2 )           »          Load library clip into target on stage (Last Post : NedWebs - Replies : 5 - Views : 8 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 10-09-2008, 07:41 PM
dalejoel
 
Posts: n/a
Diggs:
Default MXML Custom Component Instantiation Problem

Hi -

I have created a custom component in an MXML file based on a VBox that
contains another custom component.
Something like below (I will call it CustomVBox for illustrative purposes):
<!-- file name CustomVBox.mxml -->
<mx:VBox>
<CustomRow>
</CustomRow>
</mx:VBox>

Now - in an action script file I wish to create the CustomVBox:
var comp:CustomVBox = new CustomVBox().

The problem is that the CustomRow inside the CustomVBox component is now a
public member that my action script can refer to, but calling the constructor
will not instantiate the sub component. So if I wanted to set some property on
the inner CustomRow object, I get a null reference exception.

If within my action script I addChild(comp) first, that creates the child
components and I am okay. However, I want to be able to set all my properties
up front. So I could just save off any settings and use them when
createChildren() is called. But the CustomRow, being an mxml tag in my
CustomVBox mxml file, is still public and nothing prevents a user from
accessing it directly and getting the null reference before createChildren()
got called.

How do I prevent this? Am I forced to write it all in actionscript so that my
subcomponent can be made private or can I still write it in mxml and prevent
the null reference exception?

Thank you,
Joel




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-11-2008, 10:18 PM
wvxvw
 
Posts: n/a
Diggs:
Default Re: MXML Custom Component Instantiation Problem

You need to listen to flex event creationComplete, or override childrenCreated
protected UIComponent method to inform you on that occasion that all children
are created, or change creationPolicy to ContainerCreationPolicy.ALL (this will
ensure that children are built once you instantiate the component). However,
the last way isn't preferable because this will force your component into
creating children that may be invisible at the creation time.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 02:17 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk