dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] [F8] deleting objects

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    24

    resolved [RESOLVED] [F8] deleting objects

    hi!

    I'm making a game and I need some help . I don't think it's necassary to go into all the details. So here's the problem. I have made a class. In this class I have some properties of raw data (String, Numbers and such). I also have a propert holding a MovieClip. Now for the sake of optimizing I want to remove the entire object after using it. In my code I use the
    PHP Code:
    delete this
    statement to delete the object. But it does'nt work at all! It keeps returning false. So for now I use the
    PHP Code:
    removeMovieClip(this.container); 
    method just to get rid of the graphical appearance. But does anybody know why I can't delete an instance of this class? Here's the class:

    PHP Code:
    class ActionInterface {
        
    // properties:
        
    private var container:MovieClip;
        private var 
    menu:String;
        private var 
    args:Array = new Array();
        private static var 
    ELEMENT:String;
        private var 
    point:Object = new Object();
        
    //constructor: 
        
    public function ActionInterface(menu:Stringmc:MovieClipargs:Array) {
            if (
    ELEMENT == undefined) {
                
    trace("ERROR: element is undefined!");
                break;
            }
            
    this.menu menu;
            
    this.args args;
            
    this.container _root.createEmptyMovieClip("container" this.menu_root.getNextHighestDepth());
            
    this.point.mc._width;
            
    this.point.= -* (mc._height);
            
    mc.localToGlobal(point);
            
    this.container._x this.point.x;
            
    this.container._y this.point.y;
            var 
    am:ActionManager ActionManager.getInstance();
            var 
    actionsArray:Array = am.getActionMenu(this.menu);
            
    this.loadUI(actionsArray);
        }
        public static function 
    setElement(element:String):Void {
            
    ELEMENT element;
        }
        
    // methods:
        
    public function loadUI(actionsArray:Array):Void {
            var 
    objRef:ActionInterface this;

            for (var 
    i:Number 0actionsArray.lengthi++) {
                            
    this.container.element this.container.attachMovie(ELEMENTELEMENTi);
                
    this.container.element._y this.container.element._height;
                
    this.container.element.action actionsArray[i];
                
    this.container.element.element_txt.text actionsArray[i].getDesc();
                
    this.container.element.onPress = function() {
                                    
    objRef.executeCommand(this.action);
                };
            }
        }

        public function 
    unloadUI():Void {
            
    removeMovieClip(this.container);
            
    trace(delete this);
        }
        public function 
    executeCommand(action:Action):Void {
            if (
    action.getRoot() == "Lopen naar") {
                
    trace(" ");
                
    trace("commencing move...");
                
    trace(" ");
                var 
    user:User User.getInstance();
                
    user.goToRoom(action.getDesc());
            }
            
    this.unloadUI();
        }

    Last edited by jeev010; 05-24-2008 at 10:58 AM.

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    See this post.

  3. #3
    Junior Member
    Join Date
    Aug 2007
    Posts
    24
    thnx for looking into it

    so basicly, as long there is a reference to the object, it won't be flushed from the memory. sounds fair. then ill clsoe this topic

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