PDA

View Full Version : problems with changing Scene in movie


boyzdynasty
07-14-2004, 11:32 PM
I was helping someone...and was trying to put a fla together...but it's not working.

I have a combo box. Depending on what the user selects it will gotoAndStop at the scene the user picked.

But it's not working


/*
comboBoxInstance.addItem("label display", "data");
*/
comboBoxInstance.addItem("Scene 1", "Scene 1");
comboBoxInstance.addItem("Scene 2", "Scene 2");
comboBoxInstance.addItem("Scene 3", "Scene 3");

listenerObject = new Object();
listenerObject.change = function(eventObject){
trace(eventObject.target.value);
// Goes to whatever scence was selected
_root.gotoAndStop(eventObject.target.value,1);
}
comboBoxInstance.addEventListener("change", listenerObject)

stop();



I also attach the file

doublethink
07-15-2004, 01:31 AM
theres no way to make each scene its own .swf instaed, and use loadmovie from an index?

sorry i dont have time to look at your .zip, good luck though.

deadbeat
07-15-2004, 01:47 AM
Using Scenes is never a good idea in actionscript, they just don't work right...

Better idea is to use frame labels...

K.

boyzdynasty
07-15-2004, 05:14 AM
thanx for your response.

I was just helping someone out...it's definitely possible to use scenes.

Basically, what it comes down to w/ my question is...what the "hell" is the reason for it not working.

That is all.

I can definitely tell the guy to load *.swf files or use frame labels...but that is not the point.

Just wanted someone to see why it doesn't work.

Anyway, I wanted put a sample file for the poor kid and now it doesn't work the way I have it set up.

What I figured out was..that... the Scene name has to be within quotes. I tried string concatenation but it would not work.

I guess the only work around is to use if and else statements or switch statements, which is how I figured out how to solve the issue. [if anyone is interested]

annexion
07-15-2004, 05:43 AM
comboBoxInstance.addItem({data:"Scene 1", label:"Scene 1"});
comboBoxInstance.addItem({data:"Scene 2", label:"Scene 2"});
comboBoxInstance.addItem({data:"Scene 3", label:"Scene 3"});
//
listenerObject = {};
listenerObject.change = function(evt){
_root.gotoAndStop(evt.target.selectedItem.label,1) ;
}
comboBoxInstance.addEventListener("change", listenerObject)
stop();

Try that and see if it yields any results. The dataProvider class is an array of objects. addItem is the same as adding a value to the end of an array. Using addItemAt is a replace. Therefore, you'd need to define the elements in the array as an object. Notice the curly braces in the addItem() code.

Though value would be fine, I've gone with selectedItem. It's an object reference. So you'd just call a property of that object. In a dataProvider, you can add as many properties as you want. To exploit it using the combobox and listbox seamlessly, be sure you've got data and label properties in each object in the array.

annexion
07-15-2004, 05:44 AM
Appears you've got it sorted out. Ah well, the above will give you pointers for problems that may arise in the future. Good luck.

boyzdynasty
07-15-2004, 02:40 PM
<lol> :p

been awhile since I heard from you. :)

thanx for the reply, it's good to know.

But it doesn't work.

If I get rid off the '_root' in front of the 'gotoAndStop', it tells me that the Scene name has to be within quotes. Maybe this is the big flaw in switch from scene to scene via gotoAndPlay and gotoAndStop.

Just to make sure if my assumption was correct, I tried this
option1:
gotoAndPlay("Scene 2", 1)

versus

option2:
tempVar = "Scene 2"
gotoAndPlay(tempVar, 1)

I would get an error message for option2.