> You may find that the initialize method runs before you get a chance to set 
> acctName

You called init() from your the constructor, so it is called as soon as you do 
'new CreateAcctDialog()'. Since you have to "new" it somewhere before you can 
set acctDialog.acctName, the name was getting set too late and it was null when 
init() was called

Gordon Smith
Adobe Flex SDK Team

From: [email protected] [mailto:[email protected]] On Behalf 
Of fumeng5
Sent: Thursday, April 30, 2009 10:04 AM
To: [email protected]
Subject: [flexcoders] Re: Outputting a variable into htmlText





You are exactly right! It worked perfectly when I added a listener for the 
creationComplete event in my constructor and set the handler to be init.

I learned something new today. Thank you very, very much for your help.
--- In [email protected]<mailto:flexcoders%40yahoogroups.com>, 
"valdhor" <valdhorli...@...> wrote:
>
> I don't believe you need that. I do what you are doing all the time although 
> I don't do it in the init method (I am assuming you are calling the init 
> method on initialize of the component?). I would try calling it on 
> creationComplete (That's what I do). You may find that the initialize method 
> runs before you get a chance to set acctName.
>
>
> --- In [email protected]<mailto:flexcoders%40yahoogroups.com>, 
> "fumeng5" <fumeng5@> wrote:
> >
> > The String I'm constructing is inside a PopUp dialog bog. I set it from 
> > another component a la:
> >
> > private function createAcct():void {
> >
> > acctDialog.acctName = accountName;
> > PopUpManager.addPopUp(acctDialog,this as Canvas,true);
> > }
> >
> > The accessor methods for acctName look like this:
> >
> > private var _acctName:String;
> > public function set acctName(s:String):void{
> > acctName = s;
> > }
> > [Bindable]
> > public function get acctName():String{
> > return _acctName;
> > }
> >
> > And I set the content.htmlText property in the init() method when acctName 
> > is null. So, I think the solution is to use binding utils in the init() 
> > method, like this:
> >
> > BindingUtils.bindProperty(content,'htmlText',msgString);
> >
> > but I think I'm missing an argument in there...i think it needs 4 args.
> >
> > Thank you very much for your help.
> >
> >
> >
> >
> >
> > --- In [email protected]<mailto:flexcoders%40yahoogroups.com>, 
> > "valdhor" <valdhorlists@> wrote:
> > >
> > > How is acctName created?
> > >
> > >
> > > --- In [email protected]<mailto:flexcoders%40yahoogroups.com>, 
> > > "fumeng5" <fumeng5@> wrote:
> > > >
> > > > Ok, I see what you're saying. So here's the constructor for my 
> > > > component that is responsible for all this:
> > > >
> > > > public function CreateAcctDialog()
> > > > {
> > > > super();
> > > > init();
> > > > }
> > > >
> > > > ...and init():
> > > >
> > > > private function init():void
> > > > {
> > > > msgString = "<b>The account " + this.acctName + " has been created </b>"
> > > > }
> > > >
> > > > and the last part:
> > > > content.htmlText = msgString;
> > > >
> > > > This comes out as: The account null has been created.
> > > >
> > > > I thought the init() method would handle the proper setting of this 
> > > > var.....
> > > >
> > > >
> > > > --- In [email protected]<mailto:flexcoders%40yahoogroups.com>, 
> > > > "valdhor" <valdhorlists@> wrote:
> > > > >
> > > > > For the first part, you are setting the value of msgString during its 
> > > > > declaration. At this point acctName will be null. You would need to 
> > > > > declare msgString and then assign it in a creationComplete handler.
> > > > >
> > > > > Secondly, you can't do this in ActionScript:
> > > > >
> > > > > content.htmlText = "{msgString}"
> > > > >
> > > > > You have to do this:
> > > > >
> > > > > content.htmlText = msgString
> > > > >
> > > > > The "{}" syntax is to bind a variable in MXML.
> > > > >
> > > > > Also, For the above, the variable does not need to be bindable.
> > >
> >
>

Reply via email to