PDA

View Full Version : A Quick Question


Noxxem
03-17-2003, 08:30 PM
I can't for the life of me get Movie CLips inside Movie Clips to talk to eachother.

Here is a senario;

In _root, there is the movie clips movCharacter.

In movCharacter, there are the movie clips movCharacterDown, movCharacterUp, movCharacterRight, and movCharacterLeft.

How to I tell movCharacterRight to stop(); form _root?

This would solve many many things i'm trying to do in my game.

Thanks,

Chris

CyanBlue
03-17-2003, 08:32 PM
Howdy...

_root.movCharacter.movCharacterRight.stop();

???

sandman9
03-17-2003, 08:35 PM
CyanBlue

Damn you are good .....

Noxxem
03-17-2003, 08:53 PM
I tried that and it dosen't work. here is the code;

O, and it would be great if someone could help me with the root.boundaryX loop.

I also attached my file.


onClipEvent (enterFrame) {
walkingSpeed = 4;
if (Key.isDown=true) {
keyPressed = "";
if (Key.isDown(Key.UP)) {
_root.movCharacter.gotoAndPlay("charMoveUp");
keyPressed = "up";
yPosition = (walkingSpeed*-1);
moveY();
detectHitBoundary();
detectHitHotspot();
detectHitSide();
if (wallCollide == true) {
yPosition = walkingSpeed;
moveY();
}
} else if (Key.isDown(Key.DOWN)) {
_root.movCharacter.gotoAndPlay("charMoveDown");
keyPressed = "down";
yPosition = walkingSpeed;
moveY();
detectHitBoundary();
detectHitHotspot();
detectHitSide();
if (wallCollide == true) {
yPosition = (walkingSpeed*-1);
moveY();
}
} else if (Key.isDown(Key.LEFT)) {
_root.movCharacter.gotoAndPlay("charMoveLeft");
keyPressed = "left";
xPosition = (walkingSpeed*-1);
moveX();
detectHitBoundary();
detectHitHotspot();
detectHitSide();
if (wallCollide == true) {
xPosition = walkingSpeed;
moveX();
}
} else if (Key.isDown(Key.RIGHT)) {
_root.movCharacter.gotoAndPlay("charMoveRight");
keyPressed = "right";
xPosition = walkingSpeed;
moveX();
detectHitBoundary();
detectHitHotspot();
detectHitSide();
if (wallCollide == true) {
xPosition = (walkingSpeed*-1);
moveX();
}
}
} else {

_root.movCharacter.movCharacterUp.stop();
_root.movCharacter.movCharacterDown.stop();
_root.movCharacter.movCharacterLeft.stop();
_root.movCharacter.movCharacterRight.stop();
//_root.mainCharacter.gotoAndPlay("mainCharacterHalt");
}
function moveX() {
_x += xPosition;
}
function moveY() {
_y += yPosition;
}
function detectHitBoundary() {
wallCollide = false;
if (this.hitTest(_root.boundary1)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary2)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary3)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary4)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary5)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary6)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary7)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary8)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary9)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary10)) {
wallCollide = true;
}
if (this.hitTest(_root.boundary11)) {
wallCollide = true;
}
}
function detectHitHotspot() {
if (this.hittest(_root.hotspotCorkboard) and (keyPressed == "up")) {
_root.txtHotspotTitle.text = "My Schedual";
} else if (this.hitTest(_root.hotspotExit) and (keyPressed == "up")) {
_root.txtHotspotTitle.text = "Exit?";
} else if (this.hitTest(_root.hotspotComputer) and (keyPressed == "down" || keyPressed == "right")) {
_root.txtHotspotTitle.text = "Contact Information";
} else if (this.hitTest(_root.hotspotSchoolwork) and (keyPressed == "down")) {
_root.txtHotspotTitle.text = "School Work";
} else if (this.hitTest(_root.hotspotPrinter) and (keyPressed == "down")) {
_root.txtHotspotTitle.text = "Printer";
} else if (this.hitTest(_root.hotspotTV) and (keyPressed == "down")) {
_root.txtHotspotTitle.text = "News and Media";
} else if (this.hitTest(_root.hotspotGames) and (keyPressed == "down")) {
_root.txtHotspotTitle.text = "My Future Plans";
} else if (this.hitTest(_root.hotspotFilingCabinet) and (keyPressed == "left")) {
_root.txtHotspotTitle.text = "Pickup Resume?";
} else if (this.hitTest(_root.hotspotDresser) and (keyPressed == "left")) {
_root.txtHotspotTitle.text = "Awards Gallery";
} else if (this.hitTest(_root.hotspotCloset) and (keyPressed == "up")) {
_root.txtHotspotTitle.text = "Open Closet?";
} else if (this.hitTest(_root.hotspotStorage) and (keyPressed == "right")) {
_root.txtHotspotTitle.text = "Old Stuff";
} else if (this.hitTest(_root.hotspotIntrests) and (keyPressed == "down")) {
_root.txtHotspotTitle.text = "My Intrests";
} else if (this.hitTest(_root.hotspotBed) and (keyPressed == "up")) {
_root.txtHotspotTitle.text = "Experiences";
} else {
_root.txtHotspotTitle.text = "";
}
}
function detectHitSide() {
if (this.hittest(_root.sideRight)) {
_root.movWindow._x = 191;
_root.movWindow._y = 240;
} else {
_root.movWindow._x = 613;
_root.movWindow._y = 240;
}
}
}

CyanBlue
03-17-2003, 09:08 PM
Cool Flash movie you have there... ;)

Are you talking about this not being working???
if (Key.isDown = true)
{
// blah blah...
}
else
{
_root.movCharacter.movCharacterUp.stop();
_root.movCharacter.movCharacterDown.stop();
_root.movCharacter.movCharacterLeft.stop();
_root.movCharacter.movCharacterRight.stop();
//_root.mainCharacter.gotoAndPlay("mainCharacterHalt");
}Why not put trace("Loop Working???"); within the block and see if that trace() shows you something???

Maybe I am wrong, but that goes with the if condition where it should be different... In other words, I don't think that if condition is valid at all... What you have there is just to assign true to Key.isDown... Know what I mean??? I'd use Key Listener if I were you rather than running it all in the onEnterFrame... Oh... Is it F5 or FMX???

Oh... What boundaryX loop??? I don't see it...

Please use code formatting (http://www.actionscript.org/forums/misc.php3?action=bbcode#buttons) next time when you post your code... It's hard to read your code... :(

Noxxem
03-17-2003, 09:18 PM
Thanks :) It's almost an exact model after my room ;P Well, as exact as vector graphics can take it.

Ok, I did the trace and it doesn't register.

I was trying to go for a;
if Key.isDown = true then {do something}, else {stop movCharacter from walking}. It works otherwise.

I'm using FX ... and what is key listener? I'm an old F4 and F5 user and am not too intune with FX's new features. can key listen do stuff if there is no keyDown present?

And I was talking about the function detectHitBoundary()

-> nm, i got what listeners are ... allot of work to change though and this has to be handed in tomarrow ^-^

CyanBlue
03-17-2003, 09:36 PM
Yes... That's what I thought...

As I was saying, that if condition is not valid, which results in the part of true goes on, not the false part...

A simple Key listener example would be...arrowListener = new Object();
arrowListener.onKeyDown = function()
{
if (Key.getCode() == 37)
trace("Left");
else if (Key.getCode() == 38)
trace("Up");
else if (Key.getCode() == 39)
trace("Right");
else if (Key.getCode() == 40)
trace("Down");
};
Key.addListener(arrowListener);Put this script into the new movie's first frame, and play to see the arrow key detected... If you are to use this instead of onEnterFrame loop, you know what you have to replace... This Key listener will reduce the CPU load big time since it only gets revoked when the key is pressed...can key listen do stuff if there is no keyDown present?I don't understand this question... Did I answer it above by any chance??? ;)

detectHitBoundary() function... What seems to be the problem??? I don't think there is any... Hm...

Noxxem
03-17-2003, 09:59 PM
Heh, I did an interesting combonation of both the listener and the on enter frame.

I had to because the character's movement's were too choppy when everything was in the listener.

But, now he stops when there is a key up :D

Check it out! Now he's buggy in the sence of him starting to walk again, but it does what I need to now :D.

Thanks a bunch! :D :D :D

You're the coolest :cool: .. and I'm not saying that just becasue of your name ;)


O, in regards to the boundary loop, it work perrfectly fine .. I was just trying to get a variable into it so that I can put the code intoa function and declare the number of boundries at the beginning of each frame instead of physically having to write _root.boundary1, _root.boundary2, _root.boundary3, etc ... something like

numberOfBounderies = 12;
for (i=1, i<=numberOfBounderies, i++) {
collision = (this.hitTest(_root.boundary && numberOfBounderies))
if (collision == true) { blah blah }
}

CyanBlue
03-18-2003, 01:56 AM
Thanks for the compliment... ;)

As for the boundary checking... I'd just leave it as it is because you get to have more conditional checking in that line since you get to check the target boundary and the multiple keypressed... Know what I mean???