A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Counting Linkages

  1. #1
    Member
    Join Date
    Jul 2008
    Posts
    40

    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 0i<1000i++){
         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

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Give this a try.

    PHP Code:
    var i:int 0;
    while(++
    i){
        try{
            
    getDefinitionByName('pic' i);
        } catch (
    err:ReferenceError){
            
    trace('No pic' ' detected. Stopping.');
            
    i--;
            break;
        }
    }

    trace(i); 
    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    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.

  4. #4
    Member
    Join Date
    Jul 2008
    Posts
    40
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center