A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [F8] No method with the name swapDepths ?! [as 2.0]

  1. #1
    Instructional Designer
    Join Date
    Feb 2005
    Location
    Whidbey Island: north of Seattle, east of Victoria, south of Vancouver
    Posts
    299

    [F8] No method with the name swapDepths ?! [as 2.0]

    I am simulating an Excell spreadsheet. I have three SWFs: one to hold data, one to hold tabs, one to hold the column headings, and one to allow scrolling (because the header needs to scroll in concert with the data). My plan is to load each of these onto one SWF with a separate container for each (using the MoveClipLoader). I've gotten help on other posts to get this far, but I am stuck with errors that do not make sense to me.

    Here are the error messages. I know that swapDepths and onLoadInit are real, so what is Flash trying to tell me?

    There is no method with the name 'swapDepths'
    There is no property with the name 'onLoadInit'
    These error messages come from the following code.

    Code:
    //This first container holds spreadsheet data
    var MCdata:MovieClipLoader = new MovieClipLoader();
    MCdata.onLoadInit = function(_loadedMC:MovieClip) {
    	//_loadedMC is now done loading and can be placed
    	//loadedMC is whatever clip you loaded the swf int (ie this.head)
    	if (_loadedMC == _root.dataFile){ //head loaded 
    		_loadedMC._x = 0;
    		_loadedMC._y = 150;
    	}
    };
    MCdata.loadClip("Summary.swf",this.dataFile);
    MCdata.swapDepths(this.getNextHighestDepth());//Pushes container to top
    
    //This second container holds column headings and will sit above the 1st container.
    var MChead:MovieClipLoader = new MovieClipLoader();
    MChead.onLoadInit = function(_loadedMC:MovieClip) {
    	//_loadedMC is now done loading and can be placed
    	//loadedMC is whatever clip you loaded the swf into (ie this.head)
    	if (_loadedMC == _root.head){ //head loaded
    		_loadedMC._x = 0;
    		_loadedMC._y = 0;
    	}
    };
    MChead.loadClip("SummaryHead.swf",this.head);
    head.swapDepths(this.getNextHighestDepth());pushes 2nd container above 1st
    
    //This 3rd container holds tab button for loading new data and headings.  
    var MCtabs:MovieClipLoader = new MovieClipLoader();
    MCtabs.onLoadInit = function(_loadedMC:MovieClip){
    	//_loadedMC is now done loading and can be placed
    	//loadedMC is whatever clip you loaded the swf into (ie this.head)
    	if (_loadedMC == _root.tabs){ //head loaded 
    		_loadedMC._x = 0;
    		_loadedMC._y = 516;
    	}
    };
    
    MCtabs.loadClip("TabControl.swf",this.tabs);
    tabs.swapDepths(this.getNextHighestDepth());
    
    
    
    //This third container holds a scroll controll swf.  It will sit at the very top.
    
    var MCnav:MovieClipLoader = new MovieClipLoader();
    MCnav.onLoadInit = function(_loadedMC:MovieClip){
    	//_loadedMC is now done loading and can be placed
    	//loadedMC is whatever clip you loaded the swf int (ie this.head)
    	if (_loadedMC == _root.nav){ //head loaded }
    		_loadedMC._x = 150;
    		_loadedMC._y = 20;
    	}
    };
    
    MCnav.loadClip("NavControl.swf",this.nav);
    MCnav.swapDepths(this.getNextHighestDepth());
    Tomas

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    your understanding of the usage of MovieClipLoader is a tad fuzzy
    suggest you re-read the Help files
    corrected method/syntax is
    Code:
    var MCListener:Object = new Object();
    
    MCListener.onLoadInit = function(_loadedMC:MovieClip) {
    	if (_loadedMC == _root.dataFile){ 
    		_loadedMC._x = 0;
    		_loadedMC._y = 150;
    		_loadedMC.swapDepths(_root.getNextHighestDepth());
    	}
    };
    
    var MCdata:MovieClipLoader = new MovieClipLoader();
    MCdata.addListener(MCListener);
    MCdata.loadClip("Summary.swf",this.dataFile);

  3. #3
    Senior Member
    Join Date
    Jun 2002
    Location
    Ljubljana, Slovenija
    Posts
    168
    so the swapDepths method you shouldent use on loader class but on the mc that has been loaded ie:
    Code:
    this.dataFile.swapDepths(this.getNextHighestDepth());//Pushes container to top

  4. #4
    Instructional Designer
    Join Date
    Feb 2005
    Location
    Whidbey Island: north of Seattle, east of Victoria, south of Vancouver
    Posts
    299
    your understanding of the usage of MovieClipLoader is a tad fuzzy
    Thanks Mr. dog. I'd go even further with the scope of fuzzy, but I'm working on it. I left my reference books at work, but I do have Rapo and Michael's Understanding Macromedia Flash 8 ActionScript 2.0, which has proven helpful. The help files, often lacking functional examples, are not generally of much value to me.

    I see that I was missing the listener. I've been guilty of using code that I don't understand, but I'm working on that.
    Tomas

  5. #5
    Instructional Designer
    Join Date
    Feb 2005
    Location
    Whidbey Island: north of Seattle, east of Victoria, south of Vancouver
    Posts
    299
    Thanks Malek. That is helpful too. That explains the other error message.

    I've been reading up on Classes. It seems to me that I could create a Container Class to do this for me (ya think?). I'll post it to this thread, if I get that far before I'm forced onto other fires.
    Tomas

  6. #6
    Instructional Designer
    Join Date
    Feb 2005
    Location
    Whidbey Island: north of Seattle, east of Victoria, south of Vancouver
    Posts
    299
    Since I am loading three different containers, should I give each listener a unique name (e.g., mc1Listener, mc2Listener, mc3Listener)? Or should I reuse the same listener for each load?
    Tomas

  7. #7
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    to avoid Flash getting its knickers in a twist I would use 3 unique listeners

  8. #8
    Instructional Designer
    Join Date
    Feb 2005
    Location
    Whidbey Island: north of Seattle, east of Victoria, south of Vancouver
    Posts
    299
    OK! No Flashy twisted knickers for us! I've come up with unique names for all objects (I realize I could have gone with _loadedMC for each since that variable is within the function, but I can afford the extra ink.

    After re-reading the MovieClipLoader help file, I think the makings were there, I just missed them.

    Here is my distillation:

    Code:
    //Loading the first container++++++++++++++++++++++++++++++++++++++++++++++++++
    var mc1Listener:Object = new Object();
    mc1Listener.onLoadInit = function(_loadedMC1:MovieClip) {
    	if (_loadedMC1 == _root.dataFile){ 
    		_loadedMC1._x = 0;
    		_loadedMC1._y = 150;
    		_loadedMC1.swapDepths(_root.getNextHighestDepth());
    	}
    };
    var MCdata:MovieClipLoader = new MovieClipLoader();
    MCdata.addListener(mc1Listener);
    MCdata.loadClip("Summary.swf",this.dataFile);
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    //Loading the second container++++++++++++++++++++++++++++++++++++=
    var mc2Listener:Object = new Object();
    mc2Listener.onLoadInit = function(_loadedMC2:MovieClip) {
    	if (_loadedMC2 == _root.head){ 
    		_loadedMC2._x = 0;
    		_loadedMC2._y = 150;
    		_loadedMC2.swapDepths(_root.getNextHighestDepth());
    	}
    };
    var mcHead:MovieClipLoader = new MovieClipLoader();
    mcHead.addListener(mc2Listener);
    mcHead.loadClip("SummaryHead.swf",this.head);
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    //Loading the third container++++++++++++++++++++++++++++++++++++=
    var mc3Listener:Object = new Object();
    mc3Listener.onLoadInit = function(_loadedMC3:MovieClip) {
    	if (_loadedMC3 == _root.tabs){ 
    		_loadedMC3._x = 0;
    		_loadedMC3._y = 150;
    		_loadedMC3.swapDepths(_root.getNextHighestDepth());
    	}
    };
    var mcTabs:MovieClipLoader = new MovieClipLoader();
    mcTabs.addListener(mc3Listener);
    mcTabs.loadClip("TabControl.swf",this.tabs);
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    //Loading the forth container++++++++++++++++++++++++++++++++++++=
    var mc4Listener:Object = new Object();
    mc4Listener.onLoadInit = function(_loadedMC4:MovieClip) {
    	if (_loadedMC4 == _root.nav){ 
    		_loadedMC4._x = 0;
    		_loadedMC4._y = 150;
    		_loadedMC4.swapDepths(_root.getNextHighestDepth());
    	}
    };
    var mcNav:MovieClipLoader = new MovieClipLoader();
    mcNav.addListener(mc3Listener);
    mcNav.loadClip("NavController.swf",this.nav);
    Tomas

  9. #9
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    so can we mark this one up as RESOLVED ? (Thread Tools)

    if so, good luck and godspeed

  10. #10
    Instructional Designer
    Join Date
    Feb 2005
    Location
    Whidbey Island: north of Seattle, east of Victoria, south of Vancouver
    Posts
    299

    Resolved

    Yes. That answers my question. Thanks very much!
    Tomas

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