[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-11-22
4
Medium Priority
?
882 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
  • 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

Technology Partners: 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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

829 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