 |
 |
Actionscript 2.0 help requested
|
 |
|
 |
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
I'm trying to get thehang of the new object oriented capabilities of Actionscript 2.0, but I have run across some problems. My goal is to create a class that creates objects that can interact with simple mouseovers, etc. So far I have everything working, except for the mouse interaction. When I mouse over the movie clips on the stage, nothing happens. I suspect that I am doing something wrong. Here is the class:
Code:
class FadingCircle {
private var target_mc:MovieClip;
private var circle_mc:MovieClip;
private var circleDepth:Number;
public function FadingCircle(target:MovieClip, depth:Number, x:Number, y:Number) {
target_mc = target;
circleDepth = depth;
showCircle(x, y);
}
private function showCircle(x:Number, y:Number):Void {
circle_mc = target_mc.createEmptyMovieClip("circle_mc"+circleDepth, circleDepth);
circle_mc._x = x;
circle_mc._y = y;
circle_mc.loadMovie("circle.jpg");
circle_mc.onRollOver = function() {
this._alpha = 0;
trace ("over");
};
circle_mc.onRollOut = function() {
this._alpha = 100;
};
trace("circle created");
}
}
And here is what I am using to implement the class (it is placed in Frame 1 of the root of the timeline):
Code:
stop();
onEnterFrame = function () {
for (x=1; x<=20; x++) {
var fader:FadingCircle = new FadingCircle(this, x, 20*x, 0);
}
delete onEnterFrame;
}
Any ideas as to what I'm doing wrong?
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by york28:
I'm trying to get thehang of the new object oriented capabilities of Actionscript 2.0, but I have run across some problems. My goal is to create a class that creates objects that can interact with simple mouseovers, etc. So far I have everything working, except for the mouse interaction. When I mouse over the movie clips on the stage, nothing happens. I suspect that I am doing something wrong. Here is the class:
Code:
class FadingCircle {
private var target_mc:MovieClip;
private var circle_mc:MovieClip;
private var circleDepth:Number;
public function FadingCircle(target:MovieClip, depth:Number, x:Number, y:Number) {
target_mc = target;
circleDepth = depth;
showCircle(x, y);
}
private function showCircle(x:Number, y:Number):Void {
circle_mc = target_mc.createEmptyMovieClip("circle_mc"+circleDepth, circleDepth);
circle_mc._x = x;
circle_mc._y = y;
circle_mc.loadMovie("circle.jpg");
circle_mc.onRollOver = function() {
this._alpha = 0;
trace ("over");
};
circle_mc.onRollOut = function() {
this._alpha = 100;
};
trace("circle created");
}
}
And here is what I am using to implement the class (it is placed in Frame 1 of the root of the timeline):
Code:
stop();
onEnterFrame = function () {
for (x=1; x<=20; x++) {
var fader:FadingCircle = new FadingCircle(this, x, 20*x, 0);
}
delete onEnterFrame;
}
Any ideas as to what I'm doing wrong?
I don't have Flash MX 2004 so I can't test this, but is the loadMovie causing the problem? It looks as if it would replace itself (as there is no target) - try creating a new movie inside your object, then load the circle.jpg into that and see if it has any effect.
Other than that your code seems to be fine to me...
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
Thanks a lot for the suggestion. It worked.
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by york28:
Thanks a lot for the suggestion. It worked.
Nice one! One of these days I'm going to see if I can rival Philzilla for the monikker of 'Occasionally useful...' 
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|