>500 lines in <fx:Script> and it all stops working - apache-flex

Well, it's a little ridiculous; and probably unbelievable, but when I have more than five hundred lines of actionscript in tags in my MXML FLEX Main.mxml, all syntax highlighting, error and syntax verification, error reporting, "Problems" pane, and even sometimes compilation fail. Upon removing any chunk of code, it works again.
I don't see why Adobe could release a product such as Flash Builder 4.5 Premium, have this big of a problem; and nobody notice. Therefore I believe the problem has to do with my computer, or my project; as there's now ay more people have had this happen if I can't even find it on Google.
Additionally, many objects that have been defined in the MXML properties above the code, even those in All States, are now showing as warning: Access of undefined property down the side of my document. However, these warnings are not showing up in the "Problems pane", and aren't even yellow squigly underlining the right sections of code to pertain to the message.
Steps I have taken to TRY and fix this:
I have tried restarting, as well as re-installing the IDE (Adobe Flash Builder 4.5).
I have tried creating a new project.
I have tried splitting my code into smaller .as files and including them.
I have tried compiling my application.
Nothing has worked, PLEASE HELP.
--
Edit 1: In response to the first answer, I have already tried increasing the memory allotted to Adobe Flash Builder 4.5 by editing the flashbuilder.ini and flashbuilderC.ini files in the main installation folder, it did not help; as my heap (heap display in bottom right) never uses more than 128MB anyways (even during compile) this did not fix anything.

You can try the following steps:
You can try to allocate additional memory for your Eclipse/Flash Builder by editing of eclipse.ini.
You can try to compile your project from the command line using mxmlc compiler and compare result.
You can try to split your code but not using just code including (which you should avoid forever) but extraction subcomponents (keywords are refactoring, OOP, composition etc.).
And of course you can use all of these advices together :)
Anyway you should avoid large code listings in a Script block of a single MXML file. The main purpose of Script block of MXML is to have simple and clear code with event handlers and required fields declarations.

Related

XCode 4 breakpoints not breaking at correct line

My breakpoints have stopped working properly in the latest XCode 4 release. With no change to the project settings, the breakpoints no longer break at the line they are set.
For instance, in one function I can set a breakpoint anywhere within it's body, but the code will always break at the last line of the function.
In another instance, I can set a breakpoint anywhere in one function and the code will break at a line in the middle of a different function in the same file! Tracing through after the break shows that it did break in the wrong place and it's not just a file / debugger sync issue.
I have no idea why this has started. It did however seem to start on new breakpoints while old ones worked. Any new breakpoints I add break in the wrong place. And recently, some files now don't even break at all! I can only assume the breakpoint is so wrong it's moved into code that's not called. I have done numerous internet searches and forum searches for this problem, and although I have found people with similar issues, there was either no solution or the solution listed (rebooting device, swapping debug output, turning off optimization etc.) haven't worked for me.
It is worth mentioninig I'm mostly coding in C++ using .mm files. For the past year of development in XCode 3, and for the last few months in XCode 4 things have been fine! I have debug set up correctly. No optimization on a debug run, no dead code stripping and I'm using the LLVM compiler 2.0 with DWARD with dSYM debug file. However, changing these values makes no difference.
Please help, it's driving me mad!!
An update to this. It's started happening again on a brand new machine with a fresh Lion and xcode install. The whole editor is out of whack. Example below of the errors appearing on the wrong lines.
From what I've read all around, Xcode tend to get confused with breakpoints and the way to get rid of the out-of-sync problem is to clean the "Derived Data"; two ways of cleaning it so far I've found (instructions are valid for Xcode 4.x) :
a) go in the organiser, under the Projects, choose your project and hit that delete on the Derived Data
or
b) go in the Product menu, hold the ALT button on the keyboard and observe that the menu are changing... so the clean transform to "Clean Build Folder..."
With-in "Build Settings" under the project target change the "Optimization Level" for "Debug" to "None".
I found that this fixed the issue for me.
I have fixed this, although I haven't found the root cause.
I removed the references from the project for the files that were not working with breakpoints. I then did a full clean and went into the folders and deleted any build and temporary data. I then opened the project bundle and deleted all data except for the project file itself. I then compiled so it threw up errors due to the missing files. I then put the files back in the project.
Now, the exact same files work fine with breakpoints!
No idea why but happy it's fixed.
Have you cleaned your targets? Shift-Cmd-K.
This started happening to me after I upgraded to XCode 4. I just deleted all breakpoints, did a clean, then re-added my breakpoints. Seems to work OK now.
I have figured out why this happens now. As mentioned in one of the replies you can fix it by deleting the derived data. This will always fix the problem. The editor for some reason loses it's relationship between the source code and the markup of the code it uses to cross reference breakpoints and errors etc. Deleting the derived data forces it to recreate this.
I believe that this only happens with files using C or C++ code. Apple seem to ignore C++ developers on iOS. I know a lot of professional game developers and every single one uses C++ to write games. Apple's lack of support is annoying.

How do I display content assist in flex builder for all classes?

I have a components and classes project library. Within the library, flex builder only seems to display content/code assist options for top level classes (e.g. arguments, Array) but not other classes such as VBox. Also, within the non top level classes, class properties are not provided by content assist.
In my other flex projects in the workspace, content assist works fine.
Any help would be greatly appreciated!
Flex / Flash Builder is often inconsistent in stuff like this; but I have never seen the exact situation you describe.
Have you tried closing down and relaunching Flex Builder?
Have you tried launching Flex Builder with the '-clean' attribute?
Have you tried cleaning your workspace?
Are you sure you do not have a syntax error somewhere causing issues? Are all the classes in the library included in your library class? Sometimes error don't show up if the class is not used, and therefore not compiled into the file SWC.
Did you save your source files? I don't think Eclipse updates its index until you save - so, if you just wrote class X with function Y, but didn't save X.as, then Eclipse won't know what to do with X.Y(...
Sometimes when I've run into the problem you're describing, it's been because FB wasn't able to determine what type of object I was using (for example, obj["toto"] = ?).
Another idea may be to update your version of eclipse ("Software Updates" or something like that under the Help menu).
Finally, there's an annoying issue that happens to me sometimes where the content assist will appear for about half a second, then disappear like the window tried to scroll and lost the pop-up. Do you get anything when you press Ctrl-Space?

Flash Builder keeps losing my imported classes...arghh

I've been having this really annoying thing happen the past few days, that has happened before but not as frequently. I create a project in Flash Builder, import some classes, and then on occasion it keeps erasing those classes. So then I get errors in a lot of my datatypes, have to go back through my document and retype the datatype so that it reimports the class.
What could be causing this? I know flash builder can be a bit buggy at times, but wasn't sure if someone else has had this problem and knows what might be causing it.
I haven't worked that much with flash builder yet, but I have had it clean up unused imports for me rather unexpectedly when I'm refactoring code. i.e cut a section of code from one section - flash builder cleans up imports - then when I paste the code back somewhere else, I'm missing the necessary imports.
I think if you go to:
Window > Preferences > Flash Builder > Editors > ActionScript
You can disable "remove unused imports" and see if this fixes your problem.
This was a known bug in the FB4 betas. Make sure you are using the release version of FB4.

Understanding Flash SWC's imported into Flex Builder 3 and key framed animation

I am trying to understand what is going on in a SWC that I am importing from Flash CS4 into Flex Builder 3. Specifically I am using a SWC supplied by a Designer as the animation for a custom preloader (a subclassed DownloadProgressBar).
The issue I am trying to understand is, once the FlexEvent.INIT_COMPLETE is fired, I cleanup by removing the swc by running this :
removeChild(myPreloader);
myPreloader = null;
though even after I have removed this (which is successful, as I have checked by comparing this.numChildren before and after the call) the key framed animation still continues to run (not visibly). This has been detected by the Designer placing a trace in the time line of the animation (in Flash).
Can anyone tell me why is it, that even after I have removed the animation from the subclassed DownloadProgressBar, it still keeps running ?
Also, is it standard practice when importing SWCs to manage the cleanup of resources from the Flash side of things (much like releasing memory in obj-c). I find it counter intuitive that removing the child from the Flex side does not stop the animation.
Any clues to this would be greatly appreciated.
Basically, your SWC file is nothing more than a ZIP containing a SWF. So what you're doing is removing a MovieClip from the stage, but it is NOT stopping or unloading it. You might want to try
myPreloader.stop();
to stop the animation and
myPreloaderLoader.unload();
after you removed the item from the stage to free up memory.
Beware, though: the Flash Player garbage collection does not always work correctly. If there is any kind of ActionScript running within myPreloader, chances are it will continue to run, and it will be ignored during garbage collection. It is usually best to include a clear() or destroy() method for all AS classes and call it upon Event.REMOVED_FROM_STAGE.
This would have to be done by your designer colleague, but in my experience it is the cleanest procedure.

Difference in building swf through FlexBuilder and mxmlc(ANT build)

Will there be any difference between the swf generated by Flex Builder and mxmlc?
In my application, there is a page with certain fields to be filled in. Upon clicking a button, it opens up a popup. Upon selecting an option in the popup and clicking OK, it makes a request to the server, fetches some data and adds it to the main page.
When the swf is generated by the Flex Builder, everything works just fine. But when the same is generated using an ANT script, upon selecting a value from the popup, I get an error.
[ResultEvent messageId="8638F71F-BCB8-ACFD-E577-B6F97156374D" type="result" bubbles=false cancelable=true eventPhase=2]
This happens only when ANT is used for building the swf.
<mxmlc output="$swf_name" file="$mxml_name" allow-source-path-overlap="true" optimize="true">
I'm using the Cairngorm framework, and the swc is generated before hand.
<compc output="$swc_name">
Also there is a size difference between the final outputs.
The swf is 802 KB when generated from Flex Builder whereas its only 788 KB when generated using ANT. I haven't made any config changes in Flex Builder. It uses the default values(which I believe is optimized) for generating swf.
Am I doing anything wrong with ANT scripts? Do I need to use any different arguments so that I can remove the error which I get only when using the swf built by mxmlc?
Please provide your suggestions.
There could be differences between your configurations; have a look here -- this Adobe KB article might help you determine whether there are, and if so, what they might be so you can correct them:
http://kb2.adobe.com/cps/404/kb404341.html
I hesitate to mention this second part, because I haven't often toggled between the two compilers (I generally stick with one or the other), but I can say that I've noticed this issue before myself, and as I recall there was a brief mention, in Ely Greenfield's talk at MAX this past month, about a push with Flex 4 to achieve parity between Flex Builder's compilers and their SDK counterparts -- suggesting that such parity doesn't quite exist today. So while I don't have much in the way of details on that, it does seem there are some differences between the two.
Wish I could be more helpful on that -- maybe someone with a little more detail could chime in on it.

Resources