Newbie TellTarget script problems

ok so here goes:

i have been follwing the follwing tutorial: http://www.flashkit.com/tutorials/A…_S-89/index.php

which teaches how to use an externa txt file to create a menu system, this works great however ive got myself stuck now that im trying to use it to my own devices i now want this meny system to laod as a container which i have succeeded in doing to a point!

the idea is as follows MenuTemplate action script is as follows:

container.loadMovie(“menus/Menu.swf”);
stop();

this loads the menu in fine however when selecting a button i get the following error:
Target not found: Target="/test" Base="_level0.container.menu.item_1"

i think it is looking at the follwing code within the menu.swf:
on (release) {
// Setting a variable at the root level of the movie is vital to keeping the function abstract enought to work for any menu item. Remember that menu_link was set by this clip’s host, “Menu Item Group”.
/:goto_link = menu_link;
tellTarget ("/test") {
gotoAndStop(/:goto_link);
}
}

it also appears that this scripting dosnt work with action script 2, i need to find a way of re coding this without having to use a different tutroial please help

Please help asap Cheers
Alex

tellTarget is an older method, try:

on (release) {
// Setting a variable at the root level of the movie is vital to keeping the function abstract enought to work for any menu item. Remember that menu_link was set by this clip’s host, “Menu Item Group”.
_root.goto_link = menu_link;
_root.test.gotoAndStop(_root.goto_link);
}

would be the AS2 way of doing that. You have to watch some of the tutorials on Flashkit as the show really old methods of doing things.

that work but now when i go to publish settings and change to action script 2 i get the following errors:

Error Symbol=Menu Item Group, layer=Action Scripts, frame=1:Line 2: Unexpected ‘/’ encountered
if (/:menu_loaded eq 1) {

reffering to:
// This checks to see if all the variables have been loaded yet. Remember, the last variable in the text field is menu_loaded, so if it equals 1, all the other variables must have been loaded.
if (/:menu_loaded eq 1) {
gotoAndPlay(“create_menu”);
}

and the following errors:

Error Symbol=Menu Item Group, layer=Action Scripts, frame=3:Line 4: Operator ‘<=’ must be followed by an operand
while (Number(x)<=Number(/:menu_count)) {

Error Symbol=Menu Item Group, layer=Action Scripts, frame=3:Line 5: ‘)’ or ‘,’ expected
duplicateMovieClip(“menu_template”, “item_” add x, x);

Error Symbol=Menu Item Group, layer=Action Scripts, frame=3:Line 6: ‘)’ expected
tellTarget (“item_” add x) {

referring to the script:

// This loop duplicates a template movie clip and prepares it based on the information set in “menudata.txt”.
item_spacing = 140;
x = 1;
while (Number(x)<=Number(/:menu_count)) {
duplicateMovieClip(“menu_template”, “item_” add x, x);
tellTarget (“item_” add x) {
menu_text = eval(“/:menu_text_” add …/:x);
menu_link = eval(“/:menu_link_” add …/:x);
gotoAndStop(eval(“/:menu_state_” add …/:x));
setProperty(“”, _x, Number(getProperty(“”, _x))+Number((…:item_spacing*(…/:x-1))));
}
x = Number(x)+1;
}
stop();

please help

Alex

that work but now when i go to publish settings and change to action script 2 i get the following errors:

Error Symbol=Menu Item Group, layer=Action Scripts, frame=1:Line 2: Unexpected ‘/’ encountered
if (/:menu_loaded eq 1) {

reffering to:
// This checks to see if all the variables have been loaded yet. Remember, the last variable in the text field is menu_loaded, so if it equals 1, all the other variables must have been loaded.
if (/:menu_loaded eq 1) {
gotoAndPlay(“create_menu”);
}

and the following errors:

Error Symbol=Menu Item Group, layer=Action Scripts, frame=3:Line 4: Operator ‘<=’ must be followed by an operand
while (Number(x)<=Number(/:menu_count)) {

Error Symbol=Menu Item Group, layer=Action Scripts, frame=3:Line 5: ‘)’ or ‘,’ expected
duplicateMovieClip(“menu_template”, “item_” add x, x);

Error Symbol=Menu Item Group, layer=Action Scripts, frame=3:Line 6: ‘)’ expected
tellTarget (“item_” add x) {

referring to the script:

// This loop duplicates a template movie clip and prepares it based on the information set in “menudata.txt”.
item_spacing = 140;
x = 1;
while (Number(x)<=Number(/:menu_count)) {
duplicateMovieClip(“menu_template”, “item_” add x, x);
tellTarget (“item_” add x) {
menu_text = eval("/:menu_text_" add …/:x);
menu_link = eval("/:menu_link_" add …/:x);
gotoAndStop(eval("/:menu_state_" add …/:x));
setProperty("", _x, Number(getProperty("", _x))+Number((…:item_spacing*(…/:x-1))));
}
x = Number(x)+1;
}
stop();

please help

Alex

Thats cause it seem this script is all done in old AS 1 format. You are going to have to update the whole thing.

For example this:
if (/:menu_loaded eq 1) {

needs to be:

if (_root.menu_loaded == 1) {

and the other code(is an absolute mess LOL):

var item_spacing:Number = 140;
for (x=1; <= menu_count; x++){
duplicateMovieClip(“menu_template”, “item_”+x, x);
root["item"+x].menu_text = [menu_text_+x];
root["item"+x].menu_link = [menu_link_+x];
root["item"+x].gotoAndStop([menu_state_+x]);
root["item"+x]._x = root["item"+(x-1)]._x +root["item"+(x-1)]._width + _root.item_spacing;
}
stop();

is as close as I can come to translating what you posted.

after chnaging you suggested codes then upgrading the publish setting to flash 8 actions cript 2 it outputs the following error:

Error Symbol=Menu Item Group, layer=Action Scripts, frame=3:Line 3: Unexpected ‘<=’ encountered
for (x=1; <= menu_count; x++){

Total ActionScript Errors: 1 Reported Errors: 1

please have patience with me and help

Alex

Sorry about that, that was amistake on my end I left out
for (x=1; **x **<= menu_count; x++){

No errors but now it does not duplicate the menu i have attatched the file to try and show you what i am trying to do please help this is killing me:

Alex

This version runs on XML as opposed to a text file. This would be more modern. It does basically what the old one does. Save the XML and the SWF in the same folder.

that seem to make sense however it appear to make one extra button although i have dragged it of the screen and it still works so cheers…

however (the problem continues) if i wanted to to have the following file structure

Main Menu which would activate a button containing the code:

on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = “assets/swf/MenuTemplate”;
container.loadMovie(“assets/swf/MenuTemplate.swf”);
} else if (_root.currMovie != “assets/swf/MenuTemplate”) {
if (container._currentframe >= container.midframe) {
_root.currMovie = “assets/swf/MenuTemplate”;
container.play();
}
}
}

Which would open the extenral swf “Menutemplate” (this has transitions found in the tutorial in Hirupa (transitions between external texts).

then the menutemplate would act as another container for the menus

container.loadMovie(“assets/swf/menus/Menu.swf”);

This dosnt work? Why?

yeah the “extra” button is the original clip that gets duplicated.

As far as the loading goes, you are realoding into the same container clip on the same level, any time you do that, the new contents replace the old ones.

how would i solve this problem?

if you know the instance name of the clip within the clip you have loaded, I suppose you could load another clip into that:
_root.container.clipInsideName.loadMovie();

Sorry i must be a pain but where would this go?

ignore the last question i hace placed the menu within the same folder as the menu template which seems to solve the extra button aswell . however when i go back to the start swf it come up with the error message:

Error opening URL “file:///C|/Documents%20and%20Settings/alex%2Dwork/Desktop/Betatest/Flash/menu.xml”

when i select the button with the following action script:

on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = “assets/swf/MenuTemplate”;
container.loadMovie(“assets/swf/MenuTemplate.swf”);
} else if (_root.currMovie != “assets/swf/MenuTemplate”) {
if (container._currentframe >= container.midframe) {
_root.currMovie = “assets/swf/MenuTemplate”;
container.play();
}
}
}

how do i solve this?

did you move the XML file to the same folder when you moved the movie?

Also, if this SWF is in an HTML page, the XML actually has to be in the same folder as the HTML page that holds the SWF.

i have stipped down my first movie and used your menu to show my problem:

i am trying to load the menu_2 movie as an external movie into start.swf

Error opening URL “file:///C|/Documents%20and%20Settings/alex%2Dwork/Desktop/New%20Folder%20%282%29/menu.xml”

when i move the xml file into the dierectory with the star.swf resides it crashes flash

the reason for the flile organisation is essential in some form as required by the assesment i am trying to fulfill

really it needs to be:

rootfolder/start.swf
rootfolder/assets/swf/menu_2.swf
rootfoler/assets/images/
roofolderassrts/txts/

which folder do i put the xml?