View Full Version : search and replace in my .as files
finchou
12-28-2005, 04:41 PM
Hello, I've got a tricky question : I need to run a movie on a pda.
The original movie is compiled in flash 7, and the win CE player is flash 6 (thank you Macromedia).
So I need to replace all the instances of myclip.myOtherClipAndSoOn.getNextHighestDepth() by
myClass.myGetDepthFunction(myclip.myOtherClipAndSo On)
in 100 or so classes.
does anyone know a tool or the Perl expression that would magically do that?
or does JSFL allow that kind of things?
the winner gets a beer when he comes to Paris :D
thanks in advance!
finchou
12-30-2005, 03:59 PM
there it is :
#!F:\programmes\perl\PXPerl\bin
#it's perl of course!
use File::Find;
$numtotal=0;
sub process_file {
return unless ($_ =~ /\.as/i);
open (FILE, $_) || print("Could not open file! ".$_."\n");
my @contenu = <FILE>;
$num=0;
foreach my $ligne (@contenu)
{
#si le getNext... est appelé sur un objet
#$num+=$ligne=~s/([a-z0-9A-Z._-]*)\.getNextHighestDepth\(\)/gestionMC.getProfondeurAvailable\($1\)/;
$num+=$ligne=~s/([^ ,]*)\.getNextHighestDepth\(\)/gestionMC.getProfondeurAvailable\($1\)/;
#si l'objet n'est pas précisé c'est this
$num+=$ligne=~s/getNextHighestDepth\(\)/gestionMC.getProfondeurAvailable\(this)/;
#print $ligne;
}
$numtotal+=$num;
print $num." occurences supprimées dans ".$_."\n";
close FILE;
open FILEWRITE, ">".$_;
print FILEWRITE @contenu;
close FILEWRITE;
}
find(\&process_file, ".");
print "\n".$numtotal." occurences supprimées en tout...\n";
you just have to create a gestionMC class and a static
getProfondeurAvailable(mc:MovieClip) function, and run the script.
it works, getnextHighestdepths (and the png images) where the only obstacle to building in flash 6.
:D
senocular
12-30-2005, 04:02 PM
why dont you just define your own function as getNextHighestDepth and not have to worry about replacing at all?
finchou
12-30-2005, 04:02 PM
and I get to keep my beer! hooray!
happy new year's eve everyone...
finchou
12-30-2005, 04:06 PM
is MovieClip a dynamic class that you can edit?
also why didn't you answer before? :D
at least I learnt a bit of Perl, it can be useful...
senocular
12-30-2005, 04:41 PM
MovieClip is dynamic... but youre aiming for Flash 6 so it doesnt matter. :D
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.