Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




AS 2 Loading Random Background FULLSCREEN Images



Hi there,I have been looking at this tutorial http://www.kirupa.com/developer/mx/l...background.htm but I need the background images to be FULLSCREEN. Can someone help me out? Is there a way to do this that someone can point me to ? I have a client squirming, and my head is on the block.I am using as2, flash cs3.Thanks in advance, Angie.



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 10-08-2008, 09:16 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Loading Random Fullscreen Background Image
so, i finally got the fullscreen / scaling background to work. AND i can add .swf's and other mc's over top of it without any problem. however, i want to be able to have the background image randomly generated. i know how to do that on its own, but i can't get it to work with this script. any advice?

here's my fullscreen / scaling bg script.


Quote:




Stage.scaleMode = "noScale";
_global.imgConstantWidth = bgImage._width;
_global.imgConstantHeight = bgImage._height;


setImage = function(mc){

var originalWidth = 1280;
var originalHeight = 850;
var widthGutter = (Stage.width - originalWidth)/2;
var heightGutter = (Stage.height - originalHeight)/2;

mc._x = -widthGutter;
mc._y = -heightGutter;


if (mc._width > Stage.width){
mc._x -= (mc._width-Stage.width)/2;
}

if (mc._height > Stage.height){
mc._y -= (mc._height-Stage.height)/2;
}

}

resizeImage = function(mc){

var scaleByWidth;

if (Stage.width/Stage.height > _global.imgConstantWidth/_global.imgConstantHeight){
scaleByWidth = true;
}else{
scaleByWidth = false;
}

if (scaleByWidth){
mc._height = Stage.width * _global.imgConstantHeight / _global.imgConstantWidth;
mc._width = Stage.width;
} else {
mc._width = Stage.height * _global.imgConstantWidth / _global.imgConstantHeight;
mc._height = Stage.height;
}

}


setImage(bgImage);
resizeImage(bgImage);

sizeListener = new Object();
sizeListener.onResize = function() {
setImage(bgImage);
resizeImage(bgImage);
};

Stage.addListener(sizeListener);

Random Fullscreen Background Image On Refresh
Hi there, I have flash site and client wants random fullscreen background image to load on refresh. sounds easy right ?. but i've tried a lot of components and code snippets but it's causing headaches as nothing seems to work. i have a client squirming because it isn't done and i was wondering if you could help me out.

I did purchase a component from flashden (randombgholder) which does exactly what i want, but it seems to clash with the flashloaded fCMS system i have working in place, and somehow knocks it out, but that could be my bad amateur flash coding causing it. And when i go to center the swf over the background using his code he provided it goes haywire.
perhaps i could do a random fullscreen background image on page refresh in html?? i tried some css ones, but nothing works probably because i'm very new to flash and the likes.
links to tutorials or someone i could even pay to do this - anything really appreciated.
THanks in advance, Angie.

Random Background Images
Hello,

I am using Flash v5.0 and I can't figure out how to make a random background image appear each time someone accesses my webpage...if anyone could help me it would be greatly appreciated!

Cheers,
Macohead

Preload External Random Background Images
I have been searching for days for a solution to this problem. I am making a flash site which loads random external images as the main background of the site. The problem is that the other content loads before the external image. So I need to create a progress loading bar/number. This seems simple enough if the image is defined, but does anyone know how it is done when the images are random? So the following actionscript loads the random background for which I need the loading/progress:

choice = Math.round(Math.random()*9);
switch (choice) {
case 0 :
location.loadMovie("image0.png");
break;
case 1 :
location.loadMovie("image1.png");
break;
case 2 :
location.loadMovie("image2.png");
break;
case 3 :
location.loadMovie("image3.png");
break;
case 4 :
location.loadMovie("image4.png");
break;
case 5 :
location.loadMovie("image5.png");
break;
case 6 :
location.loadMovie("image6.png");
break;
case 7 :
location.loadMovie("image7.png");
break;
case 8 :
location.loadMovie("image8.png");
break;
case 9 :
location.loadMovie("image9.png");
break;
}


Hope someone has some advice!
Cheerio.

Loading A Random Background At 100%
how would you go about doing this. (ex http://hi-res.net )

I know how to do both indvidualy but i cant make it all work together!

any help would be apreciated

Loading Random Background
Hi, i read and completed the tutorial on this topic:

http://www.kirupa.com/developer/mx/l...background.htm

what i needed is something similar, except that my background image is a motion clip and instead of having external .swf, i need all the MC's in just one flash. How do i do that?
Thank you for a quick response


x.
Victor

Loading A Random Background
Hi everyone

This is my first post here, but i've used the excellent tutorials section on many occasions with great success

I now have a question re: Loading a Random Background

This will indeed work perfectly for what i want, my question is this;
can i get the same effect using jpgs from an external source?

thankyou for looking
Sue

Loading A Random Background At 100%
how would you go about doing this. (ex http://hi-res.net )

I know how to do both indvidualy but i cant make it all work together!

any help would be apreciated

How Do You Use Loading A Random Background On The Website
I found the loading random background tutorial
http://www.kirupa.com/developer/mx/l...background.htm,
so i follow through the tutorial to make my .swf file work as every time i open the .swf file, it gives me different background. However, when i insert its in my webpage, it gives me no response. It won't even load or do anything else at all, so is there anything i need to do or any specific code that i need to include when i insert it to my webpage so it'll load the new background everytime that i refresh the page?

By the way, the tutorial's really helpful, thank you!

Loading Random Background Tutorial Q.
I was just reading the testing the tutorials regarding loading a random background. I have tried this and worked!

BUT!...

I tried this for my flash document but the background covers everything else.

The keyframe, in which the script for loading the random image is in, is in a layer under a layer where my title is in. But when it loads the image, it appears on top of my image.

I'm trying to make an interactive DVD and want it so that my background changes each time you load the .swf file. (If possible to make it change also whenever you come back to the home page after visiting another page in it)

How do I solve this problem?

Question About Random Loading Background
I got the tutorial to work (it's pretty simple) but I want the background to randomly load images on it's on, basically looping through all of the random bacgrkounds without the page having to be refreshed. How do I achieve this? Thanks

Random Background When Loading Website
Hi there,

I'm new to Actionscript and was hoping somone could assist me with creating a random picture loader for my background, so that when you enter the website the picture in the background is different every time you enter.

Thanks for any help!

Loading Background Images
I just added the option to my site to change background images. I set it up by loading external movies into the target BGFrame which is on the main timeline of my site. The target is on the layer right above my original background image. All background .swf's are loading into the same target BGFrame.

I was wondering if there's a way to load a new background image more smoothly than the way I have it now. It's annoying that when you switch from one new background to another, there's a brief moment where you can see the original image during loading time.

Here's the code I used:
To load the backgrounds:

Code:
on (release) {
_root.BGFrame.loadMovie("BG7.swf");
}

To return to the original:

Code:
on (release) {
_root.BGFrame.unloadMovie();
}


Any thoughts or tips would be greatly appreciated.

My site: http://calpomatt.lavista.org

Loading Images In Background?
Hi,

I am trying to make a gallery where the user clicks on a thumbnail and a JPEG is loaded, however in the 'background' the other full size JPEGs are loading so when their thumbnails are clicked they appear instantly?
If anyone has any ideas on how to do this it would be good to hear from you
Thanks for your time,
Tim

Loading Images In The Background...
How would i go about loading a set of images in the background? Just so that they are ready to go and I don't have to load them per image. I want to load the whole set for each section of a site.

click on image set 1>loads entire image set

[F8] Loading A Random Background Image And Preloading It.
Hey guys, currently making a new site. It is a fluid layout so everything streches etc. I am loading in a different background image each time the site is loaded and I have a good code for that from here:

http://www.kirupa.com/developer/mx/l...background.htm

But since the image needs to take up a lot of space on stage for things like 22" screens the image sizes are like 2MB. Is there anyway that I can preload the background image seperatly to the whole movie...well actually I know there is I just need to be pointed in the right direction or just given some help. I want the preloader to load the whole stage but then where the background image should be displayed a preloader is displayed until the background image has fully loaded.

Any help would be awsome!

thanks.

Loading Random Background Problems [renamed]
I am looking for someone skilled with Flash, a Wizard hopefully...

I have been trying to create a .swf that loads a Random background image (like the one on Kirupa's MX tutorial on this site) ... and my skills are just too insuficient.. I got it working but the images loads in sequence too fast and my general composition and work is kinda messy...

Is there someone here who is interested in helping out ?

The project is for our website, we are a non-commercial gaming clan, and alot of programmers, but none of us have any serious Flash experience. We are able to advertise/link back to anyone who might wanna help us out.

Contact me on email: therseus@gmail.com

Loading A Random Background Image With A Preloader
hello

I've been following the Loading a Random Image tutorial from kirupa but I can't seem to make my image*.swf's to work..in it all I have is 3 frames, where the first 2 frames are for the preloader and the 3rd one is for the image.. but all I get is the loadBar fully loaded (but with no animation, just static) and no image... does that code from the kirupa tutorial stop the *.swf to make anykind of anymation?


another question is about how to simple load a movie on enter frame with a movieclip defining the location where it should be loaded to.. shouldn't it be: location.loadMovie("movie.swf") ? simply.... no?

thanks in advance..

Help Loading A Random Background Full Screen
In the bottom layer of my main movie, Id like to put a random background image which loads on entering the frame and stretches to full screen. I would like to use a preloader for the image so Im trying to load a swf using this which I found here:

http://www.kirupa.com/developer/mx/l...ackground2.htm


Code:
choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
location.loadMovie("image0.swf");
break;
case 1 :
location.loadMovie("image0.swf");
break;
case 2 :
location.loadMovie("image0.swf");
break;
case 3 :
location.loadMovie("image0.swf");
break;
case 4 :
location.loadMovie("image0.swf");
break;
case 5 :
location.loadMovie("image0.swf");
break;
}
but I could not get it to stretch full screen. How do I get the externally loaded swf to stretch full screen and be able to resize via a listener from within my main movie?

Thanks!
Rich

Loading Random Background Problems [renamed]
I am looking for someone skilled with Flash, a Wizard hopefully...

I have been trying to create a .swf that loads a Random background image (like the one on Kirupa's MX tutorial on this site) ... and my skills are just too insuficient.. I got it working but the images loads in sequence too fast and my general composition and work is kinda messy...

Is there someone here who is interested in helping out ?

The project is for our website, we are a non-commercial gaming clan, and alot of programmers, but none of us have any serious Flash experience. We are able to advertise/link back to anyone who might wanna help us out.

Contact me on email: therseus@gmail.com

Random Loading Of Images
i use this actionscript to randomize the loading of an image that represent the background of my site;

_root.a = random(4);
if (_root.a=0) {
_root.loader.loadMovie("pfbg001.jpg");
}
if (_root.a=1) {
_root.loader.loadMovie("pfbg002.jpg");
}
if (_root.a=2) {
_root.loader.loadMovie("pfbg003.jpg");
}
if (_root.a=3) {
_root.loader.loadMovie("pfbg004.jpg");
}

it doesn't properly works... is there anybody who can help me? thx!!!

Loading Random Images
Hello,

I am creating a site in Flash MX 2004 where each page a user comes to I have background image with interface on top of it. What I want to do is create it so that everytime a user comes to a page or goes back to a page, or reloads the site a different image is loaded into the background, not to interfere the interface that is on top of it. I am building this site where I have a main navigation that calls the external movies into a container clip, in these movies is where I would like to place the code for this. I have been looking into some things on this and what I can find is that I will need to call these .jpg images from an external folder and set the the call in code on each movie to call them at random. The code I have so far is:

------------------------------------------------------------

imageToload = Math.random(5)
imageHolder.loadMovie([imageToload]+".jpg")

--------------------------------------------------------------

I have placed this on the first frame of the external movies, attempting to call in the 5 jpegs, but it is not working correctly. I also have a pre-loader on these movies in the first scene. I wanted that to be able to preload these as well fom that pre-loader if that is possible. My preloader script is as follows. Which is typical code.

____________________________________

(frame1)
framesLoaded = getBytesLoaded();
totalFrames = getBytesTotal();
_root.loading = Math.round((framesLoaded/totalFrames)*100);
this.bar._xscale = _root.loading;


(frame2)
if (framesLoaded == totalFrames) {
gotoAndPlay("main", 1);
} else {
gotoAndPlay(1);
}

___________________________________

I am trying a few different things, also looking into this site help as well. But I wanted to post to see if anyone could help or point me into the right direction.
Thanks

Loading Random Images
Alright, first off I'm sorry for making anothe rpost for something that has been asked about many times. I looked for tutorials online and none of them showed me how to load an image from a url unless it was in the same folder as the flash. I couldn't make sense of the posts here.
What I want to do is this:
Make a swf file that will be embedded into a webpage that randomly loads an image from a list in the form of a text file. I'd like a button to load another image inside the swf file. This should be fairly basic, but it's hurting my head. I can't even get an image to load from a url in flash. Thanks for the help.

Loading Random Images
hello all

can somebody please shed some light on how to load images in randomly but in sequence..?

see this...top strip...like this:http://www.taktak.net/About/Whoweare.aspx

thanks
s

Loading Random Images...
Hi guys... I'm kind of desperate, I have my code working beautifully for loading in an image at full screen...


Code:
Stage.scaleMode = "noScale";
Stage.align = "LT";
import flash.display.*;

function loadBitmapSmoothed(url:String, target:MovieClip) {
var bmc:MovieClip = target.createEmptyMovieClip("bmc", target.getNextHighestDepth());
var listener:Object = new Object();
listener.tmc = target;
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
percent = Math.round((bytesLoaded/bytesTotal)*100);
pText.text = percent+"%";
};
listener.onLoadInit = function(mc:MovieClip) {
mc._alpha = 0;
mc.onEnterFrame=function ()
{
mc._alpha += 15;
if(mc._alpha >= 100)
{
delete this.onEnterFrame;
}

var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);
bitmap.draw(mc);

// set size and position on load
if (Stage.height/Stage.width>target._height/target._width) {
img_prop = target._width/target._height;
target._height = Stage.height;
target._width = Stage.height*img_prop;
target._y = (Stage.height/2)-(target._height/2);
target._x = (Stage.width/2)-(target._width/2);
} else {
img_prop = target._height/target._width;
target._width = Stage.width;
target._height = Stage.width*img_prop;
target._y = (Stage.height/2)-(target._height/2);
target._x = (Stage.width/2)-(target._width/2);
}}
};
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
loadBitmapSmoothed("images/image1.jpg", bg_con);

// set size and position on resize
var stageL:Object = new Object();
stageL.onResize = function():Void {
if (Stage.height/Stage.width>bg_con._height/bg_con._width) {

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;

img_prop = bg_con._width/bg_con._height;
bg_con._height = Stage.height;
bg_con._width = Stage.height*img_prop;
bg_con._y = (Stage.height/2)-(bg_con._height/2);
bg_con._x = (Stage.width/2)-(bg_con._width/2);
} else {

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;

img_prop = bg_con._height/bg_con._width;
bg_con._width = Stage.width;
bg_con._height = Stage.width*img_prop;
bg_con._y = (Stage.height/2)-(bg_con._height/2);
bg_con._x = (Stage.width/2)-(bg_con._width/2);
}
};
Stage.addListener(stageL);

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;
footer._y = Stage.height;
BUT now I want to be able to have random images loading... I had this previously but can't seem to implement it into the new code...


Code:
var myTest = random(6) + ".jpg"; // Load 1 of 6 random images
Also further down the timeline I want to be able to add an image I directly target which I have been able to achieve by placing this on the timeline...

_root.loadBitmapSmoothed("images/image1.jpg", _root.bg_con);

Any help would be greatly appreciated!

Loading Three Random Images
Hello people, i was wondering if someone could possibly lend me a hand. I have this great idea which i have begun implimenting on my website but i have currently hit a brick wall. The idea is to have three images on the home page. Every time the page is reloaded the images change to a new random image (from a defined array of images). But...and this is the problem...there are THREE of these images. I need the images to both not repeat themselves nor have the same displayed in two images. For example, i dont want images 1/2/3 to be proceeded by images 1/2/3 (in any order), nor do i want images 1/2/2 displayed. Always three new images.

This is the code i am currently using, is slightly adapted from another i found on the web.


--------------------------------------------------------------------------------

fscommand("allowscale", "true");


//Preload Function
_root.bar._visible = 0;
_root.barBorder._visible = 0;

MovieClip.prototype.loadPic = function(pic) {

this.loadMovie(pic);
this._parent.onEnterFrame = function() {
var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
var t = containerMC1.getBytesTotal(), l = containerMC1.getBytesLoaded();
var t = containerMC2.getBytesTotal(), l = containerMC2.getBytesLoaded();
bar._visible = 1;
barBorder._visible = 1;
per = Math.round((l/t)*100);
if (t != 0 && Math.round(l/t) == 1 && "containerMC", "containerMC1", "containerMC2"._width != 0) {

bar._visible = 0;
barBorder._visible = 0;
loadText3.text = "";
delete this._parent.onEnterFrame;
} else {
bar._width = per * 2;
loadText3.text = per+" % loaded";
}
};
};

//Random images
pics = new Array("park2.jpg", "park5.jpg", "park8.jpg", "park12.jpg");
var randNum = getRandom(0, 3);
_root.containerMC.loadPic(pics[randNum],pics[randNum],100);
_root.containerMC1.loadPic(pics[randNum],pics[randNum],100);
_root.containerMC2.loadPic(pics[randNum],pics[randNum],100);
pics[randNum]._x = 0;
pics[randNum]._y = 0;
// function to generate a random integer
// between minimum and maximum, inclusively
function getRandom(minimum, maximum) {
return Math.floor(Math.random()*3(maximum-minimum+1)+minimum);
}

--------------------------------------------------------------------------------


If anyone could help by modifying this code that would be awesome. Thanks alot.

Skellz

Loading Random Images Via Xml
I'm working on a Flash movie that loads random images via XML.
My current effort is online here:
http://www.betabureau.com/flash/random

Currently I have just one images folder containing a set of three images.
I would like to add more image folders containing different sets of images and have these sets load randomly via XML.
Is this possible? Any help on this issue would be greatly appreciated.

Here's the code:

ACTIONSCRIPT:

var oldVar = 0;
var newVar = 0;
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success) {
if (success) {
library = this.firstChild.childNodes;
maxVal = library.length;
delete my_xml;
getImage();
} else {
desc_txt.text = 'Error: XML Not Loaded';
}
};
my_xml.load('library.xml');
p = 0;
this.onEnterFrame = function() {
if (container_mc._alpha<100) {
container_mc._alpha += 10;
}
};
function getImage() {
newVar = Math.floor(Math.random()*maxVal);
if (newVar == oldVar) {
getImage();
} else {
oldVar = newVar;
container_mc._alpha = 0;
container_mc.loadMovie(library[newVar].firstChild.firstChild.nodeValue);
newVar = Math.floor(Math.random()*maxVal);
one_btn.onRelease = function() {
getImage();
};
}
}

XML (library.xml) :

<?xml version='1.0' encoding='UTF-8'?>
<library>
<jpg>
<file>images/image0.jpg</file>
</jpg>
<jpg>
<file>images/image1.jpg</file>
</jpg>
<jpg>
<file>images/image2.jpg</file>
</jpg>
</library>

Loading Random Images...
Hi guys... I'm kind of desperate, I have my code working beautifully for loading in an image at full screen...


Code:
Stage.scaleMode = "noScale";
Stage.align = "LT";
import flash.display.*;

function loadBitmapSmoothed(url:String, target:MovieClip) {
var bmc:MovieClip = target.createEmptyMovieClip("bmc", target.getNextHighestDepth());
var listener:Object = new Object();
listener.tmc = target;
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
percent = Math.round((bytesLoaded/bytesTotal)*100);
pText.text = percent+"%";
};
listener.onLoadInit = function(mc:MovieClip) {
mc._alpha = 0;
mc.onEnterFrame=function ()
{
mc._alpha += 15;
if(mc._alpha >= 100)
{
delete this.onEnterFrame;
}

var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);
bitmap.draw(mc);

// set size and position on load
if (Stage.height/Stage.width>target._height/target._width) {
img_prop = target._width/target._height;
target._height = Stage.height;
target._width = Stage.height*img_prop;
target._y = (Stage.height/2)-(target._height/2);
target._x = (Stage.width/2)-(target._width/2);
} else {
img_prop = target._height/target._width;
target._width = Stage.width;
target._height = Stage.width*img_prop;
target._y = (Stage.height/2)-(target._height/2);
target._x = (Stage.width/2)-(target._width/2);
}}
};
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
loadBitmapSmoothed("images/image1.jpg", bg_con);

// set size and position on resize
var stageL:Object = new Object();
stageL.onResize = function():Void {
if (Stage.height/Stage.width>bg_con._height/bg_con._width) {

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;

img_prop = bg_con._width/bg_con._height;
bg_con._height = Stage.height;
bg_con._width = Stage.height*img_prop;
bg_con._y = (Stage.height/2)-(bg_con._height/2);
bg_con._x = (Stage.width/2)-(bg_con._width/2);
} else {

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;

img_prop = bg_con._height/bg_con._width;
bg_con._width = Stage.width;
bg_con._height = Stage.width*img_prop;
bg_con._y = (Stage.height/2)-(bg_con._height/2);
bg_con._x = (Stage.width/2)-(bg_con._width/2);
}
};
Stage.addListener(stageL);

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;
footer._y = Stage.height;
BUT now I want to be able to have random images loading... I had this previously but can't seem to implement it into the new code...


Code:
var myTest = random(6) + ".jpg"; // Load 1 of 6 random images
Also further down the timeline I want to be able to add an image I directly target which I have been able to achieve by placing this on the timeline...

_root.loadBitmapSmoothed("images/image1.jpg", _root.bg_con);

Any help would be greatly appreciated!

Loading Random Images
I'm using the following code to dynamically load random images, jpg files. It works for the first time, but it does not work when I refresh(reload in firefox) the browser.The swf file and jpg files are in the same directory.Please help.:

onLoad = function () {
var i = random(6)+1;
this.createEmptyMovieClip("main", this.getNextHighestDepth());
this.main._x=480;
this.main._y=0;
_root.main.loadMovie("1.jpg");

myInterval = setInterval(shansi, 9000);

function shansi() {
var i = random(10)+1;
_root.main.loadMovie(i+".jpg", this.getNextHighestDepth());
import mx.transitions.*;
import mx.transitions.easing.*;
TransitionManager.start(main, {type:Fade, direction:Transition.IN, duration:3});


}
};

Random Loading Images
I have done a random loading file using this tutorial:
http://www.kirupa.com/developer/mx/l...background.htm
And really like to know if there is a way to put 2 different simultaneous
random loading images in a single flash file using this code:


Code:
choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
location.loadMovie("image0.swf");
break;
case 1 :
location.loadMovie("image1.swf");
break;
case 2 :
location.loadMovie("image2.swf");
break;
case 3 :
location.loadMovie("image3.swf");
break;
case 4 :
location.loadMovie("image4.swf");
break;
case 5 :
location.loadMovie("image5.swf");
break;
}
Tried many times without luck, need some help!

Loading Random Images From An URL?
hey there

I am trying to design a banner that may be hosted many different places and I'd like it to load a series of random images from our own server.

My actionscript isn't strong enough to figure this out.

Is it do-able?

thanks for any help - much appreciated

SS

Loading Random Images From Php
So this is my first thread ever on Kirupa. I've done a search for my topic for about a week now and can't find an answer to my question.
Well here it goes:
I am loading random images of products from a php file into a movie clip. I got this part working, however I need these images to fit inside the movie clip. (Mind you all the images are random sizes) I don't want the movie clip to change size, what I need is for the images to fit within the movie clip. As of now the images are loading really large. The images will also serve as buttons linking you to pages for the products. Is there a way to make it so the images resize to fit. Here's the AS:

myVars.load("getProducts.php");

myVars.onLoad=function(){
sp_title1_txt.text = this.item1_title;
sp_LP1_txt.text = this.item1_listPrice;
sp_OP1_txt.text = this.item1_ourPrice;
sp_image1.loadMovie(this.item1_image);

sp_title2_txt.text = this.item2_title;
sp_LP2_txt.text = this.item2_listPrice;
sp_OP2_txt.text = this.item2_ourPrice;
sp_image2.loadMovie(this.item2_image);

sp_title3_txt.text = this.item3_title;
sp_LP3_txt.text = this.item3_listPrice;
sp_OP3_txt.text = this.item3_ourPrice;
sp_image3.loadMovie(this.item3_image);
}
.................................................. ................

This is the AS for the images once they are loaded.

this.sp_image1.onRelease = function(){
getURL("special_view.php");
}

this.sp_image2.onRelease = function(){
getURL("special_view.php");
}

this.sp_image3.onRelease = function(){
getURL("special_view.php");
}

thank you in advance for any help to my problemo!

Help With Loading Random Images
I have a series of jpg images that I want to load randomly onto my main movie. I am not sure how to make it so that once one of the images has been loaded, that particular image does not get chosen again.

I am not sure if this is very clear so I will try to give an example. Lets say I have 4 images name 1.jpg, 2.jpg, 3.jpg, and 4.jpg. I have 4 spaces on my main movie that I want to each hold one of the images. If the first slot randomly gets 3.jpg, then that image should not be chosen again.

Right now, I am waiting for my computer to get back to me since it is being repaired but I just want to plan out some changes/additions that I would like to make to a site. Any help would really be appreciated. Thanks in advance.

Random Loading Images
I have done a random loading file using this tutorial:
http://www.kirupa.com/developer/mx/l...background.htm
And really like to know if there is a way to put 2 different simultaneous
random loading images in a single flash file using this code:


Code:
choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
location.loadMovie("image0.swf");
break;
case 1 :
location.loadMovie("image1.swf");
break;
case 2 :
location.loadMovie("image2.swf");
break;
case 3 :
location.loadMovie("image3.swf");
break;
case 4 :
location.loadMovie("image4.swf");
break;
case 5 :
location.loadMovie("image5.swf");
break;
}
Tried many times without luck, need some help!

Loading Random Images...
Hi guys... I'm kind of desperate, I have my code working beautifully for loading in an image at full screen...


Code:
Stage.scaleMode = "noScale";
Stage.align = "LT";
import flash.display.*;

function loadBitmapSmoothed(url:String, target:MovieClip) {
var bmc:MovieClip = target.createEmptyMovieClip("bmc", target.getNextHighestDepth());
var listener:Object = new Object();
listener.tmc = target;
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
percent = Math.round((bytesLoaded/bytesTotal)*100);
pText.text = percent+"%";
};
listener.onLoadInit = function(mc:MovieClip) {
mc._alpha = 0;
mc.onEnterFrame=function ()
{
mc._alpha += 15;
if(mc._alpha >= 100)
{
delete this.onEnterFrame;
}

var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);
bitmap.draw(mc);

// set size and position on load
if (Stage.height/Stage.width>target._height/target._width) {
img_prop = target._width/target._height;
target._height = Stage.height;
target._width = Stage.height*img_prop;
target._y = (Stage.height/2)-(target._height/2);
target._x = (Stage.width/2)-(target._width/2);
} else {
img_prop = target._height/target._width;
target._width = Stage.width;
target._height = Stage.width*img_prop;
target._y = (Stage.height/2)-(target._height/2);
target._x = (Stage.width/2)-(target._width/2);
}}
};
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
loadBitmapSmoothed("images/image1.jpg", bg_con);

// set size and position on resize
var stageL:Object = new Object();
stageL.onResize = function():Void {
if (Stage.height/Stage.width>bg_con._height/bg_con._width) {

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;

img_prop = bg_con._width/bg_con._height;
bg_con._height = Stage.height;
bg_con._width = Stage.height*img_prop;
bg_con._y = (Stage.height/2)-(bg_con._height/2);
bg_con._x = (Stage.width/2)-(bg_con._width/2);
} else {

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;

img_prop = bg_con._height/bg_con._width;
bg_con._width = Stage.width;
bg_con._height = Stage.width*img_prop;
bg_con._y = (Stage.height/2)-(bg_con._height/2);
bg_con._x = (Stage.width/2)-(bg_con._width/2);
}
};
Stage.addListener(stageL);

cover._x = Math.round(Stage.width - Stage.width);
cover._y = Math.round(Stage.height / 2);
address._x = Stage.width / 2;
address._y = Stage.height - 30;
header._width = Stage.width;
footer._width = Stage.width;
footer._y = Stage.height;
footer._y = Stage.height;
BUT now I want to be able to have random images loading... I had this previously but can't seem to implement it into the new code...


Code:
var myTest = random(6) + ".jpg"; // Load 1 of 6 random images
Also further down the timeline I want to be able to add an image I directly target which I have been able to achieve by placing this on the timeline...

_root.loadBitmapSmoothed("images/image1.jpg", _root.bg_con);

Any help would be greatly appreciated!

Random Loading Images
Hello..

I have searched a while for a tutorial that shows how to load in a random image to a flashmovie. I want have a bunch of images in an external location such as a xml file or simply in a location on the server. And i want that each time someone visit the site a new image sfrom the xml/location should be loaded.

Are somone have a tut or maybe know? thanks! :D

Loading 25 Random Images... Help, Please?
I am wondering how I can make a flash movie that when started, loads 25 different pictures from a specified folder in a computer. Every few seconds, one picture turns to reveal another picture. It could be that only 1 picture at a time turns to reveal another picture "behind" or maybe 2 random pictures turn at a time.

[See my post at the bottom with more questions.]

Does anyone know how I could write the code for this? How do I set up the document? I obviously know how to put 25 different pictures on the stage, but how do I write the code so that a picture "turns" to reveal another picture in my folder?? Is this even possible?

Thanks in advance

Random Loading External Images
I'm using this code:

Code:
maxVal = 10;

myVar=Math.round(Math.random()*maxVal);

_root.mc_container.loadMovie("fotos/foto"+myVar+".jpg");

Now I need some more code to wait a few seconds, fade out the current picture and load a new one, fading in of course.

Unlimited Random Loading Images
I'm looking to create a swf that loads a random image externally and i found this on kirupa.com :

choice = Math.round(Math.random()*5);
switch (choice) {
case 0 :
location.loadMovie("image0.swf");
break;
case 1 :
location.loadMovie("image1.swf");
break;
case 2 :
location.loadMovie("image2.swf");
break;
case 3 :
location.loadMovie("image3.swf");
break;
case 4 :
location.loadMovie("image4.swf");
break;
case 5 :
location.loadMovie("image5.swf");
break;
}

which seems to do the trick however it means i need to go into the swf to change the code every time i have a new image to add to the list

Is there a way i can change this so it would work for any number of images?

Loading Random Images From A Folder
Hi All,

I have a little Flash header and each time it loads I want it to load one of six images randomly, onto the stage as a background... The images will be sitting in a folder in the same directory as the Flash file so they can easily be updated, anyone ever done this? Some opinions would be much appreciated!

Random Images Loading Problem
hi
Plz go through the following code


ActionScript Code:
var loadVars:LoadVars = new LoadVars();
loadVars.onLoad = function(success:Boolean) {
    if (success) {
        var images_array:Array = this.imgs.split(",");
        var randImg:Number = Math.round(Math.random()*(images_array.length-1));
        movieurl = images_array[randImg];
        trace("len : "+images_array.length)
        trace("imgArray : "+images_array);
        trace("randval : "+randImg);
        trace("movieurl : "+movieurl);
        loadMovieNum(movieurl, 1);
    } else {
        trace("error loading file");
    }
};
loadVars.load("lvr.txt");

In above code iam loding random images every time page refreshes.
'imgs' is external notepad variable that contains images paths like img1.jpg,img2.jpg,img3.jpg etc..

This code works everytime (image is loading) except when random number is the last element of array.In the above array img3.jpg is not loading. file loading error occurs.I checked the image exists in the folder.

can any one help?
Thanks in advance.

Loading Images At Random 5 At A Time
hi, i tried searching, but not many i found helpful.

i am trying to create a sort of slideshow. where images are loaded randomly from an external source. say xml file.

i want to load em into a movieclip. which then fades out. sort of morphing into the next picture in a sense.

but i want to load 5 at a time. show them. and while they're showing load the next 5. so on a decent internet connection it would be non stop. with just a not very noticable progress bar on bottom. incase lower internet conn people are viewing.

i am not very familiar with actionscript. only the basics. but have worked with php for quite sometime and some C,C++.

i've an idea on how to load an image into a movie clip and fade it out. but not sure on how to load 5, show, while loading next 5.

if somebody could point me into directions on how to accomplish each of those tasks. that would be very helpful

thank you in advance

Loading Random Images In Intervals
I am very new to doing ActionScripts and I want to create an applet which reads from an XML and builds an array of the URL for images, then loads the images in a repeat with about 5 second intervals without the use of any buttons. Here's what I have in my actionscript coding, but what does not seem to work is the ability to switch images in a loop. How can I do that?









Attach Code

ap_xml = new XML();
ap_xml.ignoreWhite = true;
ap_xml.load('imglist.xml');
ap_xml.onLoad = function(success) {
if (success) {
xml2Array(this);
}
};

function xml2Array(filexml):Boolean {
var aImgFiles:Array = new Array();
aImgFiles = parseFile(filexml);
aImgFiles = myScramble(aImgFiles);
var ainURL:String;
var blnLoad:Boolean = true;
do {
ainURL = aImgFiles[(j++ % aImgFiles.length)];
setInterval(myLoadImgs(aImgFiles[(j++ % aImgFiles.length)],5000));
} while (blnLoad)
return true;
}

function parseFile(xmlDoc_xml):Array {
var temp = new Array();
for (var a = 0; a<xmlDoc_xml.firstChild.childNodes.length; a++) {
temp.push(xmlDoc_xml.firstChild.childNodes[a].firstChild.nodeValue);
}
return temp;
}

function myScramble(fArray:Array):Array {
var tmpArray = new Array();
for(var i = fArray.length; i > 0; i--) {
var j = Math.random() * i;
j = Math.floor(j);
tmpArray.push(fArray[j]);
fArray.splice(j,1);
}
return tmpArray;
}

function myLoadImgs(inURL:String):Boolean {
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcLoader.loadClip(inURL, mc);
return true;
}

























Edited: 03/30/2007 at 08:21:14 AM by jfalberg

Loading Random Images Through An Array
there was a tutorial on this site i believe that loaded random images through an array (the array listed all the images and on reload it just found a random image from the array and loaded it). does anyone know the link to that? i've searched the forums and inevitable the site with nothing.

i knew i should have saved the link

Loading Random Images - Problem
Hi,
I want an image being randomly loaded out of a folder, each time you access or reload my web-page.
I use this code:

filename = ["image1.swf", "image2.swf", "image3.swf"];
path = "file:///folder_path";
i = filename.length;
k = Math.floor(Math.random()*i);
loadMovie(path+filename[k], movieTarget);

It works fine when I test the movie within Flash; but it is not working at all in any browser I test the movie in. I use Dreamweaver for the test.
I am really frustrated about this. If anybody can give me a hint what I`m doing wrong, or maybe a different actionscript code that solves my problem, IŽd be very glad.

Thank you very much in advance
Bye
Lars

Loading Random Images From A Folder
Hi All,

I have a little Flash header and each time it loads I want it to load one of six images randomly, onto the stage as a background... The images will be sitting in a folder in the same directory as the Flash file so they can easily be updated, anyone ever done this? Some opinions would be much appreciated!

Loading Unduplicated Random Images
I have a number of images I'd like to appear in a random stacked order. I'm just starting with 3 for now but it could go as many as 24. Right now I just want the variables to each have a unique number that will become a keyframe number in a MC holding all the images.

This is my code that almost works...


Code:
dork = random(3)+1;
trace ("dork = " + dork);

cat = random(3)+1
if (cat != dork){
trace("this works");

} else {
cat = random(3)+1
trace ("trying again");

}

trace ("cat = " + cat);

dog = random(3)+1
if (dog != cat and dog != dork){
trace("this dog works");

} else {
dog = random(3)+1
trace ("trying dog again");

}

trace ("dog = " + dog + newline + "=============");
Thanks in advance!

Copyright © 2005-08 www.BigResource.com, All rights reserved