[flexcoders] 32k problem

2005-08-10 Thread Mika Kiljunen










Im getting this again  Branch
between 46842 and 79852 around line 0 exceeds 32K span. 



There was a solution how you can find the branch in code
that caused this, but unfortunately I cant remember what it was and
where I found it. 



So, has anyone got the information on how to find the
branch in code that causes this?



-Mika









--
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



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  











RE: [flexcoders] 32k problem

2005-08-10 Thread Tracy Spratt










Mika, I have been wrestling with the 32k
issue for about 18 months, including banging on the MM folks on this list
mercilessly. If there was ever anything posted on this list (or anywhere
that is googlable), that would help find WHERE the problem is I probably would
have seen it. And it really mattered in the early days when I was still
working with architecture issues. I think the problem is that those
branch numbers refer to structures to far removed from the code we have written
to do us any good.



If adding the bogus code worked for you
then you probably dont really have any problem code and are just a
victim of the Flex compilers decisions. I agree, it is both funny
and stupid! By the way, next time you hit the 32k, just delete your bogus
code!



Tracy











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Mika Kiljunen
Sent: Wednesday, August 10, 2005
6:59 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] 32k
problem





I dont mean the ways to get around
it but a way to locate the actual problematic part in code so I can fix it!!



But since no one can remember the solution
to that, I got around it by adding bogus code (which is funny and stupid at the
same time).



-Mika











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Steven Webster
Sent: 10. elokuuta 2005 13:31
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] 32k
problem





There was a solution how you can find the branch in code
that caused this, but unfortunately I cant remember what it was and
where I found it. 





The solution is in the FAQ ;-)



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



Q: What does Branch
between ... and ... around line ... exceeds 32K
span mean and how do I get rid of it?

A: Don't panic. Your app is NOT too big for Flex to handle. True, the
32k limit is a real Flash Player limitation to the size of certain
structures like if blocks and for loops. But you don't really care
about that right now, because you don't have any direct control over
those things. Here is some information that will help you get back to
coding:

There are two main reasons you might the 32k issue. The primary cause,
and the one to address first, is the architecture of your application
code. The 32k error message asks you to refactor your code.
Refactoring is essentially the process of modifying the structure of
your source code while keeping the same functionality. In the Flex
world, this means moving some parts of the code out of a main file and
into separate components. One way to do this is to use custom mxml
components. So instead of, say, having several hundred lines of mxml in
a child container of a ViewStack, you put that mxml code into its own
component file, and have a single line in the ViewStack to reference it.
Do that for all the ViewStack children and 1000 lines of code can become
30. Decreasing the total number of visually rendered mxml tags in a
single file will help avoid the 32k limit. Another type of refactoring
is to move ActionScript code into its own class. Important note! Just
putting the AS code into a file and then using the #include directive or
the mx:Script source=filename to include the code will NOT
help with
the 32k problem. You MUST create a true AS class that contains the
functionality. Around two thousand lines of mixed mxml and AS code and
you are in danger of the 32k error. I have not found an upper limit
whatsoever to code length in a class.

The second cause of the 32k error is not your fault. During compile,
Flex generates AS code out of your mxml source. Then it compiles that
into the Flash swf. In that process it makes decisions on how to break
up your source and generate the AS class code. In Flex version 1.5, it
doesn't always make the right decision, and the result is the 32k error.
IF you are confident that you app is already efficiently
refactored,
and you suspect you might be at one of these boundary conditions, first
try compiling the app with ?debug=true in the url. If the app
compiles, then you are surely at a boundary condition. What is
happening is that debug adds code to your source during
generate/compile. This additional code causes Flex to change the
structure of the AS classes so that the 32k limit is not hit. Hmm, more
code? Yeah. Try just adding 50 or so lines of code, even if it is
bogus. Usually, this will get you working. Now, when you add more
real
code go on and remove the bogus stuff, you don't want it in your
production code!

A final hint. After hitting a 32k error, and trying one of the above
solutions, if you still get the error, delete the temporary generated as
code. It is located in ..\MyAppServer\flex(flexroot or contextroot)
\WEB- INF\flex\generated\*. You can delete all the folders safely (make
sure to restart your Flex server).

This can be an aggravating and somewhat scary problem, and it always
seems to happen just before