Solved

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

Posted on 2007-11-22
4
873 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 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now