Loop # of times, stop at specific frame
Hi there,
I'm having trouble finding the answer to a simple (I hope)
question. I made a flash banner and have successfully added an
action that will loop it 3 times, stopping on the last frame. Here
is the code I entered in a separate action layer:
INSERTED A KEYFRAME IN FRAME 1:
if (numberOfTimesToLoop<3) {
gotoAndPlay(1);
numberOfTimesToLoop++;
} else {
stop();
INSERTED A KEYFRAME IN MY LAST FRAME OF THE TIMELINE:
if (numberOfTimesToLoop<3) {
gotoAndPlay(1);
} else {
stop();
Works beautifully, only I need the movie to stop on frame 274
on the last loop, where I want certain elements not to fade out (I
have 279 frames in my movie). Can anyone help me out? I'd really
appreciate it!
I'm not sure I understand what code I'm supposed to put in
frame 279 exactly.. There are two elements (on two separate layers)
that need to stop at that frame on the 3rd loop.. I tried putting
something like this on frame 279 of one of those layers:
if (numberOfTimesToLoop=3) {
stop();
O so close.... but like with all code its either all right or all wrong.
the 2 diffrent layers don't matter if your stoping the main timeline.
go to frame 279 open up your ActionScript window and type in:
if (numberOfTimesToLoop == 3) {
stop();
That is little guy is called a
Comparison Operator
http://flash-creations.com/notes/actionscript_operators.php <==good site discribing them.
Good luck and I hope it helps
JT
Similar Messages
-
Measure the time in a specific frame of a flat sequence
Hi I have a labVIEW program with a flat sequence and I would like to stick in a small SubVI which measures how long it stays within an individual frame to confirm the delay I have used. Does anyone have any code or any tips on what I could add which sets a timer going when I enter the frame and spits out the answer to a numeric indicator when it goes to the next frame.
Any help would be appreciatedsrikrishnaNF wrote:
hi mr_nice,
Use time elapsed vi...
Thanks and regards,
srikrishnaNF
Please add where you find this vi.
Check out this video here. It might be useful for you when he talks about the flat sequence structure and how to get elapsed time from it. It starts at about 7 minutes into the movie. He's using Tick Count.
Also here you can find useful information
Regards,
Even
Certified LabVIEW Associate Developer
Automated Test Developer
Topro AS
Norway -
Getting a FLV to loop back toward a specific frame using Netstream (as3)
To preface this my knowledge of AS3 is quite novice. As the thread titled reads, I'm trying to get an FLV to play through it's entireity and then loop back towards a specific frame and keep replaying from the point endlessly. After a lot of digging I found a video tutorial using AS3 that worked! Here's my situation now though, I cannot find the right code to insert to make the video loop back to the frame that I want. The FLV just stops and doesnt rewind at the end of the video. Here is my code so far:
var video:Video = new Video(1980, 1020);
addChild(video);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var meta:Object = new Object ();
meta.onMetaData = function (meta: Object)
trace(meta.duration);
ns.client = meta;
video.attachNetStream(ns);
ns.play("All.flv");
Ultimately, the video needs to play all the way through only on the first load and then loop back to frame 319 and play toward the end and loop back again to frame 319 infinitely. I think I'm almost there, I just need some assistance with getting my code working appropriately. I done this before using "gotoAndPlay()" but the loop isnt seamless thus it yields a one second pause before looping back. I'm hoping using a Netstream function that this will be resolved. I would appreciate any help!Okay let me try and get this checked through you before I attempt to implement what you've recommend for a seamless loot at the aformentioned time in the previous post:
var video:Video=new Video(1980,1020);
addChild(video);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
ns.addEventListener(
var video:Video=new Video(1980,1020);
addChild(video);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream=new NetStream(nc);
ns.addEventListener(Event.ENTER_FRAME,); <-----not too sure about the rest of the syntax here
ns.client = this;
video.attachNetStream(ns);
ns.play("All.flv");
function onMetaData(obj:Object):void{
trace(obj.duration);
function netStatusF(e:NetStatusEvent):void {
switch (e.info.code) {
case "NetStream.Play.Stop":
ns.seek(10.6106);
break;
Hmmm, curious about where the"loop" and ns.time syntax should be placed. -
Timer stops during in loop while continuous operation
Hi, all
I have a sequence loop in while loop that is controlled by a "elasped time function". After several hours of program operation, the timer stops and causes cycle to freeze. This always happens (about 1-10 hours after run start) despite the length of cycle steps. I cannot determine the cause of this problem and any insight is appreciated. I use Labview 8.2v and have attached the vi and screen capture of the function loop.
Attachments:
RH cycling.vi 394 KB
block.JPG 125 KBswsyoon wrote: I'm just wondering if all the loop needs a wait statement. Is it more stable for the program?
Wy wait comment was just generi. Most likely it is not the caouse of your problem. Any while loop should only spin as often as needed. For example, to update a timer, the loop rate should depend on how many decimal digits of the time you need to show. SInce your code runs for a long time, maybe once/second is entirely sufficient.
Still, this is certainly not the cause of your problems but it is impossible to debug your VI.
We cannot run your VI, because of missing subVIs.
Do you know if any of your subVIs contain third party DLLs?
Your entire code structure is designed inside-out, making very little sense.
What's the story with the start button? Are you using the "continuous run" button to operate this VI??? Don't!!!
What's the story with the big case structure tied to the tab structure? Since your code is inside-out, operating the tab during run makes no difference in the code. Large portions of code are inaccessible.
You have extrememly confusing code the way you wire in and out of frame one at the bottom. Maybe that code at the bottom should all go inside the first frame.
You error handling is no handling at all. You just display the error indicators. Shouldn't the code depends a little bit on error status?
Even the UI is confusing. Labeling a stop switch with ON/OFF makes no sense. You turn STOP to OFF to stop the VI.
Can you check for memory leaks? Run the VI for extended periods and see if the memory use increases over time.
Check all your subVIs. Who wrote them? All your subVIs deal with instruments and visa resources. Do you properly close all references before creating new ones? Can you attach a few of your subVIs? You constantly open Labjacks (last frame)... do you ever close them??
All indications point to a serious resource leak somewhere.
It would really be beneficial to tear down most of the code a rewrite it from scratch using a more reasonable design template. The outermost structure needs to be a while loop. What good is a tab structure if the code in the other tabs cannot run?
LabVIEW Champion . Do more with less code and in less time . -
How can I put a time delay between specific events in a while loop?
How can I put a time delay between specific events within the same while loop? I'm already using the "wait" command to control the overall loop iteration speed. But I want to time the individual events as well.
Hi Jesse,
You can use a flat sequence. In each box you can put your individual events and attached wait.
Don't forget to reduce your total loop time of the time you added in the individual sequences.
Doc-Doc
Doc-Doc
http://www.machinevision.ch
http://visionindustrielle.ch
Please take time to rate this answer -
Button link to a specific frame in time line
Ok I have created my buttons and the content for the specific
frames. I have named the button and given it an instance name. I
have also given my specific frame a name and set that label type to
Name.
Whats the code for turning getting my button to link to a
specific frame?
I've also done the stop() code in each frame as I want it to
stop at each frame until the button is clicked again.
I have more than one button and each will link to a different
frame.
Thanks.I've duplicated an FLA with exactly the assets you have in
the same places, with the code on the main timeline. And mine
didn't work, just the same problem as you had. The solution I
proposed above works, but it is not the only way (See #2 below).
On Frame 1, select the UIScrollbar. if you look in the
Parameters tab of your UIScrollbar component, you'll notice that
the
scrolltargetName refers to
Instance_0. This is a default instance name assigned by the
Flash compiler, because you did not give your dynamic textfield an
instance, and your UIscollbar is referencing that. Now go to Frame
4. You will find that your dynamic textfield has the same instance
name, and the UIScrollbar is referencing the same instance. Problem
is, you have more than one textfield on more than one frame using
and referencing the same instance name, your UIScrollbars will get
confused as to which textfield is actually "Instance_0". The moment
you click to another frame, you've confused the UIScrollbar(s), so
they never work again.
The solution is simple.
First, put a stop() action on the first frame, if you have
not already done so, so your timeline stays put until you click on
a button.
Then you can solve the problem in one of two ways:
Give your textfields different instance names, and make sure
the
scrolltargetName property of each UIScrollbar refers to its
respective textfield.
Or set the text dynamically, which after all is what a dynamic
textfield is for. Have only one textfield/UIscrollbar combo, on the
first frame, and place code on a keyframe for each section which
changes the
text or
htmlText property of the textfield.
That should work. It did on mine. -
Can't get flash video to stop looping even when i use stop(); in last frame
I have only just started using Flash so im sure im doing this wrong but in tutorials i have watched to stop the video looping you put stop(); in the last frame. I have done that but the video still loops... Anyone know where i am going wrong?
If the question is related to Adobe Presenter, I would recommend associating the SWF with the presentation play bar. This will allow the player to control the playback of the SWF and can move on to the next slide when the amount of silence (ideally equal to the duration of the SWF) has passed.
If this is a question related to Flash, I'll move it to the correct forum. -
Can PrE do multiple specific frame searches?
I'm trying to find a not too expensive editing program, possibly PRE 10, that will allow me to do a search in a video for specific frame locations based on criteria within a frame. I've done exhaustive searching on web to no avail so far. I've been using Corel Videostudio which doesn't have anything like that.
Specifically I want to search the infamous Norwegian Bergne/Oslo train ride video, all seven hours of it. The video consists of the uninterrupted train ride, which by itself is great to watch except for one thing.
Every time the train passes into a tunnel, or reaches a town, a blue sign drops down from the top of the screen with the location's name. That's not so bad, but then someone has inserted a very loud gong sound at that moment, totally destroying the relaxing ambience of the video.
What I want to do is find each occurrance of this event, which is about four seconds long, and replace the audio gong sound with either silence or filler. The bad part is that there are easily a hundred plus of these, probably over 200.
So I'm hoping that some program, somewhere, would be able to either find all of them at once, or quickly 'step' forward to each so I don't have to slowly play the video, stop, insert, hoping I don't miss one, etc. It would search keying on either something in the video frame like the big blue sign, or the sound, it really doesn't matter what.
I've broken the video up into 30 minute segments to make editing easier and faster.
Any advice or recommendations would be greatly appreciated!
Thanks!I know of no NLE program, that offers the ability to match, or search frames. While I have not used them all, and some many versions ago, I do not recall such a function in AVID (Liquid, or Composer), PrPro, Pinnacle Studio, Magix MovieEdit Pro or CyberLink's PowerDirctor.
There might be some forensic programs, that can do this, but not sure that anyone, outside of law enforcement would have access to it.
Maybe others know of such software.
In PrE, about the best that I can think of is to use the Jog Shuttle in the Program Monitor, and visually watch, as the footage goes by very quickly, stopping when one reaches a tunnel, or town.
Good luck,
Hunt -
How to play a soud at specific frame?
I have the loading audio file at frame one. However, I want to play the audio only at specific frame or frame lable. How do I do that? Below are my codes:
//start of sound section is for sound
var soundReq:URLRequest = new URLRequest("FlashFiles/audioFiles/mySoundmp3");
var sound:Sound = new Sound();
sound.load(soundReq);
sound.addEventListener(Event.COMPLETE, onComplete);
//end of sound section
function onComplete(event:Event):void
sound.play();
The above plays the sound as soon as the .swf file is loaded. But I want to play at certain point in time, say frame number or frame lable.Okay, here are my code in frame one:
//start of sound section is for sound
var soundReq:URLRequest = new URLRequest("FlashFiles/audioFiles/Alma Mater plus roc.mp3");
var sound:Sound = new Sound();
sound.load(soundReq);
//sound.addEventListener(Event.COMPLETE, onComplete);
//end of sound section
this.addEventListener(Event.ENTER_FRAME, playSound);
function playSound(e:Event)
if(e.currentLabel == "lblStartSound")
this.removeEventListener(Event.ENTER_FRAME, playSound);
sound.play();
this.btn_Skip.addEventListener(MouseEvent.MOUSE_DOWN, skipFlash);
function skipFlash(event:MouseEvent):void
gotoAndPlay("frm_Ending");
sound.stop();
Errors I got are:
1119: Access of possibly undefined property currentLabel through a reference with static type flash.events:Event.
Source: if(e.currentLabel = "lblStartSound")
1061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound.
Source: sound.stop();
Eventually, if the user click the skip button, I want to stop the sound. -
Avoid repeating a 'for' loop 3 times
Any ideas how can I make my code more efficient by not
repeating the for loop 3 times within a script? Any tutorial links
or first hand experience – I’d be grateful for any
pointers:
1) First I use it to set up a drag n’ drop activity:
for (var i:Number = 0; i<words.length; i++) {
//set a var for the instances on stage:
var eachWord:String = "drag"+[i+1]+"_mc";
this[eachWord].word_txt.text = words
[0];
this[eachWord].onPress = function() {
startDrag(this, false, leftLimit, topLimit, rightLimit,
bottomLimit);
this[eachWord].onRelease =
this[eachWord].onReleaseOutside=function () {
this.stopDrag();
2) Then I use it in the part that makes it accessible by
keyboard:
function myOnKeyDown() {
for (var i:Number = 0; i<words.length; i++) {
var thisDrag:String = "drag"+[i+1]+"_mc";
if (Key.isDown …
ETC along with a listener object
3) I also have to use it in another function that the user
can call to toggle something on/off within each drag object.
Thanks in advance if anyone can help.thanks for the reply! I actually figured out a different
(although probably less efficient) way to do it. I put David's
script just before the replay button and set it up like this:
stop();
gotoAndPlay(1);
if (!loopCount) {
var loopCount:Number = 0;
loopCount++;
if (loopCount >= 3) {
this.gotoAndPlay(359);
this was placed at frame 358, with the button placed at 359,
so after it looped 3 times it continued on to 359, showed the
button and stopped the movie there. again, not the most elegant but
it did the job -
Is it possible to load an external swf at a specific frame?
Hey! I've got a flash file which acts as the main menu for a
program I'm developing. Everything works fine from the main menu
however when you click to return to the main menu the whole main
menu file reloads. Is it possible to use loadMovieNum( ) to go to a
specific frame within the main swf file? If not, is there a way to
do this?
Here's the button code I'm using now:
on (release) {
unloadMovieNum(0); //unloads the current movie so we can
reload the main menu
loadMovieNum("DemoMainMenu.swf", 0); //reloads the main menu
Thank you for whatever help you can provide! :)mcommini wrote:
> Hey! I've got a flash file which acts as the main menu
for a program I'm
> developing. Everything works fine from the main menu
however when you click to
> return to the main menu the whole main menu file
reloads. Is it possible to
> use loadMovieNum( ) to go to a specific frame within the
main swf file? If
> not, is there a way to do this?
First let me clarify one thing with you. Level zero is the
main level on the flash
player. By loading things in level zero you will remove
current content and replace
it with the new one. This is not a good idea because it works
like purge, clears the
player and from there on you can't maintain any functionality
unless you reload the
whole html document over again. Also, do not unload and load
in the same time in the
same level. Flash can hold single SWF per level, once you
load content, whatever previously
loaded will be automatically replaced, so just the loadMovie
action and you all set.
Good practice is to have the main level (zero) an empty base
and than load and unload
things in above levels, 1 and so on...
> Here's the button code I'm using now:
> on (release) {
> unloadMovieNum(0); //unloads the current movie so we can
reload the main menu
> loadMovieNum("DemoMainMenu.swf", 0); //reloads the main
menu
> }
>
In regard to the load and go to. Yes it is possible but no
matter what frame you want to
go to,you need to load the whole movie first. I will come
back to that in a second.
While you execute the loadMovie action, you can set up a
variable, for example:
loadMovieNum("file.swf", 1);
Variable="mcommini_01";
Than in the loaded movie you have preloader which makes sure
that the movie is loaded before
playing and once done loading, make it jump to frame which
has IF ELSE condition in some kind
of loop, using setInterval or Enterframe. That condition
checks for the variable value and based
on it proceed to particular frame.
That's why I told you not to clear level zero, if you set
variable and load movie in that level
in the same time, all the information will be gone and you
have totally no reference point to
get the variable from.
You could as well use shared object which is native form of
Flash's cookies. Write SOL file into
user drive temp folder, than read it from the other file and
go to frame based on the given value.
Best Regards
Urami
Beauty is in the eye of the beer holder...
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Looping movie clip stops in middle
I am using a movie clip as part of a game. It's a clip of a
spaceman walking.
When the game is being played, the movie seems to loop one
time (the spaceman walks one cycle), and on the second time around
the animation seems to stop right in the middle of the cycle. it
always stops on the same frame.
What is happening here?
Thank youOkay, great, and what about the last line? What is that for?
Do i put my keylistener info after that line?
I'm still a little puzzled about where to put the script that
you just offered me.
But before I get to that, let me ask you a question about my
current code. Below I've pasted the beginning of the code that I
have for Key Down. My question is: Is this code going to execute
over and over again? Is this code a "key listener"?
_root.onKeyDown = function() {
///keyDOWN!!!
whichKey = Key.getAscii();
if ((whichkey == _root.jumpkey) or (whichkey ==
_root.jumpkeycaps)) {
if (_root.mov == "walkleft") {
_root.mov = "jumpleft";
_root.vertspeed = 24;
if (_root.mov == "walkright") {
_root.mov = "jumpright";
_root.vertspeed = 24;
if (mov.toLowerCase().indexOf("stop") != -1) {
_root.mov = "jumpup";
_root.vertspeed = 24;
} -
*Flash animation looping but going back to first frame {want to hold on last frame}
I came across this article on looping animations = http://www.quip.net/blog/2006/flash/how-to-loop-three-times
I'm a novice with flash and just trying to plug thru to get some ads up and running for the first time.
Everything worked for me in the article...the one thing I wanted to do but haven't found an answer to is how to stop the animation on the last frame after looping is complete, instead of automatically going back to the first frame??
What's the easiest/most effective way to do this?
The stop script does not work...still goes back to first frame.
For all my flash ads, I've imported an FLV video...so don't know if it's some function for flv's/video's that auto-rewinds to first frame...
Thanks so much, really appreciate any insight on this.
The sooner you can catch a minute to get back the betterOk...not working for me - prob. b/c I'm missing something again.
What I did was...
1) Renamed the instace of replay button = "replay_btn".
[not sure if that's correct...guessed b/c you reference it in the code]
2) I placed this in the action code on action layer on last keyframe =
var loopNum:Number;
loopNum++;
if(loopNum%3==0){
stop();
your_replay_btn._visible=true;
} else {
your_replay_btn._visible=false;
3) I placed this in action code on the replay layer on last keyframe =
your_replay_btn.onRelease=function(){
this.gotoAndPlay(1);
What happens is the replay button still flashes at the end of each loop and the loops just continue...it doesn't stop at 3.
I also get this error =
Can you break down what I'm doing wrong and how to fix...need to get this out asap.
I truly appreciate your help and time so far on this...big thanks kglad! -
My Macbook Pro will be going in for reimaging and my hard drive will be wiped, I want to know if all my iTunes preferences will be copied if I have backed them up on Time Machine. Specifically, if I have set certain "Start Time" and "Stop Time" for my songs, and I copy my iTunes library, will these "Start Time" and "Stop Time" options remain or will I have to manually set them one by one once again? I need a reply ASAP! Thanks so much!
As far as I'm aware the start & stop times are stored in the library database, not the media files. If you backup/restore/transfer the whole library then the settings are included. If you create a complete copy of your iTunes folder on another drive you can connect to that copy by holding down option/alt as you start iTunes so you can check that everything is working properly before you send the Macbook away.
tt2 -
GotoAndPlay specific frame in external swf from main swf
I have a main swf that loads 2 external swfs.
I click on button to see content of external swf #1 and see stuff. I do something that causes external swf to show other stuff (i.e. not at beginning state)
In the main swf I click on button to see content of external swf #2. External swf #1 content is made invisible and I see content of external swf stuff.
NOW, if I click on button to take me back to see external swf #1, I see it's content in current state. I want to force it to start over again at frame #1 which will reset content.
However, no matter what I try, I can't seem to control which frame to go to in external swf using gotoAndplay.
Here is code in frame #1 of main swf to load external swfs:
//load academic movie
var swfLoader1:Loader = new Loader();
container1.addChild(swfLoader1);
var url1:URLRequest = new URLRequest("academic.swf");
swfLoader1.load(url1);
//load wisdom movie
var swfLoader3:Loader = new Loader();
container3.addChild(swfLoader3);
var url3:URLRequest = new URLRequest("wisdom.swf");
swfLoader3.load(url3);
Here is code in frame 2 of main swf that checks button to see where to go in external swf:
//academic button clicked
function academicClick(event:MouseEvent){
container3.alpha = 0;
container3.visible = false;
container1.visible = true;
container1.gotoAndPlay(1); //this is where I am trying to force it to start at frame 1
container1.alpha = 1;
I don't want to reload the external movie to force it to start over.
Any help would be much appreciated.You can easily control this by making the external swf to load with your movieclip, The below is the code snippet that clear on accessing the specific frame on external swf.
//Loading clips content
var ldr:Loader;
var mcExt:MovieClip;
//Loading
loadswf("external.swf");
function loadswf(tmp:String):void{
unloadSwf();
ldr= new Loader();
ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
ldr.load(new URLRequest(tmp));
function progressListener (e:ProgressEvent):void{
ploader.visible=true;
function swfLoaded(e:Event):void {
mcExt = e.target.content as MovieClip;
ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoaded);
mcExt.addEventListener(Event.ENTER_FRAME,onEnterfn);
ploader.visible=false;
addChild(mcExt);
//UnLoading
function unloadSwf():void{
if (ldr!=null){
ldr.unloadAndStop();
removeChild(mcExt);
mcExt=null;
//Intervals (The part you work on the specific frame within the external swf
function onEnterfn(e:Event):void{
var num:int=mcExt.currentFrame;
if (num==1) mcExt.play();
if (num==9) {
mcExt.skipmc.addEventListener(MouseEvent.CLICK,skipfn);
function skipfn(e:MouseEvent):void{
mcExt.stop();
mcExt.removeEventListener(Event.ENTER_FRAME,onEnterfn);
gotoAndStop("help");
if (num==mcExt.totalFrames){
mcExt.removeEventListener(Event.ENTER_FRAME,onEnterfn);
gotoAndStop("help");
hope it solve
Maybe you are looking for
-
Dear Bhudev/Guest, I am Planning to refresh my Quality system from Production's Offline Database Backup. I have seen you a lot posts. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Refresh from Offline backup (
-
Unreliable sound - speaker symbol greyed out and red light in 3.5mm jack
Had my MacBook for 3 years with no problems. But over the past few months, the sound has been very unreliable. It always works when external speakers are plugged in, but when using the internal speakers it's very temperamental. It will just suddenly
-
Items saved in the Reading List keep disappearing?
I've only just started to use the Reading list functionality after upgrading to OS X Lion recently. However, on the occasions used the items "saved" to the Reading List have been lost the next time I come to look for them after shutting down my Macbo
-
Hi, i'm creating the following table and having this error: ERROR at line 8: ORA-00907: missing right parenthesis This is the sql: CREATE TABLE baditemlist ( idbaditemlist NUMBER(16), idproducttypelist NUMBER(3), item VARCHAR2(20), CONSTRAINT pk_idba
-
I am using spouse's old Mac Air - how do I change all ID to me now?
How do I change Macbook Air using OS X YOSEMITE 10.10.1 to my apple id and not my spouse who has a new apple computer?