dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Simple MX and oop problem

  1. #1
    Senior Member
    Join Date
    Mar 2000
    Posts
    584
    I'm doing an exercise in managing movie clips via objects.

    I place a movie clip that contains a button on the stage. When the button is clicked, I want the movie clip (and the button inside it) to rotate to 45 degrees.

    Code:
    _global.MyObject=function(){
            this.prototype = new MovieClip();
    }
    
    Change = new Object();
    Change.onMouseDown = function () {
            trace("here");
    	MyObject.prototype._rotation=45;
    	MyObject.prototype.name.text="test";
    }
    
    Mouse.addListener(Change);
    
    Object.registerClass("MC", MyObject);
    
    attachMovie("MC", "TestMC", 2);
    
    stop();
    All that happens is the movie clip gets placed on the stage. The 'onMouseDown' gets successfully called as the 'here' traces out. However, the rotation doesn't happen, nor does the word 'test' get passed to a text field inside the clip.

    So I suspect the connection between the object and the movie clip is incorrect.

    If I substitute MyObject.prototype._rotation=45; with TestMC._rotation=45; it works, but that would defeat the purpose.

    Thanks for any help.


  2. #2
    Senior Member
    Join Date
    Mar 2000
    Posts
    584
    Here's the correct way to do it that I found in Flash MX ActionScripting - Advanced. Seems like a good book.

    Code:
    _global.MyObject=function(){
            this.prototype = new MovieClip();
    }
    
    MyObject.prototype.onMouseDown = function () {
            trace("here");
    		this._rotation=45;
    }
    
    Object.registerClass("clip", MyObject);
    
    attachMovie("clip", "demo", 2);
    
    stop();

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