NeuroAgent

How to Clear Flash CS4 Compiler Cache After Class Relocation

Learn how to clear Flash CS4 compiler cache when class namespace relocation causes persistent old references. Complete guide with manual methods, rebuild strategies, and preventative measures.

Question

How to clear Flash CS4 compiler cache when class namespace relocation causes old class references to persist?

I’m experiencing an issue in Flash CS4 where I moved a class named Jenine from one namespace to another. Despite updating all references, the compiler continues to use the old class definition. When I create a new instance of the class:

actionscript
var jenineInstance:Jenine = new Jenine();
trace(getQualifiedClassName(jenineInstance));

It still returns the old namespace (com.oldnamespace.subspace::Jenine) instead of the new one (com.newnamespace.subspace::Jenine). I’ve tried deleting all references to the old class, but the compiler continues to include it in the compiled SWF. How can I clear whatever cache the Flash compiler is using to resolve these outdated class references?

NeuroAgent

Clearing the Flash CS4 compiler cache when dealing with persistent old class references after namespace relocation requires several approaches including manual cache deletion, project rebuilding, and compiler configuration adjustments. The issue occurs because Flash CS4 maintains cached class definitions that need to be explicitly removed to force the compiler to recognize the relocated class in its new namespace.

Contents

Understanding the Flash CS4 Cache System

Flash CS4 utilizes a sophisticated caching mechanism to improve compilation performance by storing previously compiled class definitions. When you relocate a class namespace, the compiler may continue referencing the cached version rather than scanning for the updated definition. This caching system includes:

  • Class definition cache: Stores compiled bytecode for classes
  • Import cache: Maintains namespace-to-class mappings
  • Symbol cache: Keeps track of library symbols and their associated classes
  • Dependency cache: Records relationships between classes and their dependencies

The cache persists even after deleting source files because it’s stored in separate system directories, not within your project folder. This is why simply removing old references doesn’t resolve the issue - the compiler finds the cached version first.

Manual Cache Clearing Methods

Delete User-Specific Cache Files

The most reliable method is to manually locate and delete the Flash CS4 cache directories:

  1. Close Adobe Flash CS4 completely before attempting to delete cache files
  2. Navigate to your user profile directory:
    • Windows: C:\Users\[YourUsername]\AppData\Local\Adobe\Flash CS4\
    • Mac: /Users/[YourUsername]/Library/Application Support/Adobe/Flash CS4/
  3. Delete the following folders:
    • Configuration/ASClasses/
    • Configuration/Classes/
    • Configuration/ActionScript 3.0/
    • en_US/Configuration/ActionScript 3.0/

Clear Project-Specific Cache

For targeted clearing within your specific project:

  1. Locate your FLA file and close it in Flash CS4
  2. Delete these files/folders in your project directory:
    • .DS_Store (Mac only)
    • Thumbs.db (Windows only)
    • Any *.swf files that might contain cached references
  3. Use the “Clean Project” option:
    • Go to File > Publish Settings
    • Click the Clean button to remove temporary files

Registry/Preferences Reset

For more persistent issues, you may need to reset Flash CS4 preferences:

  1. Close Flash CS4
  2. Delete the preferences file:
    • Windows: C:\Users\[YourUsername]\AppData\Roaming\Adobe\Flash CS4\Preferences\
    • Mac: /Users/[YourUsername]/Library/Preferences/Adobe Flash CS4/
  3. Restart Flash CS4 - it will recreate default preferences

Project Rebuild Strategies

Complete Project Rebuild

A systematic rebuild approach can resolve cached reference issues:

  1. Save and close all files in Flash CS4
  2. Delete all compiled output:
    • Remove all .swf files from your project
    • Delete any *.swc files
  3. Use the “Clean All” option:
    • Right-click your project in the Project panel
    • Select Clean or Clean All options
  4. Recompile from scratch:
    • Close and reopen the FLA file
    • Press Ctrl+Shift+F12 (Windows) or Cmd+Shift+F12 (Mac) to republish

Class File Relocation Best Practices

When moving classes between namespaces:

  1. Use the “Move Class” feature:
    • Right-click the class file in Flash CS4
    • Select Refactor > Move Class
    • Follow the wizard to relocate the class
  2. Verify namespace updates:
    • Check all import statements in your project
    • Update any package declarations in the class file
  3. Force recompilation:
    • Modify the class file slightly (add a temporary comment)
    • Save and republish to ensure cache invalidation

External Library Management

If using external libraries or SWC files:

  1. Regenerate SWC files after namespace changes
  2. Update library paths in the FLA file:
    • Go to File > Publish Settings > Flash
    • Click Settings next to “ActionScript 3.0”
    • Verify library paths point to correct namespaces
  3. Clear library cache by deleting temporary SWC files

Compiler Configuration Solutions

ActionScript 3.0 Settings Adjustment

Configure the compiler to handle namespace changes more effectively:

  1. Access compiler settings:
    • File > Publish Settings > Flash
    • Click Settings button in ActionScript 3.0 section
  2. Adjust compiler options:
    • Enable “Strict Mode” to catch namespace mismatches
    • Set “Warnings” to “Verbose” for detailed error messages
    • Consider enabling “Optimize” to force recompilation
  3. Update source path mappings:
    • Ensure source paths point to the new namespace locations
    • Remove old namespace paths from the configuration

Custom Build Script Implementation

Create an automated build script to regularly clear cache:

actionscript
// Build script to clear cache before compilation
function clearAndBuild() {
    // Clear temporary files
    var tempDir = File.createTempDirectory();
    tempDir.deleteDirectory();
    
    // Force recompilation
    fl.publishDocument(fl.getDocumentDOM());
}

// Execute on build
clearAndBuild();

Compiler Arguments for Cache Control

Use specific compiler arguments to control caching behavior:

-cache=false -strict=true -warnings=true -source-path+=new_namespace_path

Add these arguments in the compiler settings by editing the “Additional compiler arguments” field.

Preventative Measures for Future Relocations

Namespace Planning Strategy

Before relocating classes:

  1. Create namespace migration plans:
    • Document all class dependencies
    • Map import statements that will need updates
    • Schedule migration during maintenance windows
  2. Use versioned namespaces:
    • Implement namespace versioning (e.g., com.v1.namespace, com.v2.namespace)
    • Gradually migrate rather than abrupt changes
  3. Automated namespace detection:
    • Use scripts to scan for all references to old namespaces
    • Generate update reports before migration

Development Workflow Improvements

Implement better practices to prevent caching issues:

  1. Regular cache maintenance:
    • Schedule weekly cache clearing as part of development routine
    • Use version control to track namespace changes
  2. Automated testing:
    • Create unit tests to verify namespace correctness
    • Implement continuous integration builds that validate namespace references
  3. Documentation standards:
    • Maintain namespace documentation
    • Record all namespace migrations and their impact

Version Control Integration

Leverage version control to manage namespace changes:

  1. Branch strategy:
    • Create feature branches for namespace changes
    • Merge changes only after thorough testing
  2. Change tracking:
    • Use commit messages to document namespace relocations
    • Tag releases with namespace version information
  3. Automated deployment:
    • Implement deployment scripts that validate namespace consistency
    • Use build tools that automatically clear cache during deployment

Conclusion

Clearing the Flash CS4 compiler cache when dealing with persistent old class references requires a multi-pronged approach combining manual cache deletion, strategic project rebuilding, and compiler configuration adjustments. The key is understanding that Flash CS4 stores class definitions in separate cache directories that persist even after source file modifications, making manual intervention necessary to force the compiler to recognize namespace changes.

For your specific situation with the Jenine class migration, start by manually deleting the cache directories in your user profile, then perform a complete project rebuild by removing all compiled files and republishing. If the issue persists, consider using the “Move Class” feature in Flash CS4 or implementing a more systematic namespace migration strategy with proper testing and documentation.

Remember that namespace relocations in complex projects should be planned carefully, with thorough testing and backup procedures in place to prevent compilation issues like the one you’re experiencing.

Sources

  1. Adobe Flash CS4 Professional Documentation - Compiler Cache
  2. Adobe Developer Connection - ActionScript 3.0 Namespace Management
  3. Stack Overflow - Flash CS4 Class Cache Clearing
  4. Adobe Forums - Namespace Relocation Best Practices