ActionScript 2.0 :: Randomizing Image And Url Data From Xml?
Feb 19, 2009
I am trying to build a simple image scroller in a way that it creates 2 arrays from 2 xml attributes. I got that working, but what I want to do next is randomize the order of the images and while making sure it they retain their specific urls. Then I want the scroller to loop those images in that random order infintely. So far here is my code:
Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
// change the values to alter the spacing and scroll speed
I am trying to build a simple image scroller in a way that it creates 2 arrays from 2 xml attributes. I got that working, but what I want to do next is randomize the order of the images and while making sure it they retain their specific urls. Then I want the scroller to loop those images in that random order infintely.
So far here is ActionScript Code: stop(); import mx.transitions.Tween; import mx.transitions.easing.*; // change the values to alter the spacing and scroll speed scrollSpeed = 1; picSpacing = 0; picWidth = 116; [Code] .....
know if it is possible to randomize data that is imported from a .CSV file so that it displays as dynamic text in Flash?Or if there might be a thread I could be pointed to? I'm creating a Flash program that can display "flash cards" with terms and their definitionsThe terms and definitions are in their own columns of the .CSV file.Currently, I can display in the dynamic text the data from each column (term and definition), however if I call them particularly. I was wondering if there was a way for me to do this randomly?
What I'm looking to do is randomize the CSS, but I'd also like to attach a background image to my css files so that I can make the site a tad more dynamic. I read the CSS tutorial on Kirupa's Site here.I'd also like to use externally loaded text, so I'm also not sure how I'd go about that, or if any of this is possible
I want to get image data from php and also display in flash. I want to know... how to read and display imagejpeg( $imgData ); from php. I am able to get php data in flash through below method...
I attempting to make a slideshow like the one on this page: [URL] But i was wondering if it is possible to change the code so that if you click on the main image, another image could come up next to it? (I'm making a portfolio site, and i want people to click on one of the main images to then see a detail image next to it).
I have an xml flash slide show that works great but i would really like it to randomly select the images out of the xml so that every time it is seen it is showing a different cycle of images. I'm not by any means an ActionScript expert far from it actually, but i understand a bit of it (not enough to write my own code yet).here is the code im using:
import mx.transitions.Tween; import mx.transitions.easing.*; var myShowXML = new XML(); myShowXML.ignoreWhite = true;
[code]....
Also I'm not using the text version of this were it gives a title of the image that is displayed but every time i think i have removed it correctly i screw the the whole thing up. right now i just have the title area in my xml blank which works but i guess its not the cleanest code right.
I used the tutorial for making a xml gallery and changed it up a bit to make a banner ad gallery from an xml file. This makes life easier for my non flash designers to just update the xml file when new ads come out. I would now like to make it randomly select the first image.The only idea I had was to change the p = 0; part to p = Math.floor(Math.random() * total); That didn't work.There is some additional code in there for a coldfusion click tracker and some to build the url string for the coldfusion page
// Load XML, define arrays, and initiate loading of first image function loadXML(loaded) { if (loaded) {
I've got an xml slideshow playing on my home page and I need to have the pictures randomized. You can see the flash in action at [URL]. Here is the code that I am using now.
delay = 10000; // function loadXML(loaded) { if (loaded) { xmlNode = this.firstChild; image = []; [Code] .....
Basically, it loads and parses an external XML file. I have it set to just step through the file but I'd like it to randomly display the images referenced by the XML. The script works like this, but I can't seem to figure out how to get the XMl into an array and then have the function read it correctly. It seems to me that the call:
picture.loadMovie(image[p], 1);
with p being changed somehow to a call to myArray should work, but it doesn't. What am I doing wrong?
this creates the load XML function and counts the children to an array function loadXML(loaded) { if (loaded) {[code]....
so the XML needs to loaded into the array somehow. Here's the array with a bunch of numbers instead of the XML info.
I'm trying to build an application that displays randomly thumbnails in a grid, but having problems with the random part. I'm displaying the thumbs in grid like this:
I'm trying to build an application that displays randomly thumbnails in a grid, but having problems with the random part.I'm displaying the thumbs in grid like this:Code: Select all//building a thumbnail container for each one of the projects from the library
var thumbContainerMisc_mc:ThumbContainer = new ThumbContainer(); thumbContainerMisc_mc.x = (200+1) * x_counterMisc; //setting the thumbnail x thumbContainerMisc_mc.y = (200+1) * y_counterMisc; //setting the thumbnail y
I wanted to randomise my quiz questions and to allow all questions to appear but no similar questions should appear twice. I tried to use arrays to do it but I kept having errors.
So I figured that the last idea I had would not work, but I realized that if I attached each seperate background image from an array to a css element that, that would indeed work.
Basically, I've got a small space shooter game and the idea is to have the enemies start moving at the top of the screen and head towards the player, while growing in scale, and moving at an angle.(To give the sort of perspective/distance effect). Right now, I'm able to get the enemies to move at one angle only. How would I get them to move on X at a certain range?
This is the code affecting movement/Scale for( i = 0; i < enemyShip.length; i++ ){ enemyShip[i].y += 10; enemyShip[i].x += 5; enemyShip[i].scaleX += 0.03; enemyShip[i].scaleY += 0.03; } The pic above basically shows what I mean by the perspective look. I need to blocks to move towards the player at various X ranges within those lines, but I don't want them to zigzag while moving. I know it has to do with Math.Random.
A slideshow containing advertisements, randomized in a way that each ad gets the same chance at being the first one to show when the page gets opened. Or rather, not randomizing, but alternating between about 25 different ads, perhaps even more
I'm having an issue using randomizing the appearance of movie clips using Math.random. I have a movie clip in the library, which is 85 frames long but it begins and ends with 15 blank key frames. In other words, it has 2 layers, one for action script and one for graphics which are movie clips too, the AS layer is 85 frames long while the art layer is shorter and begins on frame 16.
I began by putting the movie clip on the stage, without any code on the main timeline, with some code on the movie clip's timeline - this.x = Math.random()*stage.stageWidth; this.y = Math.random()*stage.stageHeight;
In this case, tested the movie, the swf played just what I wanted, the movie clip "appears" randomely on the stage, plays, disappears, and reappears, and so on and so forth.
I then gave the movie clip on the stage an instance name of b_mc, removed the code in its timeline, and put it on the main timeline, as such - b_mc.x = Math.random()*stage.stageWidth; b_mc.y = Math.random()*stage.stageHeight;
In this case, the movie clip does NOT appear randomly on the stage when the swf is tested, rather, it appears at the same position, appearing and disappearing over and over as planned, but in the same place - NOT as planned.
I'm working on a services module (slideshow for lack of a better term) for an accounting firms website - site is still under construction at On the home page, far right hand column a grey box with a service icon and user controls progresses thru the five services until the user advances the slide manually.I need to randomize the starting point of the slide show using one of the five services. To complicate the matter further I need to weight them so some services show up more often than others. But randomizing with equal weight would at least be a start.
I am currently making a quiz game and have an XML file which stores all the questions/answers.I then load the xml, and put all of the info into multiple arrays.
ActionScript Code: var x = new XML(); x.ignoreWhite = true; x.load ("Stating The Obvious 2.xml")
[code]....
So, how would I edit the code to make the questions appear in a random order? i.e. Make the currentQuestionNumber be random while not repeating itself.Also, is it possible to make the answers appear in a random order on the screen? For example, instead of the "answer1array" element always appearing at the top and the "answer4array" element appearing at the bottom, is there a way to mix things up a bit?
I'm developing an iOS flashcard app in Flash CS5 for a school project. I've got over 600 scenes, and my cards are structured in pairs so that one scene is the front of the card and the next is the backside with the answer. I've figured out how to get from scene to scene, but have had no luck trying to find how to randomize scenes while keeping them in pairs
I have an Flash CS4 application which pulls in data (questions) via XML and randomizes them. Right now if there is 50 questions in the XML file, 50 questions are displayed and randomized in the application. I am trying to figure out how to limit the randomizing pool so that only 35 questions display(even when the XML file has 50 questions) or something like that. My current code which brings in the file and randomizes is below. The code is written in AS3, by someone else.[code]
I have simple Drag n Drop interactivity in my flash movie. There are draggable objects to be dropped on their targets. If they reach the desired Target they stick to that target. If the object does not reach its target, it snaps back to its original x,y location.
How can I randomize the location of the objects, and then essentially capture that location and plug it dynamically into the code above? And how can I randomize the location of the targets for those objects to be dropped onto? (And I suppose an additional question would be, so I don't hide any content, how do I do this without overlaying the objects and targets on top of each other?)
i have four radio buttons on the stage and i want randomize there order for my quiz so that when the user clicks back each time its a lil harder to get the right answer...ALSO is it possible to do this randomizing in accordance with the randomizing of my results in my database so that the answer will actually match the radio buttons??
I'm a flash noob and I'm having trouble randomizing few dynamically loaded swf files.
1. I have a UILoader on the stage with an instance name of bg_ldr. It is working properly.
2. I have (attempted) to set up a function called getRandomNumber (see code below) and I believe it is correct.
3. BUT... specifically I don't know what I should put in this part of the code: bg_ldr.source = bgArray[?????]; and I think this area is the problem. I thought I could just call my function, like this:bg_ldr.source = bgArray[getRandomNumber];But it's not working.[code]
Im creating a kids drag and drop game and want the 6 words to change place each time it is played. ive got a box which i want them to move about in. create an array of some kind to possible do this, but i'm stuck in actually creating it. also ive managed to drag and sound clip onto my first frame and cannot delete it so any help with it would be helpful (pig oinking isnt needed when u load the game )
My homepage contains a flash file that tweens through 4 product images. I want to program my file so that every time the user goes to the homepage, the flash cycles through the four images randomly. I thought the easiest way to so this would be to create four series of image tweens and label each, and then code the first frame of the movie to go to one of the labels at random.