ActionScript 3.0 :: Waiting On A Frame For A Random Duration?
May 14, 2007
I'm looking to pause on frame 1 of a movieclip for a random amount of time before playing frame 2 and the rest of the movie. This will thus repeat and the movie will play at random intervals.how to set this up in AS3 format. how do i convert this simple line of AS2 code into a working piece of AS3 code?
ActionScript Code:
Stage.showMenu = false;
View 13 Replies
Similar Posts:
Jan 18, 2010
I am sure I will receive the beginner question of the year with this one: Just starting w/ Flash 8. Using AS2 to simply make a graphic (and its clickable area) proceed to next frame when clicked. When input : button.onRelease = function() { gotoAndStop(2) the movie proceeds to Frame 2 without a pause for the click event. I have tried a stop(); prior to the above function, but no action after click. Basically trying to understand why frame 1 with the event handler AS does not pause to accept the mouse click?
I apologize for such a basic question, but my eyeballs are bleeding from trying to figure this out.
View 1 Replies
Jan 26, 2005
how can i tell after waiting for 1 minutes go to and play frame 1 in acionscript.by the way i am using flash mx.
View 8 Replies
Jul 13, 2006
i have a movieclip on stage. it has 3 frames but is stopped with "stop():" so it only shows the first frame on mousedown i want it to play frame 2 for a duration of 1 frame then frame 3.
View 3 Replies
Oct 8, 2011
DISCLAIMER I've just started to learn flash to fulfill a class assigment. This problem probably has a very easy answer, but I can't find it and now I'm getting close to my deadline.
PROLOGUE The title describes what actions I'm trying to put in a button. I'm making a quiz. Each keyframe has a pic and 4 buttons. The correct answer should show a green V onscreen; the wrong answer should show a red X. After one second, it jumps to a new question in a new keyframe. I've made the X and V as both 12-frame movieclips and 1-frame graphics on the library, but can't seem to make them show up correctly.
1st issue: showing the movie clip/graphic. The movieclip/graphic should appear in the center of the stage *after* you press the button. Currently, the clip is there from the start; can't find a way to make it start invisible, then visible when I click the button. 2nd issue: waiting 1 second before going to next frame.I've tried using setInterval, but failed. Maybe the best way is to use a command that waits for the movieclip to play before making the jump?
[Code]...
View 6 Replies
Apr 27, 2009
I'm completely completely new to flash and the company I work for assumes I know it, even though I tell them I don't. But anyway, I was assigned to make a header that has a glowing star that flies in and becomes part of the logo. So i've done that and it looks decent. I made it just like an animation, working with individual frames, not tweens or anything like that (vocab I just learned).I need to resize it as a whole to 500 x 90 and I also need it to linger on the last frame (the completed logo) for about 10 seconds, then have the star shoot in again.
View 1 Replies
Apr 3, 2009
is it possible to make the duration of a movieclip equal the duration of the preloader, i mean is it possible to make something like, the time the preloader needs to reach the 100% = the duration of the movieclip? i'm using AS 3.0 and flash CS4 just in case it helps here is my code for the loader:
Code:
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
function loadProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
[code].....
View 1 Replies
Aug 17, 2009
I want to make a button that makes you got to a random frame within a certain range (eg frame 41-50) when you press it. I have tried various codes but so far no luck. Im using AS 2
and the button is within a couple of movie clips, but you can still click it when you test
View 1 Replies
May 4, 2010
This is something I used to know how to do in the first versions of actionscript, but I've been away from flash for a few years and am utterly lost. What I want to do is to get the movie to display random images (from a selection) for random amounts of time (subject to minimum and maximum times).
View 2 Replies
Jan 5, 2010
I am trying to read an XML file from a class, (I'm fairly new to OOP, I got the concept, how to use them and all), I want to do everything without having to break down my code to segments in a gazillion frames, so I work from the documentclass. I need to
1) load XML
2) wait for it to be loaded
3) Start working with the XMLdata
So I made a class 'queryXML' where I do all the loading, and in my Main class I setup the instance of queryXML and tell it what file to load. Now everthing runs fine, BUT i don't know how to wait in my Main-class until loading is done. My queryXML class holds a status variable and I have a method to check it.
[Code]...
View 5 Replies
Mar 13, 2010
The problem I have is that the amount of elements in my XML is variable, and I need to initially place objects on the stage depending on the data in the XML file. Both how many objects to place and their positions are in the XML file. I can't get it to wait until it's looked at the XML file before continuing through my code, obviously erroring when it doesn't know how many there are. It gets through all my code before finally coming back to run the function to grab the XML. I have tried putting setting a variable within the function, and a while loop outside the function waiting to that variable to be set, but it never happens if I do it this way.
Code:
var items:Array = new Array();
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleXMLLoaded);
loader.load(new URLRequest("[URL]"));
function handleXMLLoaded(e:Event):void {
[Code] .....
View 2 Replies
Dec 13, 2011
I am trying to make a 3-dot waiting animation using action script.
I want it to go until three dots "..." and than start over again until I manually stop it later in my program. I tried many stuff including arrays and surrendered.
View 4 Replies
May 3, 2006
I have this bit of actionscript that tweens a movie in position and scale. It then attaches a movie from the library.
Code:
_root.info._alpha = 100;
_root.info.slideTo(20, 100);
_root.info.window.tween(["_xscale"],[140],1);
[Code]....
Whats the best way of waiting until the tween is complete before attaching this movie. Basically I want the attached movie to appear once info._x == 20.
View 5 Replies
May 18, 2007
I have an animation stored in a movieclip.I have 5 instances off this mc stored off the stage. Whenever the user enters a wrong response, one of the mc's play a walk animation and a person 'walks' onto the screen. After moving 80 pixels, an if function in the onEnterFrame deletes the onEnterFrame.However, if the user enters more then 5 wrong answers, the persons start a new animation. The problem is that if the user gets a question wrong before the person has finished moving - the person stops and does the new animation.
Thus I was hoping to use setInterval after a check to see if anything is moving. Yet it doesn't see to work. My traces show no delay between the interval trace and the trace after the interval.Here is a section of my code; basically when k = 6, the fifth person has been called previously and the moving variable is a boolean set to true. But when run, there is no 20 second delay, it just says 'slow' then 'delay' and then kicks into the final animation.
Code:
if (k > 5){
trace(person5.moving);[code]....
View 2 Replies
Nov 15, 2007
I'm using a custom class to lay out a background consisting of square tiles picked at random. These are provided to the class as an array of library symbols, and they are placed on stage with the attachMovie method.- These tiles are different animations that all end up in a solid colored square. When all the tiles have finished animating, the result will be a large rectangular shape that serves as a unified background for content like text and graphics, so I't simply a sort of fancy build animation for the background.
- Naturally, I don't want to be displaying content before the animation has finished, so I need to do that based on some kind of event being dispatched. The problem is that these animations are timeline-based and I want my class to know when all background clips have reached their final frame.The question: How should I do this? Extending MovieClip for each of the animations seems a bit tedious since that would require one class per background tile MovieClip, and I don't want to be constantly checking the currentFrame of all the clips either.
Code:
public function TiledBackground(target:MovieClip,
bgSymbols:Array,
[code].....
View 5 Replies
Jul 30, 2009
I am creating a site where it is loading dynamic images and text within the SWF. Currently for images I am using the loadMovie command. This works typically when I do not have images of significant size, however I am having trouble getting the movie to check up if a larger image needs to be loaded. Here is my current code below, it does not seem to be checking to see if the clip is loaded and simply ignores it if the timeline reaches the actionscript before the image is loaded. _root.generalVars.homeImg is a variable that I define outside of flash
//creating empty placeholder
this.createEmptyMovieClip("tester",1)
tester.onData=function(){
[code]...
View 2 Replies
Nov 23, 2011
I have an arbitrary number of images I want to load. I want to load them, wait until I get an Event.INIT for each, and only then proceed with the rest of the program. I know I can do that by having an Event.INIT listener update and check some count variable, but is that the standard approach? Is there a more elegant or AS-specific way?
View 3 Replies
Feb 23, 2012
var playGraph = new Chart();
var playPart1 = new Part1();
var playPart2 = new Part2();
[code]....
View 1 Replies
Feb 15, 2009
i have an animation with a series of colored squares appearing and disappearing from the stage [URL]..except that the squares appear and disappear). Each of the squares fade in and out using Actionscript, with a custom method that animates its alpha property over time. I want to pick randomly every few seconds a square, to make it disappear and put a new one in its place, and my code is more or less like this:
[Code]...
View 0 Replies
Jul 29, 2003
Anyone know how or have any ideas on how to tell flash to wait for a "x" number of frames or time before it executes the next line in the script?
View 1 Replies
Jan 20, 2010
I have two problems:
1. Despite lots of searching/reading, i am still not sure how to listen for the end of a function in a child class from a parent class.
2. Building on question 1, I need some thoughts on best practices for halting execution until a number of events are met.
E.g. I have a class 'ContentBrowser' that instantiates a variable number of 'StuffList' classes. Upon instantiation of a 'StuffList' class an xml file is loaded for that instance. So I could have 4 or so xml files loading at once. What is the best way to wait until all the 'StuffList' instances have been loaded and parsed before continuing execution of my code within the ContentBrowser class?
View 4 Replies
Aug 31, 2009
I have a tic-tac-toe game. Where the user would which spot they would want to put their X or O in and then they would go to a random question. That's where my problem starts. How do I get it to go to a random question?[code]This is what I tried using. It works, but it only goes to QuestionOne. I tried putting a comma to seperate the labels, but that just makes it play the whole movie.
View 2 Replies
Nov 30, 2010
i have 5 different movieclips in flash library (mc1 / mc2 / mc3 / mc4 / mc5).And i have a master movieclip (master).How to make randomly load one of movieclips onto master movie clip?
View 2 Replies
Apr 12, 2011
I'm making a slideshow that plays the different slides at random. I have a movieclip named products that will have a different image on each of the 19 frames, and a code on the main timeline that changes the frames of the movie clip. I'm having a little issue with this code. At first I used:
[Code]....
View 8 Replies
Feb 3, 2010
Using Flex Builder 3 : I have been getting this problem in every single debug launch for past few hours. I used to get this earlier too, but once in a while, not with every debug launch. I found out that flex debugger uses a certain 7395 port but I can't figure out how to change it?
View 9 Replies
Feb 5, 2011
Certainly it is not the best practice, but I need to load a file and get its contents within the same function call. That is calling the urlLoader.load function and then waiting (say with an while(true)) for the contents to load.
I am stuck with the fact that flash will not trigger events nor continue with the file loading until the current thread finishes. Is there any way to allow flash to make the file contents available without exiting the current method call.
On a side note, I know this is not a good thing to do. This is only for easing a process in a local environment in which I need the file contents without waiting for an event. If I let the process continue other events already queued will fire and becomes a mess. Sadly refactoring the code to wait altogether would be too much effort.
View 2 Replies
Dec 21, 2011
I'm getting really annoyed by Flex. Is there a way to make it wait for an httpservice to get its data without having to use a timer?
At the moment my code looks like this:
protected function loginUser(event:MouseEvent):void
{
if(txtEmail.text == "" || txtPassword.text == "")
{
[Code].....
When I do user.login(), it sends a request with a HTTPservice from my external AS class. In the result event handler for this httpservice, I set a public variable to true or false, depending on whether the user's credentials are correctly in the DB.
I then use a getter to get that boolean value. However, without the timer, it always returns false because my code is faster than the event result handler. If that makes sense.
So I have to use a timer to stall my application for one second.. But seriously, that doesn't make sense to me. There has to be a better way, no?
View 3 Replies
Oct 25, 2005
Is something wrong with this code? I am trying to tell Flash to wait to call generateEventClips() until timeline_events.swf has been fully loaded into events_mc. But I don't think it is doing so, because the clips that the function is supposed to generate don't appear unless i call the function at least two frames later.
var events_mc = new MovieClipLoader();
events_mc.addListener();
events_mc.loadMovie("timeline_events.swf");
events_mc.onLoadComplete = generateEventClips();
View 3 Replies
Aug 7, 2009
i need to know how to get a random frame on range frames
for example
on press the button go to a random frames but on range :
from (frame 10 to frame 20 only)
how to do it ? ?
View 3 Replies
Nov 5, 2009
i'm just trying to do something really basic and I'm stumped.all i want to do is create a radom number onEnterFrameits to go at the end of a game i've made and the score will be radom at the end screenso far I have this below but it will not stop it just keeps going and going i've put stop(); in but that does not seem to work. I know its simple but I just can't see it.
this.onEnterFrame = function() {
display = Math.round (Math.random (10)*9)+1;
}
View 1 Replies