|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help. Some class methods not getting called
I'm in the process of writing my first ActionScript class and have run into a problem where two of my defined methods aren't getting called. Could some kindly guru take a look and point out what I'm doing wrong?
Thanks, Ken P.S. the purpose of this class is to encapsulate drag behavior. // in action layer Dragger = function(x, y, timeline, graphicID, depth) { this.x = x; this.y = y; this.timeline = timeline; this.graphic = this.attachGraphic(graphicID, depth); trace(this.graphic); this.scale = 100; this.wasDragged = false; this.render(); } Dragger.prototype.attachGraphic = function (graphicID, depth) { var newName = graphicID + "_" + depth; this.timeline.attachMovie(graphicID, newName, depth); return this.timeline[newName]; } Dragger.prototype.render = function() { with (this.graphic) { _x = this.x; _y = this.y; } } // the next two methods don't seem to get called as their embedded messages never appear in the trace window Dragger.prototype.onPress = function() { trace("item pressed"); } Dragger.prototype.onRelease = function() { trace("item released"); } this.timeline.addListener(this); // in test layer obj = new Dragger(0,0,this,"circleMC",100); // this.graphic renders to stage OK // clicking in the shape defined by this.graphic produces no output |
|
#2
|
|||
|
|||
|
Try this after your class declaration:
Dragger.prototype = new MovieClip(); or (I think) after you instantiate the class: obj.prototype = new MovieClip(); The point is I'm pretty sure onPress handlers only apply to mc's and buttons.
__________________
I'm not impatient, I just have a low tolerance for boredom. Last edited by mbritton72 : June 26th, 2003 at 12:28 PM. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Help. Some class methods not getting called |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|