GotoAndStop frame name

  • rezzkilla
  • Beginner
  • Beginner
  • rezzkilla
  • Posts: 55
  • Loc: Alabama

Post 3+ Months Ago

Is it possible to use a variable from a text document to make a button that goes to the corresponding frame name?

text document contains:
&room = kylesroom;

where kylesroom is the name of the frame in the flash movie.
For simplistic sake, the loadVars object comes in something like this:

variable = this.room;

Then the button code to go to kylesroom:
on (release){
gotoAndStop(variable);
}


I did get something close working where I declared a variable in an empty keyframe:

var sopop = "2a";

Then on the button:

on (release){
gotoAndStop(sopop);
}

...this did go to a frame I named 2a but didn't work when I get the variable from a text document. I think I may not be handling the quotations mark correctly.
Many thanks in advance.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • roarmeow
  • Professor
  • Professor
  • User avatar
  • Posts: 861
  • Loc: BKNY

Post 3+ Months Ago

are you sure you're loading the variable from the text doc correctly?

if you're not sure, try having, in the actionscript:
Code: [ Select ]
trace(variable);


with the actual variable name substituted for 'variable' (no quotes)

say you have a text ('document.txt') document with
&room = kylesroom

then have your code read

Code: [ Select ]
myVariable = new LoadVars();
myVariable.onLoad = function(){
  _global.variable = this.content;
};
myVariable.load("document.txt");
  1. myVariable = new LoadVars();
  2. myVariable.onLoad = function(){
  3.   _global.variable = this.content;
  4. };
  5. myVariable.load("document.txt");


and on the button:
Code: [ Select ]
on(release){
gotoAndStop(variable);}
  1. on(release){
  2. gotoAndStop(variable);}


i think that'd work
  • rezzkilla
  • Beginner
  • Beginner
  • rezzkilla
  • Posts: 55
  • Loc: Alabama

Post 3+ Months Ago

That's not working. If I store my incoming variable into another variable name

_global.variable2 = this.variable;

and trace(variable2);

is showing up undefined in the output, BUT if I display in a dynamic text field
_root.txtfield.text = this.variable;

I see the appropriate value of the frame name I need to store in my gotoAndStop() button code.

I'm not sure what to investigate now?
  • rezzkilla
  • Beginner
  • Beginner
  • rezzkilla
  • Posts: 55
  • Loc: Alabama

Post 3+ Months Ago

I'm getting the variable into flash. I can store the variable in a textfield then store that textfield value in another variable and when I trace it I get the correct value. Just to explain my last post a little better.

_root.textfield.text = this.content;
var jojo = _root.textfield.text;
trace(jojo);

on my button:
on (release) {
_root.gotoAndPlay(jojo);
}

Maybe I'm missing something with linking to named frames. I've tried everyway doing it with and without quotes. Can the frame name contain numbers and/or letters that I'm trying to link to? Can the frame name start with a number that I'm trying to link to like 3r?
  • roarmeow
  • Professor
  • Professor
  • User avatar
  • Posts: 861
  • Loc: BKNY

Post 3+ Months Ago

well, that's really odd... that you can pass the variable to a dynamic text field, but not another variable.

at any rate, i'm not sure (maybe someone else can speak to this) if you can use numbers in the initial place of a frame name. i've never done it, but it may be fine.

you know that, in your last example, you didn't make the variable global, right?

Code: [ Select ]
_root.textfield.text = this.content;
_global.jojo = _root.textfield.text;
trace(jojo);
  1. _root.textfield.text = this.content;
  2. _global.jojo = _root.textfield.text;
  3. trace(jojo);


on your button:
Code: [ Select ]
on (release) {
_root.gotoAndPlay(jojo);
}
  1. on (release) {
  2. _root.gotoAndPlay(jojo);
  3. }


that's just odd, though, i'm not entirely sure what's going wrong...

i figure there's definitely a corresponding frame named whatever variable you pass to jojo on the root movie, etc.
  • rezzkilla
  • Beginner
  • Beginner
  • rezzkilla
  • Posts: 55
  • Loc: Alabama

Post 3+ Months Ago

I've made a new flash document with just one button on frame one and ten frames over a named frame called 1a. I set a variable on frame one

jojo = "1a";

then on the button

on (release) {
_root.gotoAndPlay(jojo);
}

and it works, it goes to frame ten.

It's getting frustrating. I'm going to try some more ways and let you know what comes up. Can you make a numerical comparison in an if/else statement in flash from a numeric variable read from a text document say

&checkmate=1&variable2=somethingelse

is (1) read as an integer or a string?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

usually, as a string :D
so better cast it to number
var1 = Number(checkmate);

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.