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:
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?
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
- Manual Cache Clearing Methods
- Project Rebuild Strategies
- Compiler Configuration Solutions
- Preventative Measures for Future Relocations
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:
- Close Adobe Flash CS4 completely before attempting to delete cache files
- Navigate to your user profile directory:
- Windows:
C:\Users\[YourUsername]\AppData\Local\Adobe\Flash CS4\ - Mac:
/Users/[YourUsername]/Library/Application Support/Adobe/Flash CS4/
- Windows:
- 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:
- Locate your FLA file and close it in Flash CS4
- Delete these files/folders in your project directory:
.DS_Store(Mac only)Thumbs.db(Windows only)- Any
*.swffiles that might contain cached references
- Use the “Clean Project” option:
- Go to
File > Publish Settings - Click the
Cleanbutton to remove temporary files
- Go to
Registry/Preferences Reset
For more persistent issues, you may need to reset Flash CS4 preferences:
- Close Flash CS4
- Delete the preferences file:
- Windows:
C:\Users\[YourUsername]\AppData\Roaming\Adobe\Flash CS4\Preferences\ - Mac:
/Users/[YourUsername]/Library/Preferences/Adobe Flash CS4/
- Windows:
- Restart Flash CS4 - it will recreate default preferences
Project Rebuild Strategies
Complete Project Rebuild
A systematic rebuild approach can resolve cached reference issues:
- Save and close all files in Flash CS4
- Delete all compiled output:
- Remove all
.swffiles from your project - Delete any
*.swcfiles
- Remove all
- Use the “Clean All” option:
- Right-click your project in the Project panel
- Select
CleanorClean Alloptions
- Recompile from scratch:
- Close and reopen the FLA file
- Press
Ctrl+Shift+F12(Windows) orCmd+Shift+F12(Mac) to republish
Class File Relocation Best Practices
When moving classes between namespaces:
- Use the “Move Class” feature:
- Right-click the class file in Flash CS4
- Select
Refactor > Move Class - Follow the wizard to relocate the class
- Verify namespace updates:
- Check all import statements in your project
- Update any
packagedeclarations in the class file
- 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:
- Regenerate SWC files after namespace changes
- Update library paths in the FLA file:
- Go to
File > Publish Settings > Flash - Click
Settingsnext to “ActionScript 3.0” - Verify library paths point to correct namespaces
- Go to
- 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:
- Access compiler settings:
File > Publish Settings > Flash- Click
Settingsbutton in ActionScript 3.0 section
- Adjust compiler options:
- Enable “Strict Mode” to catch namespace mismatches
- Set “Warnings” to “Verbose” for detailed error messages
- Consider enabling “Optimize” to force recompilation
- 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:
// 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:
- Create namespace migration plans:
- Document all class dependencies
- Map import statements that will need updates
- Schedule migration during maintenance windows
- Use versioned namespaces:
- Implement namespace versioning (e.g.,
com.v1.namespace,com.v2.namespace) - Gradually migrate rather than abrupt changes
- Implement namespace versioning (e.g.,
- 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:
- Regular cache maintenance:
- Schedule weekly cache clearing as part of development routine
- Use version control to track namespace changes
- Automated testing:
- Create unit tests to verify namespace correctness
- Implement continuous integration builds that validate namespace references
- Documentation standards:
- Maintain namespace documentation
- Record all namespace migrations and their impact
Version Control Integration
Leverage version control to manage namespace changes:
- Branch strategy:
- Create feature branches for namespace changes
- Merge changes only after thorough testing
- Change tracking:
- Use commit messages to document namespace relocations
- Tag releases with namespace version information
- 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.