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




Looping Runtime-loaded MP3 Files?



Aieeeee.... so near, yet so far!

I'm on the last hurdle to making my new site available online, and the last thing I need to do is add a small MC in the top corner that loads MP3 files (there are 5, so the MC has five frames; the user can choose which one they want to listen to, or stop them completely) as the site is playing (streaming them). I use the following Actionscript to load the files:

function loadMP3() {
sound_1 = new Sound();
sound1.loadSound("sounds/Power.mp3", true);
}
function unloadMP3() {
sound_1.stop();
delete sound_1;
}
loadMP3();

This automatically loads the file in question when the playhead enters the frame. The functions are activated by Pushbutton components saying "Play" (for loadMP3) and "Stop" (for unloadMP3).

The problem I have is that I chose 5 ambient songs that complimented the content and yet were quite short and small in file size (so that even those on 56k could still hear them). Therefore they don't last long without stopping!

I think I need to add sound_1.start(0,999) somewhere in the actionscript to loop the sounds, but I can't figure out where. I've tried straight after sound_1.loadsound but that does nothing. I've tried replacing the final loadMP3 (the one that starts the sound automatically) with the .start command, but that won't work either.

Where am I going wrong? The site needs to be up on Sunday, I'm running out of time, and this is the last major problem that needs sorting... can someone help?



FlashKit > Flash Help > Flash MX
Posted on: 12-10-2002, 12:07 AM


View Complete Forum Thread with Replies

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

Looping Externally Loaded Swf Files
I'm trying to load external .swf files into a blank MC on the main timeline (using loadMovie). The external files contain music (1 track in each .swf). I want these .swf's to load one after the other and then loop back to the first .swf again (like a CD player set to repeat all songs). What kind of script can I write to accomplish this?
Note: In the external swf files, the sound is in a MC called audio. No other frames exist in the .swf.
Also, what's the best way to script button controls that can stop, play, fwd to next track or rev to next track??
Help!

Thanks!

Create Txt/xml Files In Runtime?
Is it possible to create or modify files in flash?
I have put data from an xml file in an xml object, changed the xml object and now I want to write the changes to file?

I've googled alot for this with no result,
can it be done?

/Per-Henrik

Trouble Getting Loaded Swf Url At Runtime.
I need to determine the url of a loaded swf at runtime.

I used to be able to use:

import flash.display.*;
var myLoaderInfo:LoaderInfo = new flash.display.LoaderInfo();
var myurl:String = myLoaderInfo.url;

Worked just fine until the recent flash cs3 update. Doesn't work now.

It's a little like twilight zone. I thought maybe I changed something so I looked in a working example. The code is the same. Compiled and ran a week ago. Doesn't work now.

I don't mind. Might be I was using a side-effect that should not work.

Is there a proper way to the the url of the swf file during runtime?

Or is there an obvious fix that will make the above snippet run again?

Thanks for any clues,
Claude

Instance A SWF That Is Loaded At Runtime
Hi all,
This sounds like a bit of a stupid question but how do i make an instance of a loaded SWF file in as3. I load my needed file in and then store it in a global var so i can use it throughout my program. However i need to instance it off of this var so i can have multiples of this movieclip showing at the same time. Does anyone have any ideas i have been searching for this for some time now and cant find anything (maybe i am searching the wrong thing).
Regards
Mark

Opening Files From Flash @ Runtime
how do you open a file from flash at runtime please help!!
IS there an EASY way?

Runtime Sharing & External Swf Files
I'm making a flash movie that has a pallete of objects (movie clips) which you can basically drag out onto the screen and create a picture. This has been working seemlessly...until I decided that it would be a good idea to have external pallete that you could load in. I can get the "palletes" (swf files) to load in and share their respective movie clips. However, they seem to only work if I load the new movie into root (which will not work, as it will replace all the current content) or if i load the new movie into another "holder" movie clip and then spawn that movie's movie clips inside "holder" (which also will not work for me, as i need to use these clips in the main stage with others).
Does anyone have any ideas to get around this. Suggestions?

Importing Local Files During Runtime (swf)?
Hi All,

I've posted in the actionscript section, but didn't get any feedbacks, if anyone can help me out would be great!

does anyone know if a running swf can access or attach images from a users' local computer? Because I know a running swf can read .as files, so I was wondering if flash can grab local jpegs/pngs/swfs in run time. Please let me know if there's anyway that this can be done, thanks!

Is It Possible To Have Users Browse Their Files At Runtime?
I need to make a flash movie where the user is able to click a button and browse his/her files, namely picture files like jpg. After the user finds his file and selects it, I want the return to be the location of the file.
The command
Code:

fl.browseForFileURL("open");

doesn't work. I have a suspicion that I should use
Code:

fscommand

for this, but I don't know javascript at all. Any suggestions?

Resizing Pictures Loaded At Runtime
I'm writting a small script that loads pictures at runtime and then displays them in several sizes (2, actually =P). The thing is, I managed to load the pictures and everything, but I'm not beeing able to resize them to my needs. What I have so far is something like this:

//------------------------------------------------------
// Variables
//------------------------------------------------------
var pictureList:Array = new Array();
var vars:LoadVars = new LoadVars();
var picturePath:String = new String(".");
//------------------------------------------------------
// loadList
//------------------------------------------------------
loadList = function() {

var i:Number;

// Load list
for (i=1 ; i<=vars.picCnt ; i++)
pictureList[i] = vars["pic" + i];

// Load pictures
_root.createEmptyMovieClip("largeDisplay", 1);
largeDisplay.loadMovie(pictureList[1]);

// :: TODO :: TODO :: RESIZE HERE!
}
//------------------------------------------------------
// Main script
//------------------------------------------------------
// Load picture list
vars.load(picturePath + "/pictures.lst");
vars.onLoad = loadList;

I tryed using "largeDisplay._width = nSomething" but whenever I do this, the presentation just goes blank (no picture is displayed).

Does anybody know what's wrong?

Best regards

Runtime Loaded Asset Seems To Have No Definition
Hi,


one of you forum readers might get the title for "AS-Guru of all time" pointing me the solution to THIS:

I'm publishing an SWF file on domainA and loading every graphical assets and included classes from another SWF located on domainB.
It's great.
Locally.

I mean that when the two files are loaded locally side by side, everything rolls fine.
As soon as I'm trying to load the assets library from domainB, I get a runtime error #1009 (null object reference).

The following "crossdomain.xml" is hosted on domainB :

Code:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
<allow-access-from domain="localhost" />
<allow-access-from domain="127.0.0.1" />
</cross-domain-policy>
but doesn't seems to accept remote serving of an SWF from another.
I worked my way around security issues by declaring in the first frame of the library SWF

Code:
Security.allowDomain("*");
(now that's security...)
and the library assets gets loaded fine from domainB, like this:

Code:
var path:URLRequest = new URLRequest(Config.SERVER_PATH + "assets/assets.swf");
var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onAssetsLoadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.load(path, context);
Or do they?

The classes associated with the linked library assets gets loaded fine too, as I can instantiate them.
The thing is every time there's a sub-clip inside one of them, it doesn't seem to get defined at all.
For instance, I have SimpleButton called "replay_btn" inside a movieClip linked with "OptionsButtons" class.
I have this

Code:
public var replay_btn:SimpleButton;
in the class definition.

I repeat : this is working fine when

Code:
Config.SERVER_PATH = ""
not anymore when

Code:
Config.SERVER_PATH = "domainB"
Winners might get recognition.
A whole lot'of'it.

I know many chicks.
Please help.

Anyway To See Whats Loaded Into Each Level At Runtime?
I have a bit of a problem. I need to turn off the music to my site from a sub swf.

This is the structure:


Code:
_level0 - main.swf
_level1 - footer.swf (music is controlled here)
_level2 - contentholder.swf
_level1 - content.swf
So the content swfs are loaded into the content holder swf which has been loaded into the main.swf, the questions is, how can i turn off the music controlled in footer.swf from a content.swf? And is my levelling structure appropriate, is it ok to use _level1 again from contenthold.swf or should I be using _level3 there?

Thanks again.

Linkage-identifier From Runtime-loaded Swf?
Hi,
Is it possible to get MC's from a runtime-loaded SWF?
My idea is like this:

graphics.swf
- holds a lot of MC's and they all got their linkage-identifier set like this:
MC_GROUP1
MC_GROUP2
etc.

Can I from my main.swf load the swf and the use attachMovie somehow to retrieve the MC_GROUP's? Like this somehow (example below doesn't work ofcourse...):

_root.BOX.loadMovie("graphics.swf");
_root.attachMovie("_root.BOX/MC_GROUP1",1);

Anyone any idea to get around this?

Runtime Loaded Asset Seems To Have No Definition
Hi,


I'm looking for a way to make THIS work:

I'm publishing an SWF file on domainA and loading every graphical assets and included classes from another SWF located on domainB.

When the two files are loaded locally side by side, everything works fine.
As soon as I'm trying to load the assets library from domainB, I get a runtime error #1009 (null object reference).

The following "crossdomain.xml" is hosted on domainB :
Code:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
<allow-access-from domain="localhost" />
<allow-access-from domain="127.0.0.1" />
</cross-domain-policy>
but doesn't seems to accept remote serving of an SWF from another.
I worked my way around security issues by declaring in the first frame of the library SWF
Code:
Security.allowDomain("*");
and the library assets gets loaded fine from domainB, like this:

Code:
var path:URLRequest = new URLRequest(Config.SERVER_PATH + "assets/assets.swf");
var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onAssetsLoadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.load(path, context);
Or do they?

The classes associated with the linked library assets gets loaded fine too, as I can instantiate them.
The thing is every time there's a sub-clip inside one of them, it doesn't seem to get defined at all.
For instance, I have SimpleButton called "replay_btn" inside a movieClip linked with "OptionsButtons" class.
I have this
Code:
public var replay_btn:SimpleButton;
in the class definition.

This is working fine when

Code:
Config.SERVER_PATH = ""
not anymore when

Code:
Config.SERVER_PATH = "domainB"
Help, I'm out of ideas...

Runtime Loaded Image Pixel Color
I have used methods to find the color of a pixel in an image by Bitmap Data Class but this works only for images already imported in library but i want to make this work with images not loaded in the library at design time but loaded at run time.... Can any one help me with some code.....?

ComboBox Problems When In A MovieClip Loaded At Runtime
Hello,

I hope someone out there can help me with this problem: I have a ScrollPane that contains a MovieClip that to which I attach several other MovieClips at runtime in response to user inputs using attachMoveClip() (both MCs are in my library and set to export for actionscrip in first frame). Each of those MovieClips contains a ComboBox.

At runtime, I attach the MovieClip containing the ComboBox, then I set the dataProvider property for the ComboBox to a list (Array) of data/label value pairs. I then try to set the text property of the ComboBox to a "Please select a value" message and then I add a couple of listeners.

Setting the dataProvider property sort of works: the ComboBox displays the proper dropdown list when clicked, but nothing happens when I select an item from the dropdown list - i.e., the selected value doesn't display in the ComboBox's TextField.

Setting the text property doesn't seem to work: the value doesn't display in the ComboBox's TextField, but oddly, if I trace the ComboBox's text property, it outputs the correct message.

Also, none of the event handlers work at all.

I tried all of the same code on a ComboBox that isn't created dynamically, and it all works.

Here's the code. The first set of code is the part I need to get working. It sets up the ComboBox after the MovieClip it is contained in is attached to the parent MovieClip. The second set of code was my test code to see if this worked on a ComboBox that isn't created at runtime. It all works properly.









Attach Code

/******************************
First set of code: sets up ComboBox contained in a MovieClip that was just attached to another MovieClip (contained in a ScrollPane). Doesn't work properly.
The ComboBox is 'pathwayMC.pathway_area.area.vehicle_cb' (sorry for the long reference).
******************************/

//setup list for ComboBox (values are from an XML file)
vehiclesList = new Array(vehiclesArray.length);
for (var i = 0; i<vehiclesArray.length; i++) {
vehiclesList[i] = {data:String(vehiclesArray[i].firstChild.firstChild.nodeValue), label:String(vehiclesArray[i].firstChild.firstChild.nodeValue)};
trace(" adding: " + vehiclesList[i].label); //outputs correct values from XML file
} //end for

//Set the dataProvider property for the ComboBox to the list:
pathwayMC.pathway_area.area.vehicle_cb.dataProvider = vehiclesList;
var foo = pathwayMC.pathway_area.area.vehicle_cb.dropdown; //This line forces Flash to instantiate dropdown list to avoid delay when user first interacts with ComboBox.

trace("First entry: " + pathwayMC.pathway_area.area.vehicle_cb.getItemAt(0).label + " (" + vehiclesList[0].label + ")"); // the getItemAt(0) traces as undefined, while vehiclesList[0] traces as the correct value

//Setup event handlers (these are for debugging purposes currently, but I'll need event handlers later). Neither of these work right now (i.e., nothing traces when I select a different value, or rollover the items in the dropdown list, both of which should trigger one of these events).
cbListener.change = function(event_obj:Object){
trace("Value changed to: " + event_obj.target.selectedItem.label);
};
pathwayMC.pathway_area.area.vehicle_cb.addEventListener("change", cbListener);
cbListener.itemRollOver = function(event_obj:Object){
trace(" roll over");
};
pathwayMC.pathway_area.area.vehicle_cb.addEventListener("itemRollOver", cbListener);

//Setup initial message to be displayed in the ComboBox's TextField:
//This doesn't display
pathwayMC.pathway_area.area.vehicle_cb.text = "Please select a vehicle type";
trace("Message: " + pathwayMC.pathway_area.area.vehicle_cb.text); //Outputs "Please select a vehicle type"

/******************************
Second set of code: sets up ComboBox on the Stage (not created at runtime). Everything works properly.
The ComboBox is 'my_cb'
******************************/
//Setup list for ComboBox:
var list:Array = new Array({data:0, label:"zero"}, {data:1, label:"one"}, {data:2, label:"two"}, {data:3, label:"three"});
my_cb.dataProvider = list;

//Setup event listeners:
var myCBListener:Object = new Object();
myCBListener.change = function(event_obj:Object){
trace("Value changed to: " + event_obj.target.selectedItem.label);
};
my_cb.addEventListener("change", myCBListener);
myCBListener.itemRollOver = function(event_obj:Object){
trace(" roll over");
};
my_cb.addEventListener("itemRollOver", myCBListener);

//Setup initial message:
my_cb.text = "Please select a vehicle type";
trace("First entry: " + my_cb.getItemAt(0).label + " (" + vehiclesList[0].label + ")");

How To Associate Class With Clip Loaded At Runtime
Hi. Does anyone know how to associate a class (that extends MovieClip) with a movie clip loaded at runtime with a MovieClipLoader. I want to do the same as the AS 2.0 Class property of a MovieClip symbol in the Library but with a dynamically loaded MovieClip, not one that is created with attachMovie. Cheers.

Skewing A Dynamically Loaded Image At Runtime...
Hi,
am doing a kind of gallery swf, and loading in thumbnails dynamically using loadMovie.

When the user clicks on one of these thumbnails I'd like to load the bigger image into a kind of skewed picture of a mobile phone - so that it fits.

Is there any way that I can skew the image when it loads?  
(the effect I'm looking for is kind of 3d, leaning forward kind of thing)

I can't change the original image... (although if anyone knows of a dotnet solution for dynamically skewing the image and serving it to flash instead that'd be great too)


Any pointers would be appreciated.
cheers,
Sarah



Accessing Code In Runtime Loaded Swfs
Hi all,

I load an external swf at runtime, and then get that swf to instantiate one of it's clips with attachMovie().

My problem is that this attached clip has some properties embedded as actionscript in frame 1 (eg)


ActionScript Code:
var m_strName:String = "Test";


Now in my main movie script I try and access this right after the attachMovie() thus:


ActionScript Code:
mcExternalLibrary.attachMovie("Test", "mcTest");
var strTestName:String = mcExternalLibrary.mcTest.m_strName;


The problem is this doesn't work. I just get back undefined even though mcTest is there ok. After some testing I found that I need to let the playhead advance before I can access variables declared in frame one of the test clip. In other words I have to exit my script with a play() and then in the next frame call another function to read the property.

I can't even just do an mcTest.gotoAndStop(2). I have to let the playhead advance by itself.

This means I have to break out of my script and it is turning my finely crafted code into complete spaghetti.

Is there any way you can think of that I can get the test clip to initialise it's properties in frame 1 without exiting my script?
Or is there any other way of giving a clip properties that I can access at runtime other than member variables?

Thanks

Attach Events To Runtime-loaded Movie Clips
Hello,

I am trying to attach some events to a movieclip which i load at run-time:


Code:
var cardBack:MovieClip=this.createEmptyMovieClip("cardback", 999);
cardback.loadMovie("http://www.xshaped.com/cards/cardback.png");
cardback.onRollOver = function() { trace("test");}
But nothing happens on mouseover.

Any ideeas?

Thanks.

How To Make A Loaded .swf Auto-resize To Fit Its Content,which Will Change At Runtime
Well, first I don't even know if this is possible, lol, but I think I saw something like this once in a website, and I'd really need it to work.

I have a site which loads an external .swf and puts it inside a scrollpane (or should I say scrollPAIN).

This external swf is initially empty, and generates its content at runtime duplicating some movieclips inside it. But this content can change everytime (this is all for a dynamic image gallery, and the .swf file is the one containing the thumbnails, so it has a different number of them for each different gallery).

The problem is, right now I have to make a separate .swf file for each thumbnail gallery, one by one, making each of them of the corresponding size to contain the number of thumbnails they'll create at runtime.

For example, if every thumb is 50 px in height and a gallery has got 10 of them, I have to make a .swf file which is 50 * 10 = 500 px in height.

But if another gallery has 8 of them, the .swf file has to be 50 * 8 = 400 px tall, so I need to make an identical .swf which is 400 px tall.

What I'd like to be able to do is the .swf to automatically resize itself to fit the content it loads at runtime.

I hope I made myself clear, as this is a bit tricky to understand if you're not seeing it.

Thanks in advance for any replies

Looping A Loaded An Externally Loaded Mp3
I was trying to loop an externally loaded mp3 and suceeded on my machine, but when I upload the swf and mp3, the function will not work in my browser (IE). I tried a relative path, as well as the absolute URL and neither worked. Here is the code I used to loop the externally loaded mp3:

loopSound = function () {
my_sound.loadSound("whisper.mp3", true);
};
my_sound = new Sound();
my_sound.loadSound("whisper.mp3", true);
my_sound.onSoundComplete = loopSound;
my_sound.setVolume(45);

Any help would be most appreciated, I have wasted a lot of time on this already.

Retaining Order Of Files Loaded Externally From Large XML Files
Hi everyone,
I was messing around with some old examples, and I ran into an unfinished example where several 30k-100k XML files are loaded and stored as a string into an Array. The code looks basically like:

Code:
//example input: foo.xml%zeeb.xml%blarg.xml
function loadXML(filePaths:String) {
filesArray = filePaths.split('%');
for (var i:Number = 0; i<filesArray.length; i++) {
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = function(success) {
if (success) {
//order of files loaded is messed up here!
parseXMLData(this, filesArray.length);
} else {
//trace(filesArray[1]+" failed to load!");
}
};
xmlData.load(filesArray[i]);
}
}
Basically, when I trace the 'this', the order of the files that are loaded is off. Out of about 10 tries, about 3 times the order is perfect. The remaining 7 times, the order is a bit off. Does anybody have a suggestion on how to ensure the files are loaded prior to the next file being loaded?

I tried placing a while loop that basically delays the clock for a few milliseconds, and that didn't work either. Besides, that is not really a good solution to arbitrarily waste clock cycles. I am guessing some sort of a listener might be needed, but that is where I've hit a wall

Thanks!
Kirupa

Looping Files
How do I loop a flash file?

Loaded SWF Keeps Looping
Hello Flash Wizards,

I'm needing some help.

I've got a movie into which I'm loading another movie. The 'host' file has a LoadMovie action in it.

Here's the problem:

--The .html file plays the entire loaded movie over and over.

--The .swf file loads the movie continuously only getting to the first or second frame.

The first time I published I had the Loop option checked in the HTML tab. But I subsequently exported many times with it checked off and no dice.

I've also tried putting a stop action after the LoadMovie action and also one at the end of the loaded movie but that didn't work either.

Can anyone help? I'm stuck.

Ideally, I'd like the movie to load and play the movie at launch and then for the loaded movie to call up the next loaded movie to take its place. Is this doable?
Thanks!

Looping A Loaded MP3?
Can I program the file to loop the mp3?

I'm using the following code:

mySound=new Sound();
mySound.loadSound("music.mp3",true)
mySound.setVolume(50);
mySound.start(0,999);

When I add the line **mySound.start(0,999);** it refuses to play the MP3.

Any suggestions?

Cheers,
Jen

Looping Loaded Mp3
how do you loop a dynamically loaded mp3?
thanks,
Aaron

2 .swf Files Continuously Looping, One After Another
I have 2 swf files. How can I get one to play and then the other play + have them continually loop, one after another?

I'm ok with having this happen in a browser, but since they are large swf files and I'd like to have them loop uninterruptedly, I'd prefer to have one executable projector file that just keeps the whole thing going smoothly.

Ideas?

Remote Files And Looping
Okay, I have a box, with these dimensions
W:340
H:250
Basically, its a grid of 20x10 rectangles (w by h)

I want to load an actionscript file so it loads a ascii file that has the following:


Code:
01001001000010000
00000100001000100
00100001000000001
00000000000001000
01001000100010001
01001001000010000
00000100001000100
00100001000000001
00000000000001000
01001000100010001
01001001000010000
00000100001000100
00100001000000001
00000000000001000
01001000100010001
01001001000010000
00000100001000100
00100001000000001
00000000000001000
01001000100010001
01001001000010000
00000100001000100
00100001000000001
00000000000001000
01001000100010001
00000000000001000
01001000100010001
Now, the 0s can be replaced with 1s, and vice versa

The file is 17x25 numbers

Also, the numbers don't have to be binary



Anyway,
The actionscript reads the file
If it encounters a 0, it goes to the next grid point
If it encounters a 1, it displays a 20x10 rectangle



Its made on Flash MX

Thanks a bunch

Help With Looping Sound Files.
Hi there, just been having a little trouble with getting my sounds to loop in odd circumstances and haven't been able to find anything in the search..


basically i have two different problems. One is streaming bg music, it loads inside a movie clip with this code no problems;

Code:
var bg_music:Sound = new Sound(this);
bg_music.loadSound("servants.mp3", true);


But i need the mp3 to loop infintely, what code do I add to achieve this?

THe other problem I have is a sound effect on a button:
I preload it with

Code:
var sd_static:Sound = new Sound(this);
sd_static.attachSound("static");
stop();


And then just use a sd_static.start(); to begin the sample of a button rollover. However it only plays one cycle, i need it to loop infintely (there is a stop() command on rolloff.

I know that start() had a loop variable, but I dont' quite understand how to impliment it properly.

Thanks for your help!

-LetterAfterZ

EDIT: I am aware that you can use a command like start(0,10) to make it loop say 10 times, but I want it to loop forever, is the solutoin just to put in a REALLY high number, or is there a better way? And in the case of my streaming BG mp3, apparently you can't make that loop using that method?

Looping Through All The Files In A Folder
Hi

I'm totally new to Flash (usually I do print and video stuff), but have been asked to put together a simple photo gallery on CD for somebody, largely as a favour. I bought a template from ohmyflash.com (have emailed them about this but so far, nothing) which can be viewed here:

http://www.ohmyflash.com/gallery/124/124a.html

The way they've set it up (which I didn't realise at the time) is for the images to be numbered 1.jpg, 2.jpg, etc. There's a variable which sets how many images it's looking for, and then it loads them up. If it tries to load one it can't find, you just get a blank.

Anyway. The images we have are all named in a specific way (eg "Aleksander Nevsky Cathedral 1, Toompea, Tallinn, Estonia.jpg"). The ideal would be to set the template up with a caption field, so it does this:

for each (file in folder) {
if (filetype is jpeg) {
// display thumbnail
}
}

thumbnail.onClick {
// display larger image
// set image caption to the filename minus the .jpg
}

I'm pretty familiar with PHP, ASP and JavaScript, but ActionScript isn't making a lot of sense to me, and I can't work out how to do this. I suppose a neater way would be to use XML, but this template isn't set up to use XML. If you can help me do this, I'd be massively grateful. I'm using Flash CS3, so compatibility shouldn't be a problem. The existing ActionScript code is pasted below.

Thanks in advance

Nick



/* Current actionscript */

PHP Code:



function btnImgSet(pageNum)
{
    dupNum = (pageNum - 1) * imgPerPage + 1;
    for (var _loc3 = 0; _loc3 < imgNumy; ++_loc3)
    {
        for (var _loc2 = 0; _loc2 < imgNumx; ++_loc2)
        {
            if (dupNum <= imgTotalNum)
            {
                var _loc1 = this.menuMc.btn.duplicateMovieClip("btn" + dupNum, dupNum);
                _loc1.loadSmallBox.loadMovie(imgFolder + "/img" + dupNum + ".jpg");
                _loc1._width = imgWidth;
                _loc1._height = imgHeight;
                _loc1._x = btnStartx + imgWidth * _loc2 + imgSpacex * _loc2;
                _loc1._y = btnStarty + imgHeight * _loc3 + imgSpacey * _loc3;
                ++dupNum;
                _loc1.onRollOver = function ()
                {
                    this.play();
                };
                _loc1.onRelease = function ()
                {
                    imgMoving = true;
                    _root.loadBox.targetMc._alpha = alphaTrans = delTimer = 0;
                    _root.loadBox.targetMc.loadMovie(imgFolder + "/img" + this._name.slice(3) + ".jpg");
                };
            } // end if
        } // end of for
    } // end of for
} // End of the function
function removeImg()
{
    var _loc2 = this;
    for (var _loc1 = dupNum - imgNumx * imgNumy; _loc1 < dupNum; ++_loc1)
    {
        _loc2.menuMc["btn" + _loc1].removeMovieClip();
    } // end of for
} // End of the function
var stageWidth = 750;
var stageHeight = 620;
var imgNumx = 1;
var imgNumy = 10;
var imgTotalNum = 47;//Total number of images show on movie
var imgWidth = 50;//Thumb  image widths
var imgHeight = 35;//Thumb image heights
var imgSpacex = 3;
var imgSpacey = 5;
var imgFolder = "image";//Image folder path
var imgViewTime = 10;//Number of thumb images per row 
var spaceMCenter = 10;//Space between thumb images
var menuMoving = 1;
var imgSpeed = 3.000000E-001;
var alphaSpeed = 1.500000E-001;
var btnStartx = this.menuMc.btn._x;
var btnStarty = this.menuMc.btn._y;
var imgPerPage = imgNumx * imgNumy;
var lastPage = Math.ceil(imgTotalNum / imgPerPage);
var currentPage = 1;
this.loadBox.targetMc.loadMovie(imgFolder + "/img1.jpg");//First image (On load movie)
this.loadBox.targetMc._alpha = alphaTrans = 0;
this.menuMc.btn._visible = 0;
var imgMoving = true;
var delTimer = 0;
var tempw = temph = 100;
this.menuMc.prevBtn.onRelease = function ()
{
    if (currentPage > 1)
    {
        removeImg();
        --currentPage;
        btnImgSet(currentPage);
    } // end if
};
this.menuMc.nextBtn.onRelease = function ()
{
    if (currentPage < lastPage)
    {
        removeImg();
        ++currentPage;
        btnImgSet(currentPage);
    } // end if
};
btnImgSet(currentPage);
this.onEnterFrame = function ()
{
    var _loc2 = this;
    var _loc1 = _loc2.loadBox;
    if (imgMoving == true)
    {
        if (Math.abs(_loc1.targetMc._width - _loc1.lineMc._width) > 1)
        {
            if (_loc1.targetMc._width == 0)
            {
                _loc1.lineMc._width = _loc1.lineMc._width + imgSpeed * (tempw - _loc1.lineMc._width);
                _loc1.lineMc._height = _loc1.lineMc._height + imgSpeed * (temph - _loc1.lineMc._height);
            }
            else
            {
                _loc1.lineMc._width = _loc1.lineMc._width + imgSpeed * (_loc1.targetMc._width - _loc1.lineMc._width);
                _loc1.lineMc._height = _loc1.lineMc._height + imgSpeed * (_loc1.targetMc._height - _loc1.lineMc._height);
            } // end else if
        }
        else
        {
            tempw = _loc1.lineMc._width = _loc1.targetMc._width;
            temph = _loc1.lineMc._height = _loc1.targetMc._height;
            ++alphaTrans;
        } // end if
    } // end else if
    if (alphaTrans > imgViewTime)
    {
        if (_loc1.targetMc._alpha <= 100)
        {
            imgMoving = false;
            _loc1.targetMc._alpha = _loc1.targetMc._alpha + alphaSpeed * (105 - _loc1.targetMc._alpha);
        } // end if
    } // end if
    if (delTimer++ < 108)
    {
        _loc1._x = _loc1._x + imgSpeed * (stageWidth / 2 - _loc1._width / 2 - _loc1._x);
        _loc1._y = _loc1._y + imgSpeed * (stageHeight / 2 - _loc1._height / 2 - _loc1._y);
        if (menuMoving == 1)
        {
            _loc2.menuMc._x = _loc1._x + _loc1.lineMc._width + spaceMCenter;
            _loc2.menuMc._y = _loc1._y;
        } // end if
    } // end if
}; 

Looping Flash Files
For a novice, is there an easy way to get a flash video to play continuously?

Stop Looping On Swf Files?
how do i stop the looping on my .swf files?

I only want them to play once then hold steady on the last frame and stop playing?

I can do it with the animated .gif output, but i want the same effect with the higher quality .swf files.


Thanks,

Luke

Looping Loaded Sound?
I am in need of this mp3 to loop continuously. How will I edit the code to loop the mp3? Thanks in advance



Code:
on (release) {
_root.mySound = new Sound();
_root.mySound.loadSound("My_Sound.mp3", true);
}

Stop A Loaded SWF From Looping
i have a SWF file that i am loading into a MC in another Flash file. Is there a way to get that SWF to not loop? i do not have access to the source of the SWF so i cannot go into that and set up anything in there.

thanks in advance!
ggogis

Looping A Dynamically Loaded Mp3...
How on earth can I make mp3's, dynamically loaded from an .xml file, loop in the .swf? (they have to be started by a play button)

How Do I Prevent My Loaded .swf From Looping?
I converted an mpg movie to an swf using Ultra Flash; I end up with a nice .swf, but it loops. How can I prevent this video from looping when I bring it into Flash? Is there a way to load the movie, then unload it after 10 seconds of play (one iteration)?

Please help - I'm desperate.

Thanks,

Shannon

Externally Loaded Swf Keeps Looping
I have a button with the following code:

on (release) {
//load Movie Behavior
if(this == Number(this)){
loadMovieNum("bwgroupx.swf",this.loadera);
} else {
this.loadera.loadMovie("bwgroupx.swf");
}
//End Behavior

}

The button works wonderfully but when clicked, the swf file loads and then keeps replaying. When I tested the swf alone, it loaded and played once, which is what I want.

What am I doing wrong?

Thanks much.

LoadVar() From Several Txt Files Looping Problem
hi,

I've got 3 (a.txt b.txt c.txt) files with varying data inside (name1=value1&name2=value2&name3=value3)

now my user types in a series of 3 inputs (name1, name2, name3) - they end up in a list (test_string).

each word in this list is read in turn (active_string).

depending on what was typed, i open one of the text files and loadVar().

finally, i get 1 value from each of the loaded object, say value of "name2" from c.txt (the_topic_object[active_string]).

my problem:
I only get the data string for the last iteration of the loop.

what am i doing wrong?

thanks. code below.

hugo



the_topic_object = new loadVars();
//
for (a=0; a<test_string_qty; a++) {
active_string = new String(test_string[a]);
alpha = active_string.slice(0, 1);

// create the new XML object for getting the file matches
the_topic_object.load("common/results/index_files/rm/"+alpha+".txt");
}
//
the_topic_object.onLoad = function(success) {
if (success) {
trace("the string = "+ the_topic_object[active_string]);
}
};

Looping 3 External .flv Files Forever
Hey,

I am trying to loop 3 .flv files... I have tried reading the other posts
but can't seen to get it to work...

I have it playing 1.flv then 2.flv then 3.flv but then it just stops...
I want it to go back to 1.flv again and then play 2.flv and so on..

I basically want a line of code that says "If Current = 4 make current = 1 again" that way when the count gets to 4 it will go back to 1 again and play
1.flv

HERE IS MY CODE:

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

// Create a NetConnection object:
netConn = new NetConnection();
// Create a local streaming connection:
netConn.connect(null);
// Create a NetStream object and define an onStatus() function:
NetStream = new NetStream(netConn);

NetStream.onStatus = function(infoObject) {
status.text += "Status (NetStream)" + newline;
status.text += "Level: "+infoObject.level + newline;
status.text += "Code: "+infoObject.code + newline;
};
// Attach the NetStream video feed to the Video object:
my_video.attachVideo(netStream);
// Set the buffer time:
netStream.setBufferTime(5);
//create a variable which will reference the current video
current=1;
//start playing the first flv
netStream.play(current+".flv");

netStream.onStatus = function(info)

{
if(info.code=="NetStream.Buffer.Empty" && waitingForEmpty==true)
{


if (current == 4) {

//THIS IS WHERE I NEED TO MAKE CURRENT = 1 again
???? CURRENT = 1?????


} else {
//if its not the last video
//increment current
current++;


}

//increment current
current++;
netStream.play(current+".flv");
}
waitingForEmpty = (info.code=="NetStream.Play.Stop");
};
waitingForEmpty=false;

stop();

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

Any help would be great, Thanks

LOOPING Through Many XML Files To Create Summary
I'm puzzled why this pair of functions stops after each iteration of the loop.

The first function pulls an XML file name from an array of names then tells the second function to load it.

The second function loads and parses the data then adds the values to a total.

I have a button that calls totalHeat() but I have to click it after each iteration to make it read the next file to parse.

Any ideas?


/*this function loops through an array holding a large number
of small XML files then loads the file into the heatTotalXml object*/

function totalHeat() {
fCount += 1;
if (fCount<=_root.addData.numItems) {
var fName = filesArray[fCount];
heatTotalXml.load(fName);
}
}

heatTotalXml = new XML();
heatTotalXml.ignoreWhite = true;
/*this function loops through the nodes and totals up the number of hits on each name variable */
heatTotalXml.onLoad = function() {
var unit = this.firstChild.childNodes;
if ((unit>"")) {
for (var t = 0; t<unit.length; t++) {
var name = (unit[t].attributes.name);
var hits = (unit[t].attributes.hits);
_root["name"+t] += hits;
}
totalHeat();
}
};

Stop Looping A Loaded Movie
Hi again
I made a basic movie with baloons. One of the balloons is a button(first.swf); on mouseevent I load a movie on the same level, so first.swf disappears.

When clicking on this second.swf a third.swf is opening instead of the second.swf. This third.swf is supposed to stop at the end and showing a logo, but it starts and starts again with the second.swf.

I tried to put a stop in the second.swf....but then it stops at the end and this is not the meaning if somebody does not click to start the third.swf.

Can anybody help?

Thanks a lot!

Looping Dynamically Loaded Sound
Say I load an external mp3 dynamically like this:

mySound.new Sound();
mySound.loadSound("thesound.mp3", true);

How would I go about getting the sound to loop?

Thanks,
Selfminded

Looping Dynamicly Loaded Audio
I cant get my background audio to loop when i load them in dynamicly. since dynamicly loaded audio starts playing right away using start() doesnt work for me, can anyone help please

Looping Externally Loaded Jukebox?
How do I loop a song in a externally loaded jukebox? And how can I configure it to not have a moment of silence in the middle of it looping.

Thanks
-J

Help How To Stop Looping Loaded Swf File
Hi I’ve looked everywhere for a solution but I simply can't figure it out. Please help if you can, I'm new to flash and I’m coming up to a deadline where I’m am no where near finished thanks!

I'm making a character select menu and have buttons which load an external animated swf which shows a character profile within an empty movieclip.
I've placed the following code on the button

on (press) {
loadMovie("WB1.swf", "container");

Thing is the animation swf "WB1" loops, I've placed stop(); code at the end of the swf animation and even tried mc_WB1.stop(); as well as trying out placing the code in the character menu but no luck.
Any ideas or different approaches.

Thanks

Cs3 Help How To Stop Looping Loaded Swf File
Hi I’ve looked everywhere for a solution but I simply can't figure it out. Please help if you can, I'm new to flash and I’m coming up to a deadline where I’m am no where near finished thanks!

I'm making a character select menu and have buttons which load an external animated swf which shows a character profile within an empty movieclip.
I've placed the following code on the button

on (press) {
loadMovie("WB1.swf", "container");

Thing is the animation swf "WB1" loops, I've placed stop(); code at the end of the swf animation and even tried mc_WB1.stop(); as well as trying out placing the code in the character menu but no luck.
Any ideas or different approaches.

Thanks

Looping Externally Loaded Music
Just putting together a web site and was just wondering if anyone knows if it is posible to loop externally loaded music when it is loaded into my site. The code im using to get the music into the site looks like this:-

this.createTextField("status_txt", this.getNextHighestDepth(), 0,0,100,22);

var site_sound:Sound = new Sound();

site_sound.onLoad = function(success:Boolean) {
if (success) {
site_sound.start();
status_txt.text = "Sound loaded";
} else {
status_txt.text = "Sound failed";
}
};

site_sound.loadSound("song1.mp3", true);

Any tips would be helpful

[FMX] Looping Dynamically Loaded Mp3s
Hey there. I have brought this up at the end of another thread, but thought it needed it's own.
Trying to loop a dynamically loaded mp3 of a cicada.

cicada = new Sound(cicadaMC);
cicada.loadSound("sounds/cicadas.mp3", true);
cicada.start(0.7, 999);

Why does this not work?
I understand that the start function isn't needed, as it's a streaming object, but I thought if I added it, it would loop. This syntax is the only way I know to loop a sound object in AS.
I have read this
http://kennybellew.com/tutorial/
This tute is great, explains everything about sound files except this problem.
Any takers?

Looping To Give Loaded Progress
I am trying to create a loop that will display the loaded progress of an image.

I have the following code but cant get it to loop to show the progress:

Code:
l = this._parent.photo.getBytesLoaded();
t = this._parent.photo.getBytesTotal();
if(l < t)
{
textbox.text = "Loading (" + l + " bytes of: " + t +")";
}
if(l == t)
{
textbox.text = "done";
}
Please help!

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