Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable based loading

Status
Not open for further replies.

law78

Technical User
Apr 23, 2004
78
GB
Hi people,

How do I load movie clip (illo1_mc, illo2_mc all the way up to 65) which is located on level 1 based on a variable whic is located on the root timeline.

Basically, I have buttons that when clicked add a digit to the variable called illo. The button loads via loadMovieNum into level_1 (illo_swf) attached to the timeline of that movie I want flash to take the current digit stored in the illo variable on the main timeline and show its relevent movie clips. I have 65 movie clips located in the illo_swf library and I just need to reference them similar to:

Add illo to the beginning of the digit stored in the illo variable located on the root timeline and add _mc to the end, thus, loading the movie clip that responds to the digit currently stored in the variable:

>>>> var illo = 23 >>>> play >>>> illo23_mc.

Sorry for the rubbish explanation, hope someone can figure it out...


 
Frame 1 of the main timeline (actions layer).

Code:
illo = 0;

function buttonClick() {
	i = _root.illo;
	++i;
	_root.illo = i;
	theURL = "illo"+i+"_mc";
	trace(theURL);
	loadMovieNum(theString,1,"POST");
}
button.onRelease = function(){
	buttonClick();
}

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Not sure that would work:

Take a look at
I basically have a main movie that has 42 links to external swf files loaded over the top onto level1.

The problem arose when I added a previous and next button, it is basically too much hassle to go into all 42 (and there is going to be more) external files and edit the code on the previous and next buttons to display the previous and next in the gallery.

That was when I came up with the idea of putting all the seperate illustrations into movie clips host within one swf file rather a seperate one for each, then create a variable that updated depending on which mc, so that the next and previous button code would just retrieve the variable value and add 1 (to go forward) and minus 1 to go back.

Problem is, I don't know how to script this, any help?
 
Nothing is available at that URL?

You are saying two different things. Movies and MC's. The method I posted is for Movies.

It sounds like you currently have a movie that loads 42 movies on level 1. See the code above and apply it to your forward button(maybe change the function name to nextClick()). Then copy the function and change the name to prevClick and change to decrement instead of increment.

Code:
function prevClick() {
    i = _root.illo;
    [highlight]--i;[/highlight]
    _root.illo = i;
    theURL = "illo"+i+"_mc";
    trace(theURL);
    loadMovieNum(theString,1,"POST");
}

If you want to do MC's instead of swf's just change the onrelease function to attachMovieClip() instead of loadMovieNum

Code:
function nextClick() {
    i = _root.illo;
    ++i
    _root.illo = i;
    theMC = "illo"+i+"_mc";
    trace(theMC);
    [highlight]this.attachMovie(theMC,theMC,this.getNextHighestDepth(),{_x:100,_y:100});[/highlight]
}

Your button functions would be:
Code:
nextButton.onrelease = function{
   nextClick();
}
prevButton.onrelease = function{
   prevClick();
}

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top