• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

Behavior generated script not working

I'm working on a project with Flash CS3 but I want to use the behaviors which work with Actionscript 2.0.

This is a simple button control with the script attached, that starts a movie.

The first frame has a stop(); on it.

When the button is left-clicked upon, the animation , it should go to and play frame 2. It's easy to make manually, but why don't the behaviours work? There is some problem with the instance, I think, but I've been unable to solve it.
//FROM ACTIONSCRIPT 2.0 BEHAVIOUR
	//DOES NOT WORK!!
	//---------------------------------
 
on (release) {
 
	//Movieclip GotoAndPlay Behavior
 
	this.square1.gotoAndPlay("2");
 
	//End Behavior
 
}
	//---------------------------------
 
 
	//CODED WITH SCRIPT ASSIST (2.0)
	//WORKS
	//---------------------------------
 
on (release) {
	gotoAndPlay(2);
}

Open in new window

button.txt
0
Jason210
Asked:
Jason210
  • 3
  • 3
  • 2
1 Solution
 
CyanBlueCommented:
My guess is that Flash is not finding the this.square1 movieClip...

Try this and tell me what you get in the Output panel...

on (release) {
 
        //Movieclip GotoAndPlay Behavior
        trace("this.square1 = " + this.square1);
        this.square1.gotoAndPlay("2");
 
        //End Behavior
 
}
0
 
Jason210Author Commented:
Perhaps you can just check the file?
0
 
Jason210Author Commented:
This is what the output gave with your code. What's your script doing by the way?

this.square1 = _level0.square1
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
CyanBlueCommented:
Doh...  The quotes...  Try this instead and let me know if it does the job...

     this.square1.gotoAndPlay(2);

Not everybody is fortunate to have CS3 if you know what I mean...  :(

CyanBlue
0
 
julianopolitoCommented:
Just looked your fla. It's simple:

That's occuring because you've choosen square1 in the behaviour panel, but there is no animation INSIDE square1. square1 is being used in THE TIMELINE, so you must play THE TIMELINE. Just choose _root in the behavior panel and it will work.

Juliano Polito
0
 
julianopolitoCommented:
Just for you to be sure of what I'm telling you, take a look at the script generated by the assist. it says gotoandplay(2) without refering to any object. Take a look at the picture attached.
example.jpg
0
 
Jason210Author Commented:
Thanks. I understand & it makes sense.

I'm new to using scripts in Flash, and this what I'm working on now is taken directly from a video tutorial on www.lynda.com.

The video tutorial says you should choose the instance, eg square one.

However, this mistake has helped me solve another problem - how to contorl a movie clip.

I'll award the points later when I've tested it on my PC.

0
 
julianopolitoCommented:
perfect.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now