Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Stopping Items From Moving Off Screen, Possible?



Hello again people, ive got my paddles to move at last. Now im trying to stop them from going off the stage at the top and the bottom. If you keep the key presses up or down it will continue to move into I guess indefinatly. Ive added an if statement after my movement code but it dont seem to work, Anyone know why this peice of code is not working thanks.


Code:
private function keyPressedDown(event:KeyboardEvent):void {
var key:uint = event.keyCode;
var step:uint = 5
switch (key) {
case Keyboard.UP :
myleftbat.y -= step;
if (myleftbat.y > stage.stageHeight) {
myleftbat.y < (stage.stageHeight);
}
break;
case Keyboard.DOWN :
myleftbat.y += step;
if (myleftbat.y < stage.stageHeight) {
myleftbat.y == (stage.stageHeight);
}
break;
case Keyboard.NUMPAD_8:
myrightbat.y -= step;
if (myleftbat.y > stage.stageHeight) {
myleftbat.y < (stage.stageHeight);
}
break;
case Keyboard.NUMPAD_2:
myrightbat.y += step;
if (myleftbat.y < stage.stageHeight) {
myleftbat.y == (stage.stageHeight);
}
break;
}



FlashKit > Flash Help > Actionscript 3.0
Posted on: 11-28-2007, 01:24 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Stopping Items From Movinf Off Screen, Possible?
Hello again people, ive got my paddles to move at last. Now im trying to stop them from going off the stage at the top and the bottom. If you keep the key presses up or down it will continue to move into I guess indefinatly. Ive added an if statement after my movement code but it dont seem to work, Anyone know why this peice of code is not working thanks.


Code:
private function keyPressedDown(event:KeyboardEvent):void {
var key:uint = event.keyCode;
var step:uint = 5
switch (key) {
case Keyboard.UP :
myleftbat.y -= step;
if (myleftbat.y > stage.stageHeight) {
myleftbat.y < (stage.stageHeight);
}
break;
case Keyboard.DOWN :
myleftbat.y += step;
if (myleftbat.y < stage.stageHeight) {
myleftbat.y == (stage.stageHeight);
}
break;
case Keyboard.NUMPAD_8:
myrightbat.y -= step;
if (myleftbat.y > stage.stageHeight) {
myleftbat.y < (stage.stageHeight);
}
break;
case Keyboard.NUMPAD_2:
myrightbat.y += step;
if (myleftbat.y < stage.stageHeight) {
myleftbat.y == (stage.stageHeight);
}
break;
}

Moving Several Items Together
Hello,
I have several items (buttons, graphic symbols) that I want to move on the stage at the same time, as if they were all tied together and placed on the same layer. The problem is that each item has to be on one particular layer to be able to motion tween them. How can do that? Thank you for your help.

Moving Items With Actionscript?
Hi,
I have made three different objects.
I want to have multiple copies of these objects randomly move across the screen than fall at about 3/4 of the way.

The objects also must be seperate from each other.

How should i go about this?

Thanks alot
Smitch

Items On A Moving Menu
Hi,

I'm trying to make a menu that pops out when rolled over (you've seen it a thousand times). The problem is that since I've applied the on(action) script to the movie clip, any buttons or other clips I place on the moving movie clip itself dont respond to their own on(action) scripts. Here's what I have so far (without any menu items).

http://www.clintbalcom.com/photoTest.htm

How can I add movie clips and/or buttons to the menu that pops out that will actually work when rolled over and out...? Is it only buttons that dont respond from within a movie clip?

Thanks...help!!
Clint

Moving Items With Script
I am trying to create a script that moves one itme (with script) then another, then another.

Layer1: 3 instances of a symbol, named: sqMc1, sqMc2, sqMc3

ACTIONS layer:
frame1:
// SET itemNum DEFAULT
itemNum = 1

frame2: (labeled "main")
// SET SETTINGS

currItem = "sqMc"+(itemNum);

finalPos = 76;
speed = 1;
moveItem = "moveItem"+(itemNum);
moveItem1 = "wait-1";
moveItem2 = "wait-2";
moveItem3 = "wait-3";
currPos = (currItem)._x;

// SET DIRECTION

if(currPos < finalPos){
speed = 2;}
else{speed = -2;}

// MOVEMENT

currItem.onEnterFrame = function () {
if(currPos == finalPos){
moveItem = "no-"+(itemNum);
gotoAndPlay(nextFrame());

}
else{
moveItem = "yes-"+(itemNum);
currItem._x += (speed);
currPos = (currItem)._x;}
};

frame3
// INCREMENT itemNum
// to become the dynamic settings

itemNum += 1;

gotoAndPlay("main")


In showing some dynamic text areas of my VARs I can see that "currPos" is 'undefined'. I have tried many different ways to set this, the only way to make this dosplay the proper information is to force is currPos = sqMc1._x which kills the dynamic iteration of this script. So too, the movement does not happen in the lower part of the script currItem._x += (speed); unless the script is sqMc1 += (speed)

Please help!

Moving Array Items
The title means literally that - moving array items that are on the stage.

Code:

///

bottleDepth = 0;
bottleArray_array = Array();
for ( i=1 ; i<10 ; i++){
_root.bottleDepth++; // Increase bottle depth
newBottle = "theBottle"+_root.bottleDepth; // Give it a name
_root.bottleArray_array.push(newBottle); // Add to end of array
_root.landSeaMap.attachMovie("theBottle", newBottle, _root.bottleDepth); // Attach a movie clip to it
_root.landSeaMap[newBottle]._y = 10+(Math.random()*60); // Put it where I want it (y)
_root.landSeaMap[newBottle]._x = 10+(Math.random()*60); // Put it where I want it (x)
}


_root.bottleName.text = _root.bottleArray_array[0];


var myBottleNumber:Number = 0;
_root.bottleName.text = _root.myBottleArray[myBottleNumber];
_root.nextBottle.onRelease = function(){
if (_root.myBottleNumber > _root.myBottleArray.length){
myBottleNumber = 0;
}
_root.bottleName.text = _root.myBottleArray[myBottleNumber++];
}

///

So, as above, I've created about 10 bottles from an original bottle using the array thingy, right?

Now, what I wanna do is move the bottles... like, make them move across the screen. How do I do this?

Also, is there a better way of doing the bottleName.text thing - cuz at the moment when you press the button to scroll thru' all the bottles names, you have to press it twice at the start to get to the second bottle... and at the end it comes to "undefined" before it goes back to bottle1.

LoL, get me?

Cheers, guys. Y'all rock! So helpful!

=)

Moving Menu Items HELP
Hi. I'm trying to make a web page, with four links (that I assume would be best as MC's) and an image in the middle of the page. I want to make it so that when you click one of the links, eg. PICS, that the four links would move to the bottom of the screen, the image would fade out, and the pics page would then load in the middle of the screen.

Now I ASSUME that what I'm trying to do is heavily controlled by actionscript, but I'm pretty much a n00b at in depth actionscript. So if you could keep the explanation in lamens terms, that would be much appreciated. If not, if there is a template or tutorial of some kind, that I can look at and pretty much take the code from, that's fine as well.

Moving Multiple Items At Once
Okay so I have a mini-map navigation inside a movie clip on a main timeline. When the user presses the left or right keys, it moves the map to show buttons that are off of the stage. I do this using the following:


Code:
if (Key.isDown(Key.LEFT)) {
map_mc._x+=mapspeed;
button_0._x += mapspeed;
button_1._x += mapspeed;
button_2._x += mapspeed;
button_3._x += mapspeed;
button_4._x += mapspeed;
button_5._x += mapspeed;
button_6._x += mapspeed;
button_7._x += mapspeed;
button_8._x += mapspeed;

}
if (Key.isDown(Key.RIGHT)) {
map_mc._x-=mapspeed;
button_0._x -= mapspeed;
button_1._x -= mapspeed;
button_2._x -= mapspeed;
button_3._x -= mapspeed;
button_4._x -= mapspeed;
button_5._x -= mapspeed;
button_6._x -= mapspeed;
button_7._x -= mapspeed;
button_8._x -= mapspeed;
}
But if i wanted to add even more buttons, how could i reference them all at once (maybe using a loop) instead of doing it this way. Keeping in mind that the buttons being moved are on a movie clip timeline, not the main timeline.

Thanks!

Moving Items At The Same Time
Hi All,

I have this script, which basically moves my mc buttons to the left by a number of pixels, this happens to each button that is rolled over... What I want to try and achieve however is if right1 is hovered, I want right2, right3, right4 and right5 to move to the right, and if right3 is hovered, I want right1 and right2 to go left, and right4 and right5 to go right and so on... Here is the code I currently have
Code:
// Includes the tweening extensions.

#include "mc_tween2.as"


// Assigns each button its own functions.

// Of course, these buttons were created at design time, on the Flash IDE itself.
// Usually, you wouldn't do that with serious projects, you'd create them dinamically from some "template"
// movieclip (or from some component).

// This is an array, a list of the buttons used.
var myButtons = [this.right_1, this.right_2, this.right_3, this.right_4];

// Loops on all buttons from the first to the last one
for (var i=0; i<myButtons.length; i++) {
// Sets its original X value. This will be used later for reference.
myButtons[i].originalX = myButtons[i]._x;
myButtons[i].xGlowTo(0x2F0000, 1, 30, 1, 3, false, false, 0);

// When the mouse rolls over this menu option... go down just a bit.
// NOTICE: I'm not taking into consideration the problem of having the hit area going down and "moving" the
// mouse area and out of the button (possible rollover flicking). This is just a simple example afterall.
myButtons[i].onRollOver = function() {
this.tween("_x", this.originalX + 5, 1);
};
// When the mouse exits the menu option.. go back up.
myButtons[i].onRollOut = function() {
this.tween("_x", this.originalX, 0.5);
};
// When the mouse clicks.. activate it!
myButtons[i].onRelease = function() {
this._parent.activateItem (this);
// *** Add some function here or somewhere else to handle real button actions!
trace ("Hey, button "+this+" was clicked.");
};
}

this.activateItem = function(item) {
// Function that activates a button.

// Checks if there's an activated item already; if so, deactivates it.
if (this.currentItem != false) this.deActivateItem();

// Activates it, finally
this.currentItem = item;
this.currentItem.alphaTo (100, 1); // makes it 'disabled'
this.currentItem.enabled = true; // makes it a disabled button, so it won't receive mouse events
};

this.deActivateItem = function() {
// Deactivates the current activated menu item.
this.currentItem.enabled = true; // back to a normal button/movieclip
this.currentItem.alphaTo (100, 0.5); // back to its original opacity
this.currentItem.tween("_x", this.currentItem.originalX, 0.5); // back to its original position
this.currentItem = undefined;
};

this.stop();

Moving List Items
Hello every one I need a lot of help.
I need to move and item that is kept in one list to and other list.

Thanks for passing by

Moving Items At The Same Time
Hi All,

I have this script, which basically moves my mc buttons to the left by a number of pixels, this happens to each button that is rolled over... What I want to try and achieve however is if right1 is hovered, I want right2, right3, right4 and right5 to move to the right, and if right3 is hovered, I want right1 and right2 to go left, and right4 and right5 to go right and so on... Here is the code I currently have

Code:
// Includes the tweening extensions.

#include "mc_tween2.as"


// Assigns each button its own functions.

// Of course, these buttons were created at design time, on the Flash IDE itself.
// Usually, you wouldn't do that with serious projects, you'd create them dinamically from some "template"
// movieclip (or from some component).

// This is an array, a list of the buttons used.
var myButtons = [this.right_1, this.right_2, this.right_3, this.right_4];

// Loops on all buttons from the first to the last one
for (var i=0; i<myButtons.length; i++) {
// Sets its original X value. This will be used later for reference.
myButtons[i].originalX = myButtons[i]._x;
myButtons[i].xGlowTo(0x2F0000, 1, 30, 1, 3, false, false, 0);

// When the mouse rolls over this menu option... go down just a bit.
// NOTICE: I'm not taking into consideration the problem of having the hit area going down and "moving" the
// mouse area and out of the button (possible rollover flicking). This is just a simple example afterall.
myButtons[i].onRollOver = function() {
this.tween("_x", this.originalX + 5, 1);
};
// When the mouse exits the menu option.. go back up.
myButtons[i].onRollOut = function() {
this.tween("_x", this.originalX, 0.5);
};
// When the mouse clicks.. activate it!
myButtons[i].onRelease = function() {
this._parent.activateItem (this);
// *** Add some function here or somewhere else to handle real button actions!
trace ("Hey, button "+this+" was clicked.");
};
}

this.activateItem = function(item) {
// Function that activates a button.

// Checks if there's an activated item already; if so, deactivates it.
if (this.currentItem != false) this.deActivateItem();

// Activates it, finally
this.currentItem = item;
this.currentItem.alphaTo (100, 1); // makes it 'disabled'
this.currentItem.enabled = true; // makes it a disabled button, so it won't receive mouse events
};

this.deActivateItem = function() {
// Deactivates the current activated menu item.
this.currentItem.enabled = true; // back to a normal button/movieclip
this.currentItem.alphaTo (100, 0.5); // back to its original opacity
this.currentItem.tween("_x", this.currentItem.originalX, 0.5); // back to its original position
this.currentItem = undefined;
};

this.stop();

Moving Items Between 2 Grids
I want to move items between 2 datagrids.
If I click on the Add Button it should move the data from GridA to GridB
GridA is declared as the dataprovider...

How do I do it?

Dyamically Moving Attached Items
Does anyone know if this is possible:

I have two spheres at key frame 1. Between the two is a single straight line. At key frame 10 I want the spheres to move in opposite directions (one moves to the top of the window, the other to the bottom).

How can I make that connecting line stay attached to those spheres. It requires each end of the line to somehow be attached to the spheres and move/stretch when they move.

Is this possible with Flash?

(I'm using Flash MX).

Moving Multiple Items On The Stage
This is probably a dumb question, but here goes:

I need to dump the contents of all my nested mov clips to Scene1 as one flat animation. When I do, they are no longer in the right place on the stage.

- Is there a way to move multiple keyframes and tweens as a group to another point on the stage, without having to reposition every keyframe one at a time?

When I try selecting them all and grouping, it only moves what keyframes my timeline pointer is on. The rest are left to make unwanted crazy animations.

thanks for your help

Moving Items En Masse In The Timeline - HOW?
Let's say you have a row on your timeline made of 10 frames of a small box graphic. Every other frame, you move the box slightly so it appears to wiggle on the stage when played. Later you decide you want to pick up this entire row of your 10-frame animation, and move it en masse to another part of the stage. How would you do this?

Shift selecting doesn't do it - it only moves the frame you're on.
Grouping doesn't do it - it only moves the frame you're on.
The only way I've found is to move the first box to the new location, hit F6 until I've got 9 more frames the same, and then go in to every other frame to recreate the animation by hand.

You'd think there'd be a better way of doing this. Any ideas?

Thanks,
jcarruth

Moving Stage Items On Resize
Does anyone know how to reposition the stage items on resize like they do on
http://www.hellohikimori.com/
I know how to just move the items onResize, but I want to have the effect of waiting till the resizing has finished before the items move, and how the items bounce in using a Tween.

Any Suggestions.

Moving Thru Items In An XML + Flash Gallery
Greetings,

I am currently working in a Flash gallery that loads all the information into the movie from an XML file. The movie has two dynamic text fields(one for the name of the item and another for the description) and a movie clip to hold the image.

I am able to load the content into the movie just fine and they load into the text fields and movie clip. However, there are several items in the XML file and I want to navigate thru them.

I know I can do it by adding a button for each item, but I much preffer using only two buttons. I added two buttons to the movie, one to go to the next item and another one to go to the previous item.

Here is the code of the movie:


Code:
xmlTest = new XML;
xmlTest.ignoreWhite = true;
xmlTest.load("data.xml");
xmlTest.onLoad = function() {
model(0);
}

function model(whichmodel) {
modelName = xmlTest.firstChild.childNodes[whichmodel].childNodes[0].firstChild.nodeValue;
modelInfo = xmlTest.firstChild.childNodes[whichmodel].childNodes[1].firstChild.nodeValue;
modelImage = xmlTest.firstChild.childNodes[whichmodel].childNodes[2].firstChild.nodeValue;
_root.pictHolder.modelPict.loadMovie (modelImage);
}

// this code below is what I think needs fixing
btnPrev.onRelease = function () {
_root.pictHolder.gotoAndPlay(1);
model(0);
}
btnNext.onRelease = function () {
_root.pictHolder.gotoAndPlay(1);
model(1);
}
The code below the comment is what I am having problems with. When I run the movie like that and click the next button, the info and pict update to show model(1), which is the second item on my XML file, if I click on previous button, it shows model(o), the first item.

What I would like to do is to have the previous and next buttons increment or decrease the value of model(o) by 1 so that it can display the remaining items on the XML file and show the previous one as well.

Any help is apreciated.


Evo

Moving Items En Masse In The Timeline - HOW?
Let's say you have a row on your timeline made of 10 frames of a small box graphic. Every other frame, you move the box slightly so it appears to wiggle on the stage when played. Later you decide you want to pick up this entire row of your 10-frame animation, and move it en masse to another part of the stage. How would you do this?

Shift selecting doesn't do it - it only moves the frame your PB head is on.
Grouping doesn't do it - it only moves the frame your PB head is on.
The only way I've found is to move the first box to the new location, hit F6 until I've got 9 more frames the same, and then go in to every other frame to recreate the animation by hand.

You'd think there'd be a better way of doing this. Any ideas?

Thanks,
jcarruth

Moving Items En Masse Using X And Y Coords
I had a row of text items in the timeline that I wanted to move, without having to click on each one individually and put in the new X and Y coordinates in either the properties inspector or the info box.

I selected them all at once, then put in the new coordinates, hit enter, and then when I clicked on each one individually, found they were still in their old position. I had to move them one by one. What a time waster! Ain't there no faster way to do this?

Thanks,
jcarruth

Moving Items En Masse Using X And Y Coords
I had a row of text items in the timeline that I wanted to move, without having to click on each one individually and put in the new X and Y coordinates in either the properties inspector or the info box.

I selected them all at once, then put in the new coordinates, hit enter, and then when I clicked on each one individually, found they were still in their old position. I had to move them one by one. What a time waster! Ain't there no faster way to do this?

Thanks,
jcarruth

Moving Multiple Items Using OnEnterFrame
I am trying create to move objects (boxes, named box_1, box_2 etc) to positions on the stage (xPos_1, xPos_2 etc) using onEnterFrames. I can make all the boxes move individually, but I cant get them to move together. I am using the following code in an attempt to move 3 boxes.

If anyone can point me in the right direction it would be appreciated!


PHP Code:



while (k < 3) {_root.onEnterFrame = function() {            _root["box_"+k]._x -= 5;        _root["box_"+k]._y -= 5;                if (_root["box_"+k]._x <= _root["xPos_"+k]) {            _root["box_"+k]._x = _root["xPos_"+k];        }                if (_root["box_"+k]._y <= yPos) {            _root["box_"+k]._y = yPos;        }        }k++;    } 

Moving Items At The Same Time Using MC Tween
Hi All,

I have this script, which basically moves my mc buttons to the left by a number of pixels, this happens to each button that is rolled over... What I want to try and achieve however is if right1 is hovered, I want right2, right3, right4 and right5 to move to the right, and if right3 is hovered, I want right1 and right2 to go left, and right4 and right5 to go right and so on... Here is the code I currently have

Code:
// Includes the tweening extensions.

#include "mc_tween2.as"


// Assigns each button its own functions.

// Of course, these buttons were created at design time, on the Flash IDE itself.
// Usually, you wouldn't do that with serious projects, you'd create them dinamically from some "template"
// movieclip (or from some component).

// This is an array, a list of the buttons used.
var myButtons = [this.right_1, this.right_2, this.right_3, this.right_4];

// Loops on all buttons from the first to the last one
for (var i=0; i<myButtons.length; i++) {
// Sets its original X value. This will be used later for reference.
myButtons[i].originalX = myButtons[i]._x;
myButtons[i].xGlowTo(0x2F0000, 1, 30, 1, 3, false, false, 0);

// When the mouse rolls over this menu option... go down just a bit.
// NOTICE: I'm not taking into consideration the problem of having the hit area going down and "moving" the
// mouse area and out of the button (possible rollover flicking). This is just a simple example afterall.
myButtons[i].onRollOver = function() {
this.tween("_x", this.originalX + 5, 1);
};
// When the mouse exits the menu option.. go back up.
myButtons[i].onRollOut = function() {
this.tween("_x", this.originalX, 0.5);
};
// When the mouse clicks.. activate it!
myButtons[i].onRelease = function() {
this._parent.activateItem (this);
// *** Add some function here or somewhere else to handle real button actions!
trace ("Hey, button "+this+" was clicked.");
};
}

this.activateItem = function(item) {
// Function that activates a button.

// Checks if there's an activated item already; if so, deactivates it.
if (this.currentItem != false) this.deActivateItem();

// Activates it, finally
this.currentItem = item;
this.currentItem.alphaTo (100, 1); // makes it 'disabled'
this.currentItem.enabled = true; // makes it a disabled button, so it won't receive mouse events
};

this.deActivateItem = function() {
// Deactivates the current activated menu item.
this.currentItem.enabled = true; // back to a normal button/movieclip
this.currentItem.alphaTo (100, 0.5); // back to its original opacity
this.currentItem.tween("_x", this.currentItem.originalX, 0.5); // back to its original position
this.currentItem = undefined;
};

this.stop();

Moving Items At The Same Time Using MC Tween
Hi All,

I have this script, which basically moves my mc buttons to the left by a number of pixels, this happens to each button that is rolled over... What I want to try and achieve however is if right1 is hovered, I want right2, right3, right4 and right5 to move to the right, and if right3 is hovered, I want right1 and right2 to go left, and right4 and right5 to go right and so on... Here is the code I currently have Code:

// Includes the tweening extensions.

#include "mc_tween2.as"


// Assigns each button its own functions.

// Of course, these buttons were created at design time, on the Flash IDE itself.
// Usually, you wouldn't do that with serious projects, you'd create them dinamically from some "template"
// movieclip (or from some component).

// This is an array, a list of the buttons used.
var myButtons = [this.right_1, this.right_2, this.right_3, this.right_4];

// Loops on all buttons from the first to the last one
for (var i=0; i<myButtons.length; i++) {
   // Sets its original X value. This will be used later for reference.
   myButtons[i].originalX = myButtons[i]._x;
   myButtons[i].xGlowTo(0x2F0000, 1, 30, 1, 3, false, false, 0);

   // When the mouse rolls over this menu option... go down just a bit.
   // NOTICE: I'm not taking into consideration the problem of having the hit area going down and "moving" the
   // mouse area and out of the button (possible rollover flicking). This is just a simple example afterall.
   myButtons[i].onRollOver = function() {
            this.tween("_x", this.originalX + 5, 1);
   };
   // When the mouse exits the menu option.. go back up.
   myButtons[i].onRollOut = function() {
      this.tween("_x", this.originalX, 0.5);
   };
   // When the mouse clicks.. activate it!
   myButtons[i].onRelease = function() {
      this._parent.activateItem (this);
      // *** Add some function here or somewhere else to handle real button actions!
      trace ("Hey, button "+this+" was clicked.");
   };
}

this.activateItem = function(item) {
   // Function that activates a button.
   
   // Checks if there's an activated item already; if so, deactivates it.
   if (this.currentItem != false) this.deActivateItem();
   
   // Activates it, finally
   this.currentItem = item;
   this.currentItem.alphaTo (100, 1); // makes it 'disabled'
   this.currentItem.enabled = true; // makes it a disabled button, so it won't receive mouse events
};

this.deActivateItem = function() {
   // Deactivates the current activated menu item.
   this.currentItem.enabled = true; // back to a normal button/movieclip
   this.currentItem.alphaTo (100, 0.5); // back to its original opacity
   this.currentItem.tween("_x", this.currentItem.originalX, 0.5); // back to its original position
   this.currentItem = undefined;
};

this.stop();

Moving Items At The Same Time Using MC Tween
Hi All,

I have this script, which basically moves my mc buttons to the left by a number of pixels, this happens to each button that is rolled over... What I want to try and achieve however is if right1 is hovered, I want right2, right3, right4 and right5 to move to the right, and if right3 is hovered, I want right1 and right2 to go left, and right4 and right5 to go right and so on... Here is the code I currently have

Code:

// Includes the tweening extensions.

#include "mc_tween2.as"


// Assigns each button its own functions.

// Of course, these buttons were created at design time, on the Flash IDE itself.
// Usually, you wouldn't do that with serious projects, you'd create them dinamically from some "template"
// movieclip (or from some component).

// This is an array, a list of the buttons used.
var myButtons = [this.right_1, this.right_2, this.right_3, this.right_4];

// Loops on all buttons from the first to the last one
for (var i=0; i<myButtons.length; i++) {
// Sets its original X value. This will be used later for reference.
myButtons[i].originalX = myButtons[i]._x;
myButtons[i].xGlowTo(0x2F0000, 1, 30, 1, 3, false, false, 0);

// When the mouse rolls over this menu option... go down just a bit.
// NOTICE: I'm not taking into consideration the problem of having the hit area going down and "moving" the
// mouse area and out of the button (possible rollover flicking). This is just a simple example afterall.
myButtons[i].onRollOver = function() {
this.tween("_x", this.originalX + 5, 1);
};
// When the mouse exits the menu option.. go back up.
myButtons[i].onRollOut = function() {
this.tween("_x", this.originalX, 0.5);
};
// When the mouse clicks.. activate it!
myButtons[i].onRelease = function() {
this._parent.activateItem (this);
// *** Add some function here or somewhere else to handle real button actions!
trace ("Hey, button "+this+" was clicked.");
};
}

this.activateItem = function(item) {
// Function that activates a button.

// Checks if there's an activated item already; if so, deactivates it.
if (this.currentItem != false) this.deActivateItem();

// Activates it, finally
this.currentItem = item;
this.currentItem.alphaTo (100, 1); // makes it 'disabled'
this.currentItem.enabled = true; // makes it a disabled button, so it won't receive mouse events
};

this.deActivateItem = function() {
// Deactivates the current activated menu item.
this.currentItem.enabled = true; // back to a normal button/movieclip
this.currentItem.alphaTo (100, 0.5); // back to its original opacity
this.currentItem.tween("_x", this.currentItem.originalX, 0.5); // back to its original position
this.currentItem = undefined;
};

this.stop();

Intermediate Gray Screen Seen While Moving From One Screen To Another
I am integrating flash with VC++ using ActiveX.Here when I click on buttons to go to the next screen an intermediate blank screen flashes for a second that looks very odd.In fact for some screens that have many movie clips the blank screen stays there for a few seconds before showing the actual frame. This causes a blinking effect that is not proper.I wish to know why this happens and how it can be removed.
Thanks in advance.

Moving And Stopping
My friend needs action script to make a movie clip not be able to move on top of another mc.
He uses this code for the moving clip:
onClipEvent(load){
x = this._x;
y = this._y;
speed = 5;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.LEFT)) {
x -= speed;
}
if (Key.isDown(Key.RIGHT)) {
x += speed;
}
if (Key.isDown(Key.UP)) {
y -= speed;
}
if (Key.isDown(Key.DOWN)) {
y += speed;
}

this._x = x;
this._y = y;
}


and he wnats it so when it tries to go over "clip1" (instance name) it doesn't.
I can make an event if it moves on top of "clip1," but not stop moving over it. Can anyone help?

Flash Exports Off-screen Items, Help?
I've ran into another problem with my first flash movie... when I export the file it even exports things that are off the canvas, how can I get only the canvas items exported? I even had the document size right, but it seems to ignore that.

Displaying The Numbers Of Items On The Screen
Can any 1 please tell me how to display the number of item on a movie clip. I need the number to be shown in a dynamic text box. And I need the number to be able to change as some of the items will disappear and reappear later in the time line.

Moving Text Then Stopping....
I just recently went over the Flash 5 lessons but they really don't help me with what I want to do. I wanted to have text come from the left side and each letter move to the right, stop until the rest of the text finishes then repeat again. Can someone help me out and point me in the right direction?

[CS3/F8]AS2 Stopping A Tween From Moving.
Hi all, I have a yellow square that i am tweening along the x axis using the .tween class, however this animation starts as soon as the frame is loaded, i have tried several ways to make it start at a stationary position yet to no avail.
The play control works so far and it does loop the animation like i want it to yet i just want the square to start at a stop.
I also need a working stop button as i can only make it pause curently.
I have uploaded a working .zip file with the examples save in CS3 and F8 formats any help is appreciated greatly.

Regards,

Rich.

Moving And Stopping Objects Via AS
Howdy ... I have a problem ...

I want to move an Object via AS in this way:

Start: x = 0 moving to x = 300 waiting there for 4 seconds moving from x = 300 then to x = 500 ...

how can i do this in AS rather then motion tween ... any help much appreciated

cheers

ChromeD

Random Moving And Stopping...
I've instituted the code for random movement from this tutorial - http://www.kirupa.com/developer/actionscript/random.htm

Does any know of away that I can modify this so when the user rolls over one of the movieclips it will stop moving and once the user rolls offs it will resume random movement.

Thanks in advance.

[CS3/F8]AS2 Stopping A Tween From Moving.
Hi all, I have a yellow square that i am tweening along the x axis using the .tween class, however this animation starts as soon as the frame is loaded, i have tried several ways to make it start at a stationary position yet to no avail.
The play control works so far and it does loop the animation like i want it to yet i just want the square to start at a stop.
I also need a working stop button as i can only make it pause curently.
I have uploaded a working .zip file with the examples save in CS3 and F8 formats any help is appreciated greatly.

Regards,

Rich.

Moving Multiple Items Across A Timeline, Adding Frames
A couple of things have always bugged me about flash and i thought maybe i'm missing something.

When i create something like a web banner i often have to change the order of certain items on the time line or add extra frames at the beginning of the animation. Only way i seem to be able to do this is clicking top left corner of top layer/shift/bottom right of bottom layer. But, when i move everything over each layer ads frames to the end frame. i.e. layer 3 which started on frame 100 and ended on frame 200 has just added frames all the way to the end, frame 1000 (and hence the object in this layer is now visible all the way to the end of the movie.

Another example would be if i wanted to move the last 100 frames of a movie to the start. So, say there's an object on layer1 and another on layer 10, it's difficult to get this to the beginning without ruining the whole movie.

So i then looked at splitting the animation into 2 scenes so i could change the order. but i cannot copy/paste a layer from one scene into another..... i hope i'm missing something :-)

Sorry if it sounds confusing!

Cheers





























Edited: 01/17/2007 at 03:54:42 AM by gr1f

Stopping A Character From Moving Through Object
Hi,

Newbie here...and I'm using flash mx 2004.

I have a movieclip (character) with an instance named "car", and a png turned movieclip with instance name "toxic". The car keeps going through toxic and I want to use toxic as a barrier.
I understand that I have to use collision detection so I tested that by using

if(car.hitTest(toxic)){
trace('Collision detected!');
}

So, that worked. But in place of trace('Collision detected!');

What actionscripting do I need to add so toxic becomes solid and can not be walked through? Thanks.

Stopping My Symbol From Moving Out Of The Border
Hello,

im feeling ill from trying to solve this so ive come here in search of some much needed guidance.

i am doing a uni project and have to make a game that is half frogger and half pacman. Im nearly done but cant work out how to stop a symbol that i move with the arrow keys to stop when he gets to the borders of the screen.

This is the code to make him move:

onClipEvent (keyDown) {

if (Key.isDown(key.RIGHT)) {
this.gotoAndPlay("roll");
this._x = this._x+20;
}

if (Key.isDown(key.UP)) {
this.gotoAndPlay("roll");
this._y -= 15;
}

if (Key.isDown(key.DOWN)) {
this.gotoAndPlay("roll");
this._y += 15;
}

if (Key.isDown(key.LEFT)) {
this.gotoAndPlay("roll");
this._x -= 10;
}

}

This code is placed inside the instance of my frog (well a hedgehog but nevermind).

What i had thought of is to put an if statement saying it can only move if it was within the x and y coordinates. I used this:

if(this._x > 10 && this._x < 600 && this._y > 10 && this._y < 400){

above the other code. This made it so when the frog moved out of these coodinates he couldnt move anymore. it disabled all controls. I then tried an else{
this._x = this._x + 1 so that it would move the symbol back to within range of the 1st if statement. But im afraid i had no joy

Im sure there is some help on these forums and im sorry if i am repeating apost but i didnt know how to search for this.

Well

Thanks

fonze

Actionscript Moving Left But Not Stopping
This is probably an obvious answer but... I currently have this code:


onClipEvent(enterFrame) {

this._x-=10;

if (this._x > 35){
this._x=stop();
}
}

The movie clip currently moves to the left as it should but I want it to stop when it gets to 35 on the x coordinates. Is there an easier way to do this?

Moving And Stopping A Movie Clip
hi everyone! i'm new to this forum but have been using flash for a while. in the past i've done everything with motion tweens but now that i'm trying to use actionscript i've run into a probelm.

i want to move a movie clip on the stage. this is the code that i am using:

onClipEvent(enterFrame){

_x = _x + 10;

}

after it moves to this position i want it to stop - at the moment it just keeps on moving. despite my best attempts i'm having no joy. i know there is probably a ridiculously simple solution but i'm stumped.

any help would be much apprecitated

Moving And Stopping It With Mouse Movements
Hello,
I am trying to create time-line that moves in the direction of the mouse movement but then will stop whenever I hover over an area. In other words, I have links on the time-line that I want to be able to stop at by hovering over the button. The code listed below is what I am using for the x and y background movements:
(What am I missing to get the background to stop when I hover over a button?)

this.onMouseMove = function() {

constrainedMove(bg2_mc, 4, 1);

};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {

var mousePercent:Number = _xmouse/Stage.width;
var mSpeed:Number;
if (dir == 1) {

mSpeed = 1-mousePercent;

} else {

mSpeed = mousePercent;

}
target.destX = Math.round(-((target._width-Stage.width)*mSpeed));
target.onEnterFrame = function() {

if (target._x == target.destX) {

delete target.onEnterFrame;

} else {

target._x += Math.ceil((target.destX-target._x)*(speed/300));

}

};

}

Stopping A Moving Object With ActionScript
Greetings,

I have a movie clip I am moving from the left side of the stage to the right using AS, however I can't seem to get the clip to scale larger or stop.

I was able to succesfully get the clip to move, so I am wonderging if anyone can help me stop the MC and gradually make the clip larger.

Here is the AS as it stands now -

onClipEvent (load) {
_x=24;
_y=111.7;
_xscale=_yscale=0;
_alpha = 10;
}
onClipEvent (enterFrame) {
_x=_x+3;
_xscale=_yscale=+100
_xscale=_yscale=+100;
_alpha = _alpha+2;
}
onClipEvent (data) {
stop();
}

All help is greatly appreciated.

Best,
CG

Flash Game (How Do I Display Moving Items In Random Order?)
Ok
I'm creating my first game in Flash mx.
Its a conveyor belt game where toys move from left to right. There are several boxes located underneath the belt.
The user has to drag and drop each toy into its correct box.

I want each toy to continously come out in a random order.

(1 idea) randomly select movie clips from the library?
each movie clip representing a toy.

any suggestions at all wud be welcome!

thanks

Flash Game (How Do I Display Moving Items In Random Order?)
Ok
I'm creating my first game in Flash mx.
Its a conveyor belt game where toys move from left to right. There are several boxes located underneath the belt.
The user has to drag and drop each toy into its correct box.

I want each toy to continously come out in a random order.

(1 idea) randomly select movie clips from the library?
each movie clip representing a toy.

any suggestions at all wud be welcome!

thanks

Stopping Sound After Moving To Next Scene In Flash 5
I have a piece of music that I'd like to loop in a stopped frame, but I also want the music to stop when I use a button to move to the next scene. It's a single frame that I've added it into, but the music should stop entirely so I can play different sounds in other scenes. In other words, I can't mute everything when I move to a new scene. I just want to stop this one piece of music.
Should I just add a stop music line to each button? If so, what's the code for that?

Moving A M/c Using KeyDown Then Stopping At A Specific Point
Hi - I'm moving a m/c left and right on a screen using the onClipEvent (keyDown) command successfully. But here is a simply, but maddening thing that I need to fix. How do you stop the clip from moving when you reach a specified limit on the far left or right of the screen? Say _x = 35 and _x = 500 I want the clip to move in between these two numbers. How do I do it??

ta

frank

Dragging Objects (stopping Mouse From Moving)
Hello,

I am very stuck. I tried looking over my old Director scripts for help but I cant make anything of them to help them with Actionscript.

Basically what i want to do is, when i am dragging a a movie clip such as 'lungs_mc' i dont want the user to be able to drag it outside of a box called 'dragArea_mc' which has co ords of: w:560.0, h:538, x: 235, y:57.0.

Basically when the user drags lungs_mc to the edge of box it stops the user from moving the object outside this box, but they are still able ot move it inside of the box.

Any Suggestions??

If you dont know how to retrain 'lungs_mc' within 'dragArea_mc' then even retraining them within x and y co ords would be great and i will just use < and > for those.

Also 'lungs_mc' is on the _root and so is 'dragArea_mc'. They both must stay on the root to make the whole movie work.

It would be greatly appreciated if anyone could help as it would solve a massive problem for me

thanks a lot :-)

Lee





























Edited: 12/15/2006 at 05:22:58 AM by leej_w

Full Screen, No Scale, Hide Items Outside Movie Area
I have created a full screen movie but want to keep the scale so the movie sits in the centre of the screen (done, no probs) but how do I stop any symbols/objects from appearing outside of the movie parameters. I want the items which go off screen NOT to appear on the full screen.

Can anyone help?!

p.s. I dont want to use a mask as the movie I want to apply this to has several layers, some of which are already masked.

Collision Detect: Stopping A Movie From Moving On The Stage
Hey everyone,

I have multiple stationary movies on the stage (they dont move around on the stage) and I have a movie that is moved by the arrow keys (on the keyboard). How can I make it so that when the movable movie comes in contact with one of those statinary movies, they don't overlap each other?

(e.g. When Pac-Man hits a wall, he stops moving until the user gives another direction. Also, attempting to move in the blocked direction repeatedly doesn't allow you to pass through)

Thanks!!!

- OneMrBean

Stopping A Movie Clip From Moving At Specific X Position
I have created a simple movie where I am moving a movie clip using buttons with action script. I have everything moving the way I want it to but I am looking for some code to set a limit to how far it will move in order for it to stop within the masked area.

Right now my code looks like this...

moveLeft.onRollOver = function() {
rocket.onEnterFrame = function() {
this._x -= 8;
};
};
moveLeft.onRollOut = function() {
delete rocket.onEnterFrame;
};
moveRight.onRollOver = function() {
rocket.onEnterFrame = function() {
this._x += 8;
};
};
moveRight.onRollOut = function() {
delete rocket.onEnterFrame;
};


Any help would be much appreciated

Moving Car Across Screen... Then Changes To Another
Hi im new to actionscripting, just starting to learn it. I need to make an animation where shops go past along with cloud and the road and 3 different types of caravans will drive on the road.

I have already done the clouds and the moving shops, and im wondering if someone can help me getting the caravans to work.

Basically caravan number 1 needs to drive on screen from the left, keep driving for a few minutes then drive back where it came from, and then caravan number 2 appears, does the same thing then goes back to allow caravan 3 to go on. This will need to be in a constant loop.

I have uploaded my animation if you want to view it.

Much help would be appreciated thanks.

p.s. Please do not worry about the current graphic's for the caravans. I will change them later when i get the pictures. Thankss!

EDIT: Sorry this is for Flash 8 Professional

Copyright © 2005-08 www.BigResource.com, All rights reserved