Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Actionscript 2.0 help requested

Actionscript 2.0 help requested
Thread Tools
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status: Offline
Reply With Quote
Sep 30, 2004, 12:20 AM
 
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
Reply With Quote
Sep 30, 2004, 06:07 PM
 
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...
     
york28  (op)
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status: Offline
Reply With Quote
Sep 30, 2004, 10:33 PM
 
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
Reply With Quote
Oct 1, 2004, 01:26 AM
 
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...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:12 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2