Author Topic: Anyone with Actionscript expertise, please help me!  (Read 3077 times)

0 Members and 1 Guest are viewing this topic.

Offline matt oz

  • APPLES!
  • Score: 0
    • View Profile
Anyone with Actionscript expertise, please help me!
« on: November 30, 2006, 01:57:00 PM »
All right, since most of you know nothing about me, I'll just start by saying I'm a college student, recently changed my major to a program called Interactive Multimedia.  It's fun and I like it.  There.

Now, I'm in this class called 'Interactive Computing' and as our final project, we have to do something (anything, really) in Flash.

My idea is based on Colorforms, those little reusable sticker things you would place on a cardboard background.  What I'm doing is having a bunch of shapes and objects that the user can move around on a background, thereby making a complete picture.  When they're done moving everything, they hit a 'Done' button, the objects freeze, then the user can click on each object for some kind of animation.  (For example, clicking on a door will open it and someone will come out and wave)

My problem: getting the objects to stop moving.

I've been working for days trying to get these stupid objects to stay put after I press the Done button, but I can't seem to do it.  I've asked my professors for help (one of whom is a programming genius, and has created some awesome stuff with Flash/Actionscript), and no one can figure it out.  I need a StopFunction function or something like that.  Something that will freeze my objects to keep the user from moving them again, so I can then animate them.

Stuff I've already tried:
-putting stop(); everywhere I can think of
-using a true/false variable combined with if statements
-a do while loop, which I don't even think I did right

If anyone can help me, I sure would appreciate it.  Thanks!!!
Wii Code:  7894 - 4898 - 7716 - 3649

Offline Ceric

  • Once killed four Deviljho in one hunt
  • Score: 0
    • View Profile
RE:Anyone with Actionscript expertise, please help me!
« Reply #1 on: November 30, 2006, 02:53:00 PM »
This is what I'm thinking you did with the True/False statement but...

I don't know much about flash  but I'm assuming you either have the pieces follow the mouse after you click them or the follow when the mouse is over them.
When you click the done button couldn't you just a have a global boolean that then be set to true so that will have the program skip all the movement code whenever the person does what causes them to move?
Need a Personal NonCitizen-Magical-Elf-Boy-Child-Game-Abused-King-Kratos-Play-Thing Crimm Unmaker-of-Worlds-Hunter-Of-Boxes
so, I don't have to edit as Much.

Offline bustin98

  • Bustin' out kids
  • Score: 30
    • View Profile
    • Web Design Web Hosting Computer Sales and Service
RE:Anyone with Actionscript expertise, please help me!
« Reply #2 on: December 01, 2006, 02:39:37 AM »
My thoughts:

Either tell the objects 'startDrag(false)'

OR

Have Flash record the X and Y coordinates of each piece on the field, then move to a new frame (or scene?) which does not invoke the startDrag function and place movieclips of each piece in their recorded positions.

Offline Pale

  • Staff Layton Hat Thief
  • Score: 4
    • View Profile
    • PaleHour
RE: Anyone with Actionscript expertise, please help me!
« Reply #3 on: December 01, 2006, 03:27:53 AM »
Are you using built in flash drag functions?  Like startDrag and what not?

This sounds like a glitch in code somewhere that is making it really hard for any of us to debug.  If I could make one suggestion, it would be to write almost all of your drag code yourself instead of using Flash's built in stuff.  This would allow you to have full control.

Basically, you could make a holder MovieClip variable at your root to represent something that is attached to your mouse.  When you click on something to move it, just copy it into that holder variable and set a boolean to true.  Then, in your frame loop, if the boolean is true, set that holder variable's _x and _y to be _xmouse and _ymouse (you can offset them for perfect placement).  Then do a global onRelease function that if your boolean is true, it drops the current MovieClip in the holder variable at that location.

While not a direct solution, this would allow you to really manipulate your dragging how you want.  You could even get really creative and give the drag a rubber band like feel for some added fun.

This is what I did to implement some cross SWF dragging in a project I'm working on at work not 2 hours ago.  
:: I was an active staffer forever ago, or was it yesterday. Time is an anomaly. Father of two boys.
---------------------
:: Grouvee :: Instagram

Offline Pale

  • Staff Layton Hat Thief
  • Score: 4
    • View Profile
    • PaleHour
RE: Anyone with Actionscript expertise, please help me!
« Reply #4 on: December 01, 2006, 03:32:53 AM »
Here's some of my code...


// Variable declarations
var attachedMovie:MovieClip;
var isAttached:Boolean = false;

// Set some onpress functions for each of my objects that are draggable
alphaContainer_mc.onPress = function() {
     isAttached = true;
     attachedMovie = alphaDragger_mc;
}

betaContainer_mc.onPress = function() {
     isAttached = true;
     attachedMovie = betaDragger_mc;
}

gammaContainer_mc.onPress = function() {
     isAttached = true;
     attachedMovie = gammaDragger_mc;
}

neutronContainer_mc.onPress = function() {
     isAttached = true;
     attachedMovie = neutronDragger_mc;
}


// Global onMouseUp function to release objects (with some hit test code you can ignore)
// In my particular case I move the objects off the screen on release.  You would just leave them where they are.
onMouseUp = function() {
     if(attachedMovie.hitTest(balance_mc)) {
          if(_xmouse >= balance_mc._x - (balance_mc._width / 2) && _xmouse <= balance_mc._x) {
               // Hit left
               balance_mc.weightLeft = attachedMovie.weight;
               balance_mc.objectLeft_mc.gotoAndStop(attachedMovie.theType);
          } else {
               // Hit right
               balance_mc.weightRight = attachedMovie.weight;
               balance_mc.objectRight_mc.gotoAndStop(attachedMovie.theType);
          }
     }
     isAttached = false;
     attachedMovie._x = -1000;
     attachedMovie._y = -1000;
}


// General frame loop
onEnterFrame = function() {
     if(isAttached) {
          attachedMovie._x = _xmouse;
          attachedMovie._y = _ymouse;
     }
}  
:: I was an active staffer forever ago, or was it yesterday. Time is an anomaly. Father of two boys.
---------------------
:: Grouvee :: Instagram

Offline matt oz

  • APPLES!
  • Score: 0
    • View Profile
RE: Anyone with Actionscript expertise, please help me!
« Reply #5 on: December 02, 2006, 04:09:26 PM »
Thanks guys, especially Pale.  I've been working on it, and it's not quite right yet, but it's getting there.  Now I'm also focusing on my final project for my Digital Media class, and I'm just all over the place with everything.  I'll let you know how it turns out.
Wii Code:  7894 - 4898 - 7716 - 3649

Offline Pale

  • Staff Layton Hat Thief
  • Score: 4
    • View Profile
    • PaleHour
RE: Anyone with Actionscript expertise, please help me!
« Reply #6 on: December 18, 2006, 08:17:17 AM »
My turn to ask a question...  I'm linking to my google post...

http://groups.google.com/group/macromedia.flash.actionscript/browse_thread/thread/aaf722b38dee5d31?hl=en

This is frustrating the hell out of me.
:: I was an active staffer forever ago, or was it yesterday. Time is an anomaly. Father of two boys.
---------------------
:: Grouvee :: Instagram

Offline Nick DiMola

  • Staff Alumnus
  • Score: 20
    • View Profile
    • PixlBit
RE: Anyone with Actionscript expertise, please help me!
« Reply #7 on: December 18, 2006, 12:29:09 PM »
That doesn't seem to make too much sense Pale, maybe it has something to do with actionscript. It seems that "OLD_" should have been appended to the front of the name. Have you tried to make a new variable and assign it the value of OLD plus the name and then assign it to the name in the following line. Maybe the way you are doing it screws up the parser. I have no idea though. My exposure to actionscript is extremely limited.
Check out PixlBit!

Offline Pale

  • Staff Layton Hat Thief
  • Score: 4
    • View Profile
    • PaleHour
RE: Anyone with Actionscript expertise, please help me!
« Reply #8 on: December 18, 2006, 01:37:42 PM »
Yeah I've tried everything.  It all seems to work fine until the _name ends up being undefined.  I can't figure it out at all, but it may be some crazy Flash security thing.  I dunno.
:: I was an active staffer forever ago, or was it yesterday. Time is an anomaly. Father of two boys.
---------------------
:: Grouvee :: Instagram

Offline bustin98

  • Bustin' out kids
  • Score: 30
    • View Profile
    • Web Design Web Hosting Computer Sales and Service
RE:Anyone with Actionscript expertise, please help me!
« Reply #9 on: December 20, 2006, 03:06:36 AM »
Whenever I have a script in Flash that does not behave the way I want it to, I find that sticking the root in front of a variable tends to help.