Kizzi Posted July 4, 2008 Report Share Posted July 4, 2008 I'm learning scripting (Actionscript 2 on MX Professional), and I've made a circle that you can drag, a square that you can't, and some dynamic text that says "Drag the circle to the square." However, I don't know how to make it change the text when you drag the circle in the square. So:1) The code (duh, lol).2) Possibly an explanation.[spoiler=Code on the Circle]onClipEvent (mouseDown) { if (this.hitTest(_root._xmouse, _root._ymouse)) { startDrag(this, false);}} onClipEvent (mouseUp) { if (this.hitTest(_root._xmouse, _root._ymouse)) { stopDrag();}} Edit: Okay, I've got the trace command working, so how do I make the text change?[spoiler=Code on the Layer]circle.onRelease = function(){if (circle.hitTest(area)) {trace("You dragged the circle to the square!") }else {trace("Drag the circle to the square.") };} Edit2: I've got the text to change, but it'll only change once, and appears as "0layer1.txt" at the start.[spoiler=Updated Code]circle.onRelease = function(){//The only way I can get it to work.if (circle.hitTest(area)==true) {txt.text="You dragged the circle to the square!" }else {txt.text="Drag the circle to the square." }} Edit3: Thanks to Cyber Lucifer for helping me.[spoiler=Final Code][spoiler=Frame1]circle.onRelease = function() {if (circle.hitTest(area)==true) {gotoAndStop(2);}} onEnterFrame = function() {if (circle.hitTest(area)==true) {gotoAndStop(2);}else {gotoAndStop(1);}} [spoiler=Frame2]circle.onRelease = function() {if (circle.hitTest(area)==false) {gotoAndStop(1);}} [spoiler=Circle]onClipEvent (mouseDown) { if (this.hitTest(_root._xmouse, _root._ymouse)) { startDrag(this, false);}} onClipEvent (mouseUp) { if (this.hitTest(_root._xmouse, _root._ymouse)) { stopDrag();}} Link to comment Share on other sites More sharing options...
Kizzi Posted July 6, 2008 Author Report Share Posted July 6, 2008 *BUMP*I've edited it with my progress. Link to comment Share on other sites More sharing options...
Prince Poison Posted July 7, 2008 Report Share Posted July 7, 2008 Well I suppose you should make a new keyframe.Then edit the code on frame to:circle.onRelease = function(){if (circle.hitTest(area)) {gotoandstop(2);} Then in that keyframe do everything you want to do.Hope it works Link to comment Share on other sites More sharing options...
God GAK Posted July 7, 2008 Report Share Posted July 7, 2008 Is that supposed to be a game or something? Link to comment Share on other sites More sharing options...
Kizzi Posted July 7, 2008 Author Report Share Posted July 7, 2008 Well I suppose you should make a new keyframe.Then edit the code on frame to:circle.onRelease = function(){if (circle.hitTest(area)) {gotoandstop(2);} Then in that keyframe do everything you want to do.Hope it worksI managed to fix it using what you've given me. Tyvm' date=' +rep :D[spoiler=Final Code'][spoiler=Frame1]circle.onRelease = function() {if (circle.hitTest(area)==true) {gotoAndStop(2);}} onEnterFrame = function() {if (circle.hitTest(area)==true) {gotoAndStop(2);}else {gotoAndStop(1);}} [spoiler=Frame2]circle.onRelease = function() {if (circle.hitTest(area)==false) {gotoAndStop(1);}} [spoiler=Circle]onClipEvent (mouseDown) { if (this.hitTest(_root._xmouse, _root._ymouse)) { startDrag(this, false);}} onClipEvent (mouseUp) { if (this.hitTest(_root._xmouse, _root._ymouse)) { stopDrag();}} Link to comment Share on other sites More sharing options...
Guest Posted July 7, 2008 Report Share Posted July 7, 2008 ~Locked as Requested~ -Darth Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.