dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Using class name as instance name

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    260

    Using class name as instance name

    Hi all,

    I've got a hell of a lot of MovieClips in a library because they are all different shapes etc, so rather than creating them dynamically I've made them all manually.

    They all share the same base class in the properties dialog box (apartment.as) but all have an individual class in the dialog box. The apartment.as is as follows:
    PHP Code:
    package 
    {
        
    import flash.display.*;
        
    import flash.events.*;
        
    import fl.transitions.Tween;
        
    import fl.transitions.easing.*;    
        
        
    internal class apartment extends MovieClip
        
    {
            public function 
    apartment()
            {
                
    this.mouseEnabled true;
                            
    this.buttonMode true;
                
    this.addEventListener(MouseEvent.MOUSE_DOWNdown);
            }
            
            public function 
    down(e:Event):void
            
    {
                
    trace(this);
            }
            
        }

    So for example one of the movieclips is called level1_01 and is placed within a movieclip called plan1. Within plan 1 there are a further 20 movieclips all called level1_02, level1_03....etc.

    When I click any one of the movieclips (that I've positioned on stage) is there anyway use the class name as an instance name? I haven't given each of them an instance name but was wondering whether it's possible to use the class name that I entered into the properties dialog box as it.

    Cheers
    Matt

  2. #2
    Member
    Join Date
    Nov 2002
    Posts
    43
    Looks like the answer is NO.
    Instance name and class name have to be different.

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    It's not strictly required that instance name and class name have to be different. But it is required that variable names not be the same as class names. When you place an object on the stage manually and give it an instance name, flash declares a variable of the same name for you. So for those instances, instance name must be different from the class name (otherwise, how would the compiler know which you're referring to?).

    But if I read between the lines correctly, you just want to trace the class name when you click it. To get the class name, you can use the getQualifiedClassName function in flash.utils to get that information.

  4. #4
    Senior Member
    Join Date
    Apr 2001
    Posts
    260
    thanks for the response guys. I see what you mean about the conflict of instance and class name.
    5TonsOfFlax, getQualifiedClassName is what I was looking for, many thanks.

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