Community Forums => General Chat => Topic started by: matt oz on November 30, 2006, 01:57:00 PM
Title: Anyone with Actionscript expertise, please help me!
Post by: matt oz 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!!!
Title: RE:Anyone with Actionscript expertise, please help me!
Post by: Ceric 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?
Title: RE:Anyone with Actionscript expertise, please help me!
Post by: bustin98 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.
Title: RE: Anyone with Actionscript expertise, please help me!
Post by: Pale 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.
Title: RE: Anyone with Actionscript expertise, please help me!
Post by: Pale 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; }
// 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; }
Title: RE: Anyone with Actionscript expertise, please help me!
Post by: matt oz 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.
Title: RE: Anyone with Actionscript expertise, please help me!
Post by: Pale on December 18, 2006, 08:17:17 AM
My turn to ask a question... I'm linking to my google post...
Title: RE: Anyone with Actionscript expertise, please help me!
Post by: Nick DiMola 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.
Title: RE: Anyone with Actionscript expertise, please help me!
Post by: Pale 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.
Title: RE:Anyone with Actionscript expertise, please help me!
Post by: bustin98 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.