dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Class problem.

  1. #1
    Junior Member
    Join Date
    Sep 2000
    Posts
    19
    I've made a class and registered it to a movieclip.
    I made 'mc.prototype.onLoad()' call another function of the class with 'setInterval(functionname, 100);'.
    The funtion runs at the intervals but it doesn't work right.
    I made a statement in the funtion to 'trace(this)' and all I get is 'undefined'.
    So anything I have in that funtion like 'this.property = whatever' doesn't work.
    Why???

    Thanks.

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Location
    Hong Kong
    Posts
    171
    setInterval just gets a function running, it doesn't "belong" to the object that called it - so you need to pass it any variables that you want.
    Code:
    myID = setInterval(myFunc, 100, this);
    function myFunc(me){
       trace(me.myProperty);
    }
    Hope this helps.

  3. #3
    Junior Member
    Join Date
    Sep 2000
    Posts
    19
    Wow, you're awesome.
    Thank you SO MUCH!
    That problem has been bothering me all day.
    Thanks again!

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