ActionScript 3.0 :: Timeline Code Firing Two Times After Goto*()?
Sep 14, 2009This is my movieclip, its on the root:frame1 code:
Code:
trace("clip()");
stop();
[code]....
This is my movieclip, its on the root:frame1 code:
Code:
trace("clip()");
stop();
[code]....
i wrote this code:
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
[code]....
and it works, once clicked, it does what it has to do. Ofcourse, me trying to break it, i found that if i click the buttons fast, it will re-import the external swfs causing me to have multiple instances of the external swf.so in short, if i click like normal(slow ) ie like a person that clicked to view a section etc, then its fine, if i click fast or repeated clicking ie like a person that double clicks etc, then the problem occurs.
I'm trying to do a simple url requestion on enter frame, but it seems to be executing multiple times?
I tried removing the event handler on handleLoadSuccessful, that seems to stop it firing infinitely, but its still executing about 10 times before it stops. How do I make it only fire once?
addEventListener(Event.ENTER_FRAME, onLoadHandler);
function onLoadHandler(event:Event) {
var scriptRequest:URLRequest = new URLRequest("http://ad.doubleclick.net/clk;254580535;19110122;t?http://www.gamespot.com.au/Ads/gswide/hp/1x1.gif");
var scriptLoader:URLLoader = new URLLoader();
[Code]...
i wrote this code:
[Code]...
} // end btn4Loaded. and it works, once clicked, it does what it has to do. Ofcourse, me trying to break it, i found that if i click the buttons fast, it will re-import the external swfs causing me to have multiple instances of the external swf. so in short, if i click like normal(slow ) ie like a person that clicked to view a section etc, then its fine, if i click fast or repeated clicking ie like a person that double clicks etc, then the problem occurs.
here's a part of my code:
player_mc.onEnterFrame = function() {
if (enemy0.hitTest(this)) {
enemy0.speed = 0;
} else {
[code]...
Note the red code, I need to repeat this an unknown amount yet multiple times but with the number on the end of enemy incremented by 1 each time. It starts with 0 as you can see the code just above the red. I heard about for loops using 'i' but im unsure about how to use it.
edit: ah, this forum isnt letting me highlight red. Everything in this editor is also failing. well, when I say code in red i mean this code:
if (enemy1.hitTest(this)) {
enemy1.speed = 0;
} else {
enemy1.speed = 1;
}
I have some code that is supposed to detect if a movie subsection is currently "active" or "destroyed", and respond to these conditions. When a subsection first loads it sets _root variable "state" to "active". When a new menu item is rolled over, it triggers several events. It tells current movie to destroy itself. On the final frame of the movie subsections they change the _root variable "state" to "destroyed". After the button tells the current movie to play destroy, it begins an on enter frame function that looks for state to be != to "active" (I've tried == "destroyed" here as well). [code]...
View 3 RepliesThis is problem is cropping up in Flash CS3 rather than Flex, but it's Actionscript 3.If you paste the code below into the main timeline on frame 1 and test it in Flash, the COMPLETE and INIT events both fire. And in Firefox and Safari it works too. INIT and COMPLETE both fire. But in IE (6 and 7, both with the latest flash player) on a PC only the INIT event fires.
Code:
var debugText:TextField = new TextField()
addChild(debugText)
var onRootLoaderInit = function (event:Event):void{
debugText.text += "INITIATED." + " "
} var onRootLoaderComplete = function (event:Event):void{
debugText.text += "COMPLETE." + " "
} loaderInfo.addEventListener(Event.INIT, onRootLoaderInit);
loaderInfo.addEventListener(Event.COMPLETE, onRootLoaderComplete);
event listeners not firing in this code can anybody guide me what is problem with this code.[code]
View 2 RepliesI have seemed to have forgotten how to go from a movieclip to a frame in the main timeline. I have done it a few months back but I dont have the fla right now to reffer.
View 4 RepliesI have seemed to have forgotten how to go from a movieclip to a frame in the main timeline. I have done it a few months back but I dont have the fla right now to reffer.
View 4 Repliesstop ()
Is there a fucntion what will play a timeline two times and after it stops ?from frame 1 to 15 i want it to play two times and stop after. I dont want to duplicate timeline
After the HitTest, How do I use the gotoAndPlay to direct the the main timeline to goto frame 2, and not frame 2 of _root.circle MC? with _parent?
I know this might be a simple question, but my brain hurts from the previous 'debugging'.....
both of these give me the same results.
onClipEvent (enterFrame) {
if (_root.circle.hitTest(_root.box1)) {
gotoAndPlay(2);
;
[Code].....
I have a main flash file that I load various external swf files into. On the first frame of the timeline, there is an intro swf loaded that basically welcoming the viewer to the site. What I want to do is have this load, play and unload and then go to frame two of the timeline where the main home section of the flash site is located.One my first frame on the timeline I have:loadMovieNum("/IntroMovie.swf",1);stop();n the external IntroMovie, I have unloadMovie (1); so the movie will play and then unload itself. What I can't figure out is how to get the timeline to go to the next frame once this movie is finished playing and has unloadedIf I don't put the stop in there, it simply skips this movie and goes to the next frame on the timeline and loads the home movie swf file.Is there a way to use some sort of if statement, that if the movie is unloaded, goto the next frame, sort of like this:if(code to verify if movie is unloaded);gotoAndStop(2);
View 4 RepliesI'm trying to have a button go back to the main timeline and then goto another mc nested in another mc. For some reason it the output section when i test this says the following...Target not found: Target="_root.printmc" Base="_level0.instance8.instance29" Here is the script I have on the button.
on (rollOver) {
gotoAndPlay("move");
}
on (press) {[code]....
I'm stumped on getting my coding movie consisting only of tweens to just play 3 times and stop on last frame. I'd also like it to delay and stay on last frame about 10 seconds and/or delay before playing the first frame about 2 seconds. that stuff i do now with timer events- I set both for the interval (100000 and 2000) and repeat is set to one for each, with a timer on the last and first frames. (not sure if that's the best way to do that)
View 3 RepliesI am trying to play a banner ad 3 times and then stop for a banner ad. Does anyone know how to do this using actionscript. I have tried and failed.
View 2 RepliesI have a button that is loaded into my main movie at level 2. in my main movie on the timeline I have a frame label called guestbook. I want my button, when released to go to trigger the frame label. on my button i have the script:
on (release) {
_root.gotoAndStop("guestbook");
}
Obvously this does not work because it references the wrong timeline so i tried:
on (release) {
_parent.gotoAndStop("guestbook");
}
thinking that somehow it would see the parent swf and work - haha - me and my dumb ideas of course it doesnt work.do you know how i can get it to work. Perhaps i should mention that the button that loads in at level 2 is inside a movie clip (for reasons of animation)
As stupid as my question might sound, i have spent the last 2 weeks reading oop books; but could use some guidance. I have a flash project that is basically a supped up slide show. On the stage i have the following: main_mc (instance name = images_mc) = movieclip which holds "pictures" ui1 (instance name = ui1_mc) = user interface that allows user to draw on picture (when drawing is enabled) ui2 (instance name = ui2_mc) = activates invisible hit areas (buttons) on select pics, when hit area is clicked, we jump to another pic in the main_mc.
I accomplished all of this on the timeline, but am updating the code to OOP. I am having A HELL OF A TIME trying to figure out how to store references to the instances (images_mc etc..), so i can control them from varying class files. I have found it is easy to control the instances from the documentclass, but not from unrelated class files. Example: images_mc.stop(); works in document class; but ovieclip(Parent).images_mc.stop() doesn't seem to work from any class file.(ui2 class file for example);
[Code]...
I'm looking for a way to have my main timeline code interact with code inside of a symbol.I'm tying to get my timeline inside the symbol to gotoAndPlay(10) when something happens in my main timeline code.
View 3 RepliesIs there a way to make code on the timeline and code in a separate AS file communicate with each other?I have two buttons, a yes button and a no button.I have a confirm box which is a movie clip. In the movie clip I have the two buttons on it and code so that every time one of the buttons is clicked it runs a function.I have the rest of my code for the movie (so the code to make the confirm box appear) on a separate AS file.Is there a way I can define the functions on the movie clip and run the functions with the separate AS file?
View 7 RepliesI've been looking at other posts and trying to cobble this together, but am lost. I have a movie I need to play from frames 1-45 five times then continue from frame 50 to frame 70 and stop. on frame one I have the following script (in a layer for actions)
if (numberOfTimesToLoop<5) {
gotoAndPlay(1);
numberOfTimesToLoop++;
} else {
gotoAndPlay(50);
[Code]...
I'm creating a timeline to stop a movieclip at specific times.
Using setInterval I'd like to use an if statement to pause my movieclip at each of the times indicated by variableTimes:
variableTimes = [15, 20, 25];
if(myTimer=variableTimes){
myMovie.stop();
However, I can't seem to figure out how to give variableTimes three independent variables.
I have a movieclip called myButton,inside of myButton i have a textfield called buttonLabel. I have 16 instances of myButton placed on the stage with instancenames myButton1,myButton2, etc.I want the textfield inside of each button to display the same number as the one in their instance name. ie myButton1.buttonLabel.text = "1".instead of repeating that line of code 16 times, is there a way i can use a loop? something like
for (var i:int = 1; i < 17; i++)
{
myButton(i).buttonLabel.text = i
}
I have a very simple banner that I would like to play 3 times and stop. How can I do that in Actionscrip 3.0?
View 4 Repliesactully i create a Movie Clip by Code and i Want its appear On stage 5 times ..But its add only single Movie clip on the stage ..program has no error
ActionScript Code:
package com
{
[code]......
I have a boxer class that I would like to be able to dispatch a custom event out of at different times so the main timeline can pick it up and do something. It is at the end of different things. ie. movieclip finished playing. So far when I try to dispatchEvent it says I can't with error 1061.
View 8 RepliesI have a flash piece that I want to loop 3 times and then stop.
View 2 Repliesi'm new to AS3. how do i go about executing a custom function n number of times and then executing another function n number of times repeatedly?
eg.
function firstOne():void { }
function secondOne():void { }
i need firstOne() executed say 3 times and then secondOne() 3 times and then firstOne 3 times again and so on. i'm trying to move a movieclip 3 times to the left and then 3 times to the right continuously.
Someone asked me an interesting question on Twitter about when one should have code on the timeline as opposed to a class. My answer was never unless you are controlling the timeline itself.
After thinking more about it, is that really the correct answer? Are there other situations where you may want to have code live on your timeline even if it doesn't have anything to do with the timeline itself?
What is the script used to go to previous frame viewed as opposed to (see below) previous frame on timeline?
View 3 Replies