Re: initialize vs. construct/init...Re: [flexcoders] constructObject2() vs. init()? (Flex 1.5)

2006-07-28 Thread G
If I haven't bored you yet, I would love to tell you
exactly what the issue is.  For a long time now we've
occasionally seen very strange behavior.  As I
described before, you'll write something, get
everything working perfectly, then do a clean build
before deploying and suddenly something disappears. 
The problem is clearly that some properties are not
being initialized properly.  I can make it happen
regularly and predictably right now.  I do a clean
build, and one component's x  y are not set, so they
show up in the upper left.  Then I touch that file
(I put the line if (false) true; in it), and now it
works.

There are two theories here in the office.  One is
that there is a compiler bug in flex so that bindings
are not always properly recognized.  That's the old
pre-me theory.

My theory is that there is no problem with flex, but
that we are not properly initializing variables, and
that certain changes get made during initialization
under the radar of the binding mechanism.

First, it is easy to mistakenly break binding:

MyFirstObject initialize=handleInit() 
mx:Script
public var innerWidth: Number;
public function handleInit() {
innerWidth=myOtherObject.otherWidth;
}
/mx:Script

mx:Image width={innerWidth} /
/MyFirstObject

MyOtherObject initialize=handleInit() 
mx:Script
public var otherWidth: Number;
public function handleInit() {
otherWidth=55;
}
/mx:Script
/MyOtherObject

Width in the Image component is properly bound to
innerWidth--any time innerWidth changes, so should
width.  The problem is, innerWidth only changes one 
time, in handleInit, when it is set, not bound,
to MyOtherObject.otherWidth.  If
MyFirstObject.handleInit() is called before
MyOtherObject.handleInit(), innerWidth will be
undefined, and never changed again.

The second issue, I believe, is that the bindings are
only executed at a particular time during the
initialization process.  (Specifically, in
constructObject2, after createChildren.)  It is
possible, as I said, to get that out of order so that
the binding mechanism fires too soon, and not again.

So anyway, those are the two competing theories around
here: compiler bug, or subtleties in initialization
order that we do not appreciate.

Either way, I believe it is clear that binding is not
as robust as we'd wish, during initialization.  And at
any rate, understanding better how something works is
always a good thing!

Greg




--- JesterXL [EMAIL PROTECTED] wrote:

 2 things to do to ensure you're not nuts.
 
 1. Add recompile=true to the end of the URL string.
  Slows compiling, but 
 it's worth the piece of mind.
 
 2. Delete generated everytime you want to be sure
 your changes are in fact 
 taking.  Mine's here for Flex 1.5:

C:\JRun4\servers\starExhibits\cfusion-ear\cfusion-war\WEB-INF\flex\generated
 
 LOL Royal... AWESOME.  Whew, that made my
 Thursday.  Mmmm, tasty 
 burger
 
 First off, bindings are supposed to free you from
 initialization worries. 
 Here's how it was in Flash:
 - capture data in member var
 - create asset
 - wait a frame
 - set data
 - delete member var
 - repeat process in convulted way
 
 In Flex?  Bind value in View and it'll work when
 she's created.  Pimp!
 
 I'm sorry to hear it's not working that way for you.
  Here's the rundown.
 
 - init
 - createChildren
 - initial drawing
 * initialize is before everything is done drawing
 - createChildren is the last event fired when
 everyone and their mom is 
 ready
 
 There is a good rundown of this on Adobe's DevNet
 site.  If you want the 
 link, I can go find; it's a pretty good explanation.
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




initialize vs. construct/init...Re: [flexcoders] constructObject2() vs. init()? (Flex 1.5)

2006-07-27 Thread G
 However, you're better off just have your initialize
 event call a function 
 in your MXML and do non-GUI related stuff there.

Are you sure about that?  That seems to be exactly the
source of our problems.  If we initialize values in
the initialize handler, it seems they are being
initialized too late, and values end up not being
properly set.



 
 - Original Message - 
 From: G [EMAIL PROTECTED]
 To: flexcoders@yahoogroups.com
 Sent: Thursday, July 27, 2006 3:25 PM
 Subject: [flexcoders] constructObject2() vs. init()?
 (Flex 1.5)
 
 
 Quick question:  What is the relationship between
 constructObject2 and init?  The document I found on
 creating components does not mention
 constructObject2,
 but the flex compiler seems not to allow overriding
 of
 init() (in an mxml file).
 
 But init() does not take parameters.  Does one call
 the other?  Are they analogous for different
 situations?
 
 Thanks,
 
 Greg
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam
 protection around
 http://mail.yahoo.com
 
 
 --
 Flexcoders Mailing List
 FAQ:

http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives:

http://www.mail-archive.com/flexcoders%40yahoogroups.com
 Yahoo! Groups Links
 
 
 
 
 
 
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: initialize vs. construct/init...Re: [flexcoders] constructObject2() vs. init()? (Flex 1.5)

2006-07-27 Thread JesterXL
Of course I'm not sure.  What are you initializing, and who is expecting 
them to be initialized?

- Original Message - 
From: G [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Thursday, July 27, 2006 3:51 PM
Subject: initialize vs. construct/init...Re: [flexcoders] constructObject2() 
vs. init()? (Flex 1.5)


 However, you're better off just have your initialize
 event call a function
 in your MXML and do non-GUI related stuff there.

Are you sure about that?  That seems to be exactly the
source of our problems.  If we initialize values in
the initialize handler, it seems they are being
initialized too late, and values end up not being
properly set.




 - Original Message - 
 From: G [EMAIL PROTECTED]
 To: flexcoders@yahoogroups.com
 Sent: Thursday, July 27, 2006 3:25 PM
 Subject: [flexcoders] constructObject2() vs. init()?
 (Flex 1.5)


 Quick question:  What is the relationship between
 constructObject2 and init?  The document I found on
 creating components does not mention
 constructObject2,
 but the flex compiler seems not to allow overriding
 of
 init() (in an mxml file).

 But init() does not take parameters.  Does one call
 the other?  Are they analogous for different
 situations?

 Thanks,

 Greg

 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam
 protection around
 http://mail.yahoo.com


 --
 Flexcoders Mailing List
 FAQ:

http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives:

http://www.mail-archive.com/flexcoders%40yahoogroups.com
 Yahoo! Groups Links









__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: initialize vs. construct/init...Re: [flexcoders] constructObject2() vs. init()? (Flex 1.5)

2006-07-27 Thread G
The code is too complicated to summarize--there are so
many interconnections it would take you days to
untangle (it has me!).  For a long time we've
encountered what we thought was a compiler bug where
the order of compilation would change the behavior of
the application.  That is, if we deleted everything
and compiled from scratch, some binding would not
execute, and some component would not display.  Then
if we simply touched the code of the disappearing
component, it would show up!  Apparently the only
difference is the order that things are
compiled/linked.

I have come to believe in the last few days that it's
not a compiler bug, but a simple
order-of-initialization problem.  One needs to
understand very well the order of initialization,
invalidation, and so on, and to this point we've been
blissfully unaware of it.

Anyway, that's why I'm investigating constructObject2
and init now--trying to get a handle on it.  But as
with so many things in the documentation, things in AS
and Flex are done slightly differently, but with no
acknowledgement of the differences.  They got the same
shit over there we got over here, it's just there it's
a little different.  I'm trying to order a Royal with
Cheese, reading from the American menu.


Greg

--- JesterXL [EMAIL PROTECTED] wrote:

 Of course I'm not sure.  What are you initializing,
 and who is expecting 
 them to be initialized?
 
 - Original Message - 
 From: G [EMAIL PROTECTED]
 To: flexcoders@yahoogroups.com
 Sent: Thursday, July 27, 2006 3:51 PM
 Subject: initialize vs. construct/init...Re:
 [flexcoders] constructObject2() 
 vs. init()? (Flex 1.5)
 
 
  However, you're better off just have your
 initialize
  event call a function
  in your MXML and do non-GUI related stuff there.
 
 Are you sure about that?  That seems to be exactly
 the
 source of our problems.  If we initialize values in
 the initialize handler, it seems they are being
 initialized too late, and values end up not being
 properly set.
 
 
 
 
  - Original Message - 
  From: G [EMAIL PROTECTED]
  To: flexcoders@yahoogroups.com
  Sent: Thursday, July 27, 2006 3:25 PM
  Subject: [flexcoders] constructObject2() vs.
 init()?
  (Flex 1.5)
 
 
  Quick question:  What is the relationship between
  constructObject2 and init?  The document I found
 on
  creating components does not mention
  constructObject2,
  but the flex compiler seems not to allow
 overriding
  of
  init() (in an mxml file).
 
  But init() does not take parameters.  Does one
 call
  the other?  Are they analogous for different
  situations?
 
  Thanks,
 
  Greg
 
  __
  Do You Yahoo!?
  Tired of spam?  Yahoo! Mail has the best spam
  protection around
  http://mail.yahoo.com
 
 
  --
  Flexcoders Mailing List
  FAQ:
 

http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Search Archives:
 

http://www.mail-archive.com/flexcoders%40yahoogroups.com
  Yahoo! Groups Links
 
 
 
 
 
 
 
 
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam
 protection around
 http://mail.yahoo.com
 
 
 --
 Flexcoders Mailing List
 FAQ:

http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives:

http://www.mail-archive.com/flexcoders%40yahoogroups.com
 Yahoo! Groups Links
 
 
 
 
 
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: initialize vs. construct/init...Re: [flexcoders] constructObject2() vs. init()? (Flex 1.5)

2006-07-27 Thread JesterXL
2 things to do to ensure you're not nuts.

1. Add recompile=true to the end of the URL string.  Slows compiling, but 
it's worth the piece of mind.

2. Delete generated everytime you want to be sure your changes are in fact 
taking.  Mine's here for Flex 1.5:
C:\JRun4\servers\starExhibits\cfusion-ear\cfusion-war\WEB-INF\flex\generated

LOL Royal... AWESOME.  Whew, that made my Thursday.  Mmmm, tasty 
burger

First off, bindings are supposed to free you from initialization worries. 
Here's how it was in Flash:
- capture data in member var
- create asset
- wait a frame
- set data
- delete member var
- repeat process in convulted way

In Flex?  Bind value in View and it'll work when she's created.  Pimp!

I'm sorry to hear it's not working that way for you.  Here's the rundown.

- init
- createChildren
- initial drawing
* initialize is before everything is done drawing
- createChildren is the last event fired when everyone and their mom is 
ready

There is a good rundown of this on Adobe's DevNet site.  If you want the 
link, I can go find; it's a pretty good explanation.






- Original Message - 
From: G [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Thursday, July 27, 2006 5:22 PM
Subject: Re: initialize vs. construct/init...Re: [flexcoders] 
constructObject2() vs. init()? (Flex 1.5)


The code is too complicated to summarize--there are so
many interconnections it would take you days to
untangle (it has me!).  For a long time we've
encountered what we thought was a compiler bug where
the order of compilation would change the behavior of
the application.  That is, if we deleted everything
and compiled from scratch, some binding would not
execute, and some component would not display.  Then
if we simply touched the code of the disappearing
component, it would show up!  Apparently the only
difference is the order that things are
compiled/linked.

I have come to believe in the last few days that it's
not a compiler bug, but a simple
order-of-initialization problem.  One needs to
understand very well the order of initialization,
invalidation, and so on, and to this point we've been
blissfully unaware of it.

Anyway, that's why I'm investigating constructObject2
and init now--trying to get a handle on it.  But as
with so many things in the documentation, things in AS
and Flex are done slightly differently, but with no
acknowledgement of the differences.  They got the same
shit over there we got over here, it's just there it's
a little different.  I'm trying to order a Royal with
Cheese, reading from the American menu.


Greg

--- JesterXL [EMAIL PROTECTED] wrote:

 Of course I'm not sure.  What are you initializing,
 and who is expecting
 them to be initialized?

 - Original Message - 
 From: G [EMAIL PROTECTED]
 To: flexcoders@yahoogroups.com
 Sent: Thursday, July 27, 2006 3:51 PM
 Subject: initialize vs. construct/init...Re:
 [flexcoders] constructObject2()
 vs. init()? (Flex 1.5)


  However, you're better off just have your
 initialize
  event call a function
  in your MXML and do non-GUI related stuff there.

 Are you sure about that?  That seems to be exactly
 the
 source of our problems.  If we initialize values in
 the initialize handler, it seems they are being
 initialized too late, and values end up not being
 properly set.



 
  - Original Message - 
  From: G [EMAIL PROTECTED]
  To: flexcoders@yahoogroups.com
  Sent: Thursday, July 27, 2006 3:25 PM
  Subject: [flexcoders] constructObject2() vs.
 init()?
  (Flex 1.5)
 
 
  Quick question:  What is the relationship between
  constructObject2 and init?  The document I found
 on
  creating components does not mention
  constructObject2,
  but the flex compiler seems not to allow
 overriding
  of
  init() (in an mxml file).
 
  But init() does not take parameters.  Does one
 call
  the other?  Are they analogous for different
  situations?
 
  Thanks,
 
  Greg
 
  __
  Do You Yahoo!?
  Tired of spam?  Yahoo! Mail has the best spam
  protection around
  http://mail.yahoo.com
 
 
  --
  Flexcoders Mailing List
  FAQ:
 

http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Search Archives:
 

http://www.mail-archive.com/flexcoders%40yahoogroups.com
  Yahoo! Groups Links
 
 
 
 
 
 
 


 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam
 protection around
 http://mail.yahoo.com


 --
 Flexcoders Mailing List
 FAQ:

http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives:

http://www.mail-archive.com/flexcoders%40yahoogroups.com
 Yahoo! Groups Links








__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders