REALLY stuck here: OOP-people needed!

  • Rasper
  • Newbie
  • Newbie
  • Rasper
  • Posts: 7

Post 3+ Months Ago

Okay, I'm really breaking my head over this one. It's probably really simple once you know how :roll:
This is the problem: I'm making a class NewImage, where I define the properties, and use some methods to create new movieClips.
When i'm trying to call the methods from within the constructor, I'm not having any difficulty using this.methodName();

But .. when i'm inside the onEnterFrame function that resides in the imageClip-method, I'm unable to use the "this"-keyword because it would refer to the movieClip instead of the class.

So my question is: how do I call the function "animate()" from within my onEnterFrame function ???

btw, i'm aware of the fact that this isn't fully functionally code, I left out all the properties, arguments etc that wouldn't matter to answer my question.

Hope you guys can help me out!!

Code: [ Select ]
function NewImage(){
    this.test = "test";
    this.image = 0;
    
    movieMain.createEmptyMovieClip("test_mc", 1)
    this.holder = movieMain["test_mc"];
    
    this.setImage();
    this.imageClip();
}

NewImage.prototype.setImage = function(){
    this.holder.createEmptyMovieClip("test_jpg", 1)
    this.image = holder["test_jpg"];
    this.image.loadMovie("/test.jpg");
}

NewImage.prototype.imageClip = function(){
    picture = this.image;
    this.holder.onEnterFrame = function(){
        if(picture.getBytesLoaded() == picture.getBytesTotal()){
            animate();
            //I'm trying to call the animate-function here!!!
        }
    }
}

function animate(){
    // animation of movieclip goes here
}
  1. function NewImage(){
  2.     this.test = "test";
  3.     this.image = 0;
  4.     
  5.     movieMain.createEmptyMovieClip("test_mc", 1)
  6.     this.holder = movieMain["test_mc"];
  7.     
  8.     this.setImage();
  9.     this.imageClip();
  10. }
  11. NewImage.prototype.setImage = function(){
  12.     this.holder.createEmptyMovieClip("test_jpg", 1)
  13.     this.image = holder["test_jpg"];
  14.     this.image.loadMovie("/test.jpg");
  15. }
  16. NewImage.prototype.imageClip = function(){
  17.     picture = this.image;
  18.     this.holder.onEnterFrame = function(){
  19.         if(picture.getBytesLoaded() == picture.getBytesTotal()){
  20.             animate();
  21.             //I'm trying to call the animate-function here!!!
  22.         }
  23.     }
  24. }
  25. function animate(){
  26.     // animation of movieclip goes here
  27. }
  • Rasper
  • Newbie
  • Newbie
  • Rasper
  • Posts: 7

Post 3+ Months Ago

I already managed to solve it by adding an extra property in the class construtor:

this.holder.manager = this

and than invoking the method so:

this.manager.animate();

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 4 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.