Solved

How can I toggle between play and pause using actionscript in a flash file?

Posted on 2009-07-15
6
203 Views
Last Modified: 2013-11-11
I have a .fla file that I want to play/pause.  I have inserted the actionsript below onto the button layer.  The button is only visible on the very first frame.  The movie plays once the button is clicked, but I am unable to pause/play the .fla file once the button has been clicked the first time.
import flash.events.EventDispatcher;

import flash.display.MovieClip;

this.stop();

function startMovie(event:MouseEvent):void {

	this.gotoAndPlay(2);

}

mybutton.addEventListener(MouseEvent.CLICK,startMovie);

Open in new window

0
Comment
Question by:tprofits
  • 3
  • 3
6 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 24868443
Hi there.
i'm a bit confused.
if the button is clicked it goes to play frame 2 where the button doesn't exist anymore, so how would they click it to stop it?
0
 

Author Comment

by:tprofits
ID: 24869886
The user is currently unable to stop the flash video.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 24876318
okay i'm sorry i don't understand what it is you're trying to achieve then.
you say you want a toggle button to start/stop the timeline. but your button is on frame 1. once the movie plays the button is no longer accessible so how do you intend for them to stop it?
0
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

 

Author Comment

by:tprofits
ID: 24877944
I think the best way would be to add a play/pause button on frames 2 through 1050.
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 24885430
you only need one button. then they can stop or start it whenever they want.
you can create a 2 frame movieclip to toggle the labels for start / stop.
i think you need to first decide what you want to do before finding out how to do it.
0
 

Author Closing Comment

by:tprofits
ID: 31603989
Agreed.  I reassessed my direction and ended up using a one button on frame 1.  Another set of buttons on the remaining frames.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

707 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

15 Experts available now in Live!

Get 1:1 Help Now