If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
So it would turn out that flash CS4 cannot handle large projects out of the box. It took me a while to find the solution that is why I am republishing. This fix was originally posted on negush Their post was originally about fixing the 5005: Unknown error optimizing byte code. But what I found out later after swapping to a new macihine is that the fix below also fixes the “You cannot debug this SWF because it does not contain ActionScript”. What I think happens is the compiler runs out of memory in a big project and instead of erroring shows you the stuipid non helpful error.
But the fix below should solve the two issues (5005: Unknown error optimizing byte code and You cannot debug this SWF because it does not contain ActionScript)
Fix - windows (sorry i dont know how to change environmental vars on mac)
my computer -> properties -> advanced -> environment vars -> then make a new var like this
JAVA_TOOL_OPTIONS
and its value
-Xmx128M or -Xmx256M
Another solution on the web is to delete the .aso files generated by Flash (Control -> Delete ASO Files) .
If someone knows how to set the fix on a mac can they please post a comment
Now one of the biggest features of as3 is the management of memory within flash and flex.
In my experience event listeners are the source of about 95 percent of all memory leaks. This is because event listeners are often forgotten by developers, which normally results in the listener never being removed from memory.
This is where weakly referenced event listeners come into their own.
Weakly references to objects that are not counted by the Garbage Collector in determining an object’s availability for collection. So if you forget to remove the listener you wont stop the Garbage Collector’s ability to collect the object and freeing your memory. Yay…
So from that stand point alone I suggest that you use Weakly reference Event listeners as standard practice.
To make your event listener weakly then just set the fith param in the addEventListner to true. See code below
stage.addEventListener(Event.CLICK, handleClick, false, 0, true);
Nod to the wondeful gSkinner for this.
Returns the number of words in a string.
function wordcount(string:String):Number {
var wrdArray:Array = string.split(" ");
for (var i = wrdArray.length; i>0; i--) {
if (wrdArray[i] == "") {
wrdArray.splice(i,1);
}
}
return wrdArray.length;
}
trace(wordcount("This will count the number of words"));A While ago we had an interesting problem with file flash uploaders on Macs. It turns out it doesn’t work. But we have found the way. So here is how we solved the undocumented feature
1. Firstly ensure that you explicitly load the cross domain policy file.
2. Make sure you escape all the characters, Macs hate spaces.
3. And the most important you need to send empty response from upload server-side script.
In php, you would just do
echo (”");
after file-upload code. In ASP, you can do
Response.Write (”").
In Java servlet, you can do:
response.getWriter().println(”");
response.getWriter().flush();
That’s all, now onComplete event should trigger on Mac’s Adobe Flash Player 8.
But if sending “” dosent work try “ “ or “1” – we found that sending 1 was the best option.
Hope this shines some light on a frustrating problem
In AS3 mouse event a handled differently than in AS2. Here is the general procedure for adding a mouse up event to a object.
Mouse Event - up
// you will need a movieclip on the stage with an instance name of cir_mc
// or just download the file above (www.flashcs.org)
cir_mc.addEventListener(MouseEvent.MOUSE_UP, clickListner);
function clickListner(ev:MouseEvent):void{
trace(”Mouse Up”);
}
I had this problem and thought you would all like to know….. I was trying to load a local xml doc and this solution worked for me.
Posted on January 11th, 2007 by polyGeek
Error (#2148) Loading XML with Flex2
[RPC Fault faultString=”Error #2148: SWF file file:///C:/Documents and Settings/…/My Documents/xmlParsing/bin/xmlParsing.swf cannot access local resource Blades.xml. Only local-with-filesystem and trusted local SWF files may access local resources.” faultCode=”InvokeFailed” faultDetail=”null”]
If I go into the bin folder and launch the SWF directly then everything loads and works correctly. That right off is a tip that it’s probably a security issue. Sure enough. With a little research I found it.
So my arguments read: -locale en_US -use-network=false
It would seem that this setting has to be made for each project.
Stupid security settings.
When I Googled this problem I only got three hits back. My guess is that this will be a common problem so it wouldn’t hurt for others to duplicate this solution to make it easier for others to find.