Archive for the ‘ AS2 ’ Category

OSX 5005:Unknown error optimizing byte code

Working in a large AIR project, the flash compiler give me this strange error:

1
5005:Unknown error optimizing byte code

To avoid it , we must increase the memory of the compilator by creating a file in:

1
~/.MacOSX/environment.plist

and put this text in it:

1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>JAVA_TOOL_OPTIONS</key>
<string>-Xmx512m</string>
</dict>
</plist>

If you use flash CS5 also edit this file:

1
~/Library/Application Support/Adobe/Flash CS5/en_US/Configuration/ActionScript3.0/jvm.ini

Then change -Xmx128m to -Xmx512m

AS3 Condicional Switch Stament

Imagine we can use switch staments with conditional operators other then strict equality.

This way we can do a code like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var value:int = 2;
switch(value){
    case < 1:
        trace("Value is less than 1");
        break;
    case 2:
        trace("Value definitely equals 2");
        break;
    case >= 3:
        trace("Value is greater than or equal to 3");
        break;
    case > 1 && < 3:
        trace("Value is greater than 3 and less than 5");
        break;
    case !== 5:
        trace("Value definitely doesn't equal 5");
        break;
}

Navigating the web I have find one solution:

1
2
3
4
5
6
7
8
9
10
11
12
var value:int = 2;
switch (true) {
    case value < 1:
        trace("Value is less than 1");
    break;
    case value == 1:
        trace("Value equals 1");
    break;
    case value > 1:
        trace("Value is greater than 1");
    break;
}

innerHTML removes attribute quotes in Internet Explorer

After losing 2 hours for an unknown XML parsing error, I have discovered that the results of innerHTML in Internet Explorer are wrong.

1
2
3
4
5
6
7
8
// Original Source code of document
<div id="container">container</div>
// Result of innerHTML in document.getElementById('content')

//Firefox
<div id="container">container</div>
//Internet Explorer
<DIV id=container>container</DIV>

The solution: innerXHTML

1
2
var container = document.getElementById('container');
var code = innerXHTML(container);

Download innerxhtml