-
Counting Linkages
Hello,
I am using Flash CS4, AS3. I have within my library pictures with linkages: pic1, pic2, ... Is there a way that I can count these?
PHP Code:
for(var i:Number = 0; i<1000; i++){
var linkageName:String = "pic" + i;
if(testIfPictureExists(linkageName) == true)
count++;
}
Could someone please guide me in the right direction on creating the function 'testIfPictureExists()'?
Thanks in advance!!!
-Jake
-
Give this a try.
PHP Code:
var i:int = 0;
while(++i){
try{
getDefinitionByName('pic' + i);
} catch (err:ReferenceError){
trace('No pic' + i + ' detected. Stopping.');
i--;
break;
}
}
trace(i);
Please use [php] or [code] tags, and mark your threads resolved 8)
-
Code:
private function testClassExists(className:String):Boolean {
var toreturn:Boolean = false;
try{
var c:Object = getDefinitionByName(className);
toreturn = true;
}catch (referror:ReferenceError) {
trace(className +" does not exist");
}
return toreturn;
}
However, this will only work if the classes are actually present in the exported swf. If you only have them in the library and do not refer to them in a static context, the compiler will not include them.
-
Thank you very much!! That was just what I was looking for!
-Jake
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|