?
Solved

URGENT: Can't get gotoAndPlay work inside an onRelease function

Posted on 2007-11-22
4
Medium Priority
?
880 Views
Last Modified: 2008-02-01
Here you can find my FLA file http://dropbox.aiwmedia.com/gotoAndPlay.fla.

On frame 2 of the _root i have some lines of actionscript that control the box being dragged. The box is meant to be dragged to one of the three hitZones (the vans). On line 26 you can see an onRelease function for the box that checks if the box is on one of the drop zones and if it is it should then gotoAndPlay(21) the relevant frame in the boxContainer clip. The gotoAndPlay(21) statment is on line 31.

I can't get this gotoAndPlay to work, as you can see the trace works and proves that the if statment runs correctly. I have tried many different paths but i can't seem to find anyway to get the gotoAndPlay(21) to work. What am i doing wrong?
0
Comment
Question by:alex_wareing
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 20334995
I can't open your *.fla for some reason... Are you using Flash CS3?

Well anyway, I'd try to place a _root. before the gotoAndPlay() statement, it may help.

-V
0
 

Author Comment

by:alex_wareing
ID: 20335032
Yes its CS3. I have reuploaded in flash 8 format. I have tried _root and that didn't work
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 2000 total points
ID: 20335511
Ah, I see it now.

Check this code:

<code snippet>

You were making reference to a child object (box) of the boxContainer on the events, with this it now works correctly...

If you need anything else, let me know.

-V
boxContainer.onPress = function() { 
	startDrag(this,true);
	this._width = 77;
	this._height = 65;
}
boxContainer.onRelease = function() {
	stopDrag();
	if (this.hitTest(_root.wagonJob.dropJob)) {
		trace("Hit Job");
	} else if (this.hitTest(_root.wagonBatch.dropBatch)) {
		this.gotoAndPlay(21);
		trace("Hit Batch: " + this);
	} else if (this.hitTest(_root.wagonFlow.dropFlow)) {
		trace("Hit Flow");
	} else {
		this._width = 100;
		this._height = 85;
		this._x = -30;
		this._y = -30;
	}
}

Open in new window

0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 20335547
Lines 18 and 19 of should change though...

this._x = 167;
this._y = 297;

And maybe some other lines like this._width=100; and this._height=85; should be just after stopDrag();

-V
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question