ActionScript 3.0 :: Load Random Frame From Array Onload?
Dec 2, 2010i have an array containing the frame numbers and i would like to add an onload event so a random frame from this array would be played on load
View 7 Repliesi have an array containing the frame numbers and i would like to add an onload event so a random frame from this array would be played on load
View 7 RepliesI am trying to get a random swf to appear on a page (5 movies possible).
How can I code this in AS3?
I want a movieclip consisting of a dynamic text box that, from the time it's loaded onto the stage, loads a randomly selected text string from an array, and continues to loop until the clip is removed from the stage. I also want the text strings to appear in the text box for random intervals between 500 and 3000 milliseconds.
While I've found tutorials here and elsewhere on loading one element from an array, usually triggered by a button, I don't know how to combine/alter it with the other elements.So I want this movieclip on the stage randomly flashing phrases from an array, some for a barely perceptible time, and others for a readable time.
I've been putting data into an array via XML, and then selecting at random an image string to load in a pic at random. But whilst doing this, I wanted to remove the String from the Array that I have just used, so I don't get repetition of the same image in the output. I initially thought that pop would remove the string I had just used - But of course it Removes the last value in the Array instead, which doesn't really help.
Ok - so how about randomizing the data once inside the Array, after it has been pulled in from XML!? That way I can load in the 'last' image, and then pop it out! Keeping a randomized selection of images each time 'it' is loaded
I'm having some issues with AS3. I have a slide show as a header for a website all of my pictures are set in the timeline with transitions. What i'm trying to do is have my slideshow goto a random frame onload to ensure a new look to the wbsite on every visit. So here is what I have so far Array for specific random frames
[Code]...
Alright. I have been over every inch of the web to find something that works, and nothing seems to. So let me see if I can't explain this as best I can.
I have a simple flash movie with six images in the timeline. One image shows up for a few seconds, then fades into another image. These images are NOT embedded in a movie clip, they are just in the main timeline.
The frames where these images start are at 2, 110, 220, 330, 440 and 550.
When someone first browses to the website, I want the movie to start at one of those frame numbers and then continue to loop through the rest. So if the movie randomly begins at 330, it will then proceed normally to 440, 550 and restart at 2 and continue.
Obviously the code will go into frame 1, but every code I try, the movie will always start at 2 when the person first goes to the site. If the person selects another link on the website, and then goes BACK to the homepage, THEN the movie will pick one of those numbers, but not on the first visit.
Any idea why this is happening? I can only think because the movie hasn't loaded every frame yet.
I have a simple scrip that seems to be pulling a blank screen and an error every now and then .[code]...
View 9 RepliesIs there a way that when the flash movie starts it loads into a random frame everytime. As well as a button that would do the same thing.
View 12 RepliesMy question isn't directly related to a random image or xml but I'm using it in my example. really want to know how to load an image when the swf file loads. Please have a look at my example and you'll see what is wrong. It's a little funky resizing the border at the moment when the file is loaded.
View 1 RepliesCello posted an excellent example of resizing a border around an image when a thumbnail is clicked: [URL] My question isn't directly related to a random image or xml but I'm using it in my example. I really want to know how to load an image when the swf file loads. Please have a look at my example and you'll see what is wrong. It's a little funky resizing the border at the moment when the file is loaded.
View 1 RepliesI have a couple banners that randomly load everytime I play the SWF but I need
them to random load like every 3 seconds when the swf is playing
What do I have to add to my code to achieve that, here is what I have.
gotoAndPlay(Math.round(Math.random() * 5)+1);
I have this to load a random image from my array. But how can I keep track so that a new random pic wont be the same as one allready shown, until all pics in the array has been shown once?
View 1 RepliesI have 15 empty placeholder on my stage, named "empty01" - "empty15". I have 15 mcs in my library, with linkage identifiers "01" - "15".
[CODE]...
I would prefer for 'empty01' to load a random mc. Can anyone advise how I could achieve this? I have tried to create an array containing the 15 library mcs (not sure if this is correct):
[Code]...
I can't get my head around arrays.Ok so basic I know it can be displayed as blah then you can retrive with trace(blah[X]); or in a text box.I can't be bothered with the var blah:Array = []ect.. I want to stay simple.I want to load a random vaule from an array but I want to keep the code simple so I can come back to it and instantly understand and make changes.
View 3 RepliesNow I know this should be straightforward to do, but seen as it's early hours here, I need a fresh pair of eyes.
At the launch of my movie, I want to load in a random sound clip from an array - here's my code...
[Code]....
I'm pretty sure this isn't working because on the ENTER_FRAME command in the eventlistener
I'm trying to use an array adapted from AS2 script to load random swfs called "koan_1.swf" or "koan_2.swf" etc into a "koan_loader_mc" on the stage. Each "koan_#.swf" has code in its last frame to both advance the "shuffle" array in the action script in the first frame of the stage and to load the next koan swf. The code below -- almost -- works, but....?
Frame on main stage:
// creates function called at the end of koan_#.swfs
function shuffle(a:Array) {
for (var ivar = a.length-1; ivar>=0; ivar--) {
[Code]...
I don't think I'm as familiar with arrays as I need to be to complete the following project - I've read about 60 posts and no one seems to be doing exactly what I am. Here's what I need to do: From a main swf (home.swf), I need to load 7 consecutive swfs in random order, (movie01.swf, movie02.swf, etc) from an array, into level 1. I need all seven to play without repeating, then repeat them in the same order in a loop.
But I ALSO need the user to be able to navigate through the swfs by using next or previous buttons (or by selecting individually 1-7, but that may be asking too much from my limited knowledge).Here is the code I'm using to generate a random ordered array:
var fileNames :Array=new Array("movie01.swf","movie02.swf","movie03.swf");shuffle = function (targetArray) {for (i=0; i<targetArray.length; i++) {var tmp = targetArray[i];var randomNum = random(targetArray.length);targetArray[i] = targetArray[randomNum];targetArray[randomNum] = tmp;}};shuffle(fileNames )trace(fileNames )
I assume from here I can load the swfs from fileNames [0]. I'm way out of my depth so the rest is a mystery to me.
I have 4 groups of movieclips all with different names.
Example:
Group1 contains dog_mc, cat_mc and bird_mc
Group2 contains shoe_mc, hat_mc and pants_mc
etc...
What I am trying to do is load a random group initially (either 1-4), then I want to play that group of movieclips. Once that group is completed playing all its movieclips, I want to move on to the next group and play all those movieclips. When all groups and movieclips have completed, I want to loop back to the start.
I have let's say 6 frames now, but will be adding more and want a different frame to load each time the browser is refreshed, randomly. I've done this in AS2, but need code for AS3.
View 5 RepliesI have let's say 6 frames now, but will be adding more and want a different frame to load each time the browser is refreshed, randomly. I've done this in AS2, but need code for AS3.
View 2 RepliesI've done the following [code]trace gives me a,b,c. am i missing out something? i cant seem to access the array from outside onLoad() ...
View 5 RepliesI've done the following
[AS]
playList_lv = new LoadVars();
playList_lv.load("playlist.txt");
playList_lv.onLoad = function(){
[Code]....
trace gives me a,b,c. am i missing out something? i cant seem to access the array from outside onLoad() ...
I have a question i need to get the length of an array but outside the onLoad()
here is my code:
var O:XML = new XML();O.ignoreWhite = true;O.onLoad = function(success) {
var photos:Array = this.firstChild.childNodes; _root.PanelH = photos.length*200; trace(PanelH);};trace(PanelH);O.load("VideosBank.xml");
However I have an upcoming project that's going to have a big image gallery, that is likely to change often, so I can see XML would be very useful for speed of editing/adding etc.
I'm a complete XML noob then, and I'm just doing a little test with some text, and I can't seem to access the Array outside the xml.onLoad function.
Here is the xml...
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<writing>
<para>
[Code]....
Now in the above code, my dynamic text field named "desc" correctly displays "bloody hell, XML is a nause".
However, when the line in bold is placed outside the onLoad function, it returns undefined, and when traced, the description array returns nothing at all.
I need to access the array outside of this function.
I'm working on a basic flash gallery, when the user clicks a thumbnail, the large image above it will load (using loadMovie ("whatever.jpg")...that's all working fine, but I want to have the image center on a frame once it's fully loaded since I have some portrait and some landscape images. What I'm wondering is, is there a simple way to check if a jpg has been completely loaded, similar to an xml.onLoad = function()? I've tried the getBytesLoaded and getBytesTotal thing as well as an onEnterFrame that checks the width but these have both had issues, maybe there's just some really simple way to check?
View 1 RepliesI want to dynamically load an image into a box/frame (got that figured out) and then have the box/frame resize according to the image's dimensions .
View 14 RepliesI got the following code from Adobe's 'Serverside ActionScript Language Reference'. Here it is:
myLoadVars = new LoadVars();myLoadVars.onLoad = function(result){ trace("myLoadVars load success is " + result);}myLoadVars.load(http://www.someurl.com/somedata.txt);
My questions is, if the purpose of the onload event handler is to confirm if the load operation is a sucess,than should it not be placed after the load command? In the above code, the onload event handler appears before the load and yet it works.
I posted this in another forum, no response yet, so I thought of posting it here as well. I got the following code from Adobe's 'Serverside ActionScript Language Reference'. Here it is:
Code:
myLoadVars = new LoadVars();
myLoadVars.onLoad = function(result){
trace("myLoadVars load success is " + result);
}
myLoadVars.load("somedata.txt");
My questions is, if the purpose of the onload event handler is to confirm if the load operation is a sucess,than should it not be placed after the load command? In the above code, the onload event handler appears before the load and yet it works
I got the following code from Adobe's 'Serverside ActionScript Language Reference'. Here it is:
Code:
myLoadVars = new LoadVars();
myLoadVars.onLoad = function(result){
trace("myLoadVars load success is " + result);
}
myLoadVars.load("http://www.someurl.com/somedata.txt");
if the purpose of the onload event handler is to confirm if the load operation is a sucess,than should it not be placed after the load command? In the above code, the onload event handler appears before the load and yet it works.
I am going to call this swf file to show a random image in a panel. I want the border to be around the picture when it loads. Here is the code,
Code:
portfolioInfo = new XML();
portfolioInfo.ignoreWhite = true;
timeline = this;
[Code]....