A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: MX attachMovie within custom mc subclass

  1. #1
    Junior Member
    Join Date
    Jun 2003
    Location
    Calgary, CANADA
    Posts
    23

    MX attachMovie within custom mc subclass

    I am trying to create a panel for an interface. This panel is a subclass of MovieClip and is registered. The problem is that when i use this.attachMovie(...) it doesn't work, i can use _root.attachMovie(...), but that isn't going to work at all when i instantiate a whole bunch of these guys. Can someone see my error?

    Code:
    _global.CPanel = function(){
      }
      // Set CPanel prototype chain to inherit from MovieClip
      CPanel.prototype = new MovieClip();  
      
      // Register CPanel as the class for symbol "Panel"
      Object.registerClass("Panel", CPanel);  
      
      CPanel.prototype.onLoad = function() {
    	  var TL_Point = new CPoint(250, 100);
    	  var BR_Point = new CPoint(300, 200);
    	  this.Location_Rect = new CRect(TL_Point, BR_Point)
    	  this.attachMovie(this.Contents_str, "Contents_mc", 33);
    	  _root.Contents_mc._x = this.Location_Rect.GetTopLeft().GetX() + 1;
    	  _root.Contents_mc._y = this.Location_Rect.GetTopLeft().GetY() + 20;
    	  this.Draw();
      }
    The key is to reach the caffiene concentration point where one's fingers can still just write code and one's mind is as sharp as a lightsaber.

  2. #2
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    I hate "onLoad".

    Since each instance will pass the constructor, you can try:

    put those actions into constructor or rename "onLoad" as init and make constructor call init().

  3. #3
    Junior Member
    Join Date
    Jun 2003
    Location
    Calgary, CANADA
    Posts
    23

    thank you, but...

    That is good advice, thank you. There are just a couple of questions i have. Firstly, i have this same problem in other methods of my CPanel class, it could be because they get called from onLoad, i'm not sure, i'll have to try it. The other thing is whether i can pass data to (and use it in init()) CPanel using the initObject parameter of attachMovie. Do you know the answer to this?
    The key is to reach the caffiene concentration point where one's fingers can still just write code and one's mind is as sharp as a lightsaber.

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    Hey, I test it !

    Sorry, "onLoad" seems to work. So, my replie was a mistake.

    initObject also works both in attachMovie("Panel",........) or attachMovie("someId",......) in the onLoad section.

    Do you have #initclip in your codes ?

  5. #5
    Junior Member
    Join Date
    Jun 2003
    Location
    Calgary, CANADA
    Posts
    23
    Yes, i have the #initclip at the top (there's some other stuff above my class declaration that i need) and #endinitclip at the bottom.

    Also, here's my code for instantiating the CPanel if it helps:

    Code:
    ontactProperties = new Object();
    ContactProperties.Name_str = "Contacts Panel";
    ContactProperties.Title_str = "Contacts";
    ContactProperties.Contents_str = "NewForm";
    this.attachMovie("Panel", "Contacts_Panel", 77, ContactProperties);
    Contacts_Panel._x = 0;
    Contacts_Panel._y = 0;
    Does this explain anything??
    Thanks so much for your help!
    The key is to reach the caffiene concentration point where one's fingers can still just write code and one's mind is as sharp as a lightsaber.

  6. #6
    Junior Member
    Join Date
    Jun 2003
    Location
    Calgary, CANADA
    Posts
    23
    Anyone have any idea what is wrong here!???
    The key is to reach the caffiene concentration point where one's fingers can still just write code and one's mind is as sharp as a lightsaber.

  7. #7
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    I created a movie and copy-pasted your script in. (except _x,_y);

    I did not see any problems ?
    Attached Files Attached Files

  8. #8
    Junior Member
    Join Date
    Jun 2003
    Location
    Calgary, CANADA
    Posts
    23
    really? Could you send me the .fla so i can see what might be different? Mine isn't working yet.

    That would be awesome, if you wouldn't mind.
    Thanks!
    The key is to reach the caffiene concentration point where one's fingers can still just write code and one's mind is as sharp as a lightsaber.

  9. #9
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    I attached that fla in the reply.

  10. #10
    Junior Member
    Join Date
    Jun 2003
    Location
    Calgary, CANADA
    Posts
    23
    hehe... so you did! *grin* missed that somehow. Anyhow, yours does work, mine doesn't, so i must be doing something different somewhere! Thanks so much, i should be able to figure it out now!
    The key is to reach the caffiene concentration point where one's fingers can still just write code and one's mind is as sharp as a lightsaber.

  11. #11
    Junior Member
    Join Date
    Jun 2003
    Location
    Calgary, CANADA
    Posts
    23
    Yep, got it figured out - not exactly sure how, but it works now!! *grin* Thanks so much for helping me on this one! This is great! Sweet Puppies!
    The key is to reach the caffiene concentration point where one's fingers can still just write code and one's mind is as sharp as a lightsaber.

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