[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

trying to use on (press) events that are stored in array

Posted on 2004-11-18
12
Medium Priority
?
266 Views
Last Modified: 2010-04-07
hi
in my movie i have stored my button data in an two arrays
one holds the draw data one holds the (goto)scene data

i can access the elements of the array
i can draw the button as intended
but i cant seem to use the use the (goto)scene array
here is my goto scene array

var aRolloverGOTO:Array = ["Scene 3","Scene 4","Scene 5","Scene 6","Scene 7","Scene 8","Scene 9","Scene 10","Scene 11"];

and here is the code that does draw but doesnt goto scene
its all on the same button

------------------------------------------------------------------------
on (rollOver)
{
      arrCount=0;
      #include "simplebutton.as"
      
}
on (release)
{
 gotoAndStop ("aRolloverGOTO[arrCount]",1);
}
------------------------------------------------------------------------
does anyone have any ideas?

thanks in advance
liseperu

0
Comment
Question by:liseperu
  • 4
  • 4
  • 4
12 Comments
 
LVL 6

Expert Comment

by:hsmtp
ID: 12612923
Hi liseperu,

Try this:

on (rollOver)
{
     this.arrCount=0;
     #include "simplebutton.as"
     
}

on (release)
{
 _root.gotoAndStop (aRolloverGOTO[this.arrCount],1);
}
0
 
LVL 8

Expert Comment

by:sokhodom
ID: 12613308
Well, i can only see the problem. The problem is with the gotoAndStop. This gotoAndStop require the scene name is in between the qoute i.e. gotoAndStop("Scene 4",1). However, if we use a variable name , in this case aRolloverGOTO[arrCount]", it will not work. This is because "aRolloverGOTO[arrCount]" is indeed evaluated as a string name "aRolloverGOTO[arrCount]" and not "scene 1" or "scene 4" or "scene 5" etc. So, gotoAndPlay(aRolloverGOTO[arrCount]",1), won't be able to find that path.

0
 

Author Comment

by:liseperu
ID: 12613344
hi sokho
i started this thread about some other aspect of my movie
it now seems that my other problem -
http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21210384.html#12612857

has ended up with the same problem

in the other thread the example an expert gave - it may have even been you!

included the line
gotoAndPlay("user.data.scene",1);

how come that will work?
liseperu
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Accepted Solution

by:
hsmtp earned 400 total points
ID: 12613766
liseperu,

ok, here is solution.

Just put in every first frame of the scene - frame label, that will correspond to current scene name.
for example in scene 3 the first frame label will be "Scene 3".

Then you'll move to needed scene using just label names:

on (release)
{
 gotoAndStop (aRolloverGOTO[arrCount]);
}
0
 
LVL 8

Expert Comment

by:sokhodom
ID: 12613880
Hey liseperu,
Ya that was me :).. sorry for the mistake caused coz i just look at what you typed and didn't really take a look at the problem. oKay, i've test it out on my pc. You can do it by changing the gotoAndStop to gotoAndPlay like

on (rollOver)
{
     arrCount=0;
     #include "simplebutton.as"
     
}
on (release)
{
 gotoAndPlay("aRolloverGOTO[arrCount]",1);
}
I've posted what i think here also.
http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21210384.html#12612857
0
 

Author Comment

by:liseperu
ID: 12613959
hi
ok

here is the code
on (release)
{
      arrCount=0;
      trace(aRolloverGOTO[arrCount]);
 gotoAndPlay("aRolloverGOTO[arrCount]",1);
}

the trace shows that my aRolloverGOTO[arrCount] = Scene 3 but it still wont goto the next scene

arghh
how fustrating
does it work on your pc
with the same code?

thanks again
liseperu
0
 
LVL 6

Expert Comment

by:hsmtp
ID: 12613992
liseperu,

gotoAndPlay("aRolloverGOTO[arrCount]",1);

It will not work, because there is no scene named "aRolloverGOTO[arrCount]".
Quotes are for strings, not for variables.

The only solution is to use frame labels as I mentioned before.
0
 
LVL 8

Expert Comment

by:sokhodom
ID: 12614046
yep it works in my pc. you can download fla here:
http://www.ntu.edu.sg/home2001/n0069866/test3.fla
The difference is that i didn't pust as actionscript file. But the concept is the same.
Cheers :)
0
 
LVL 6

Expert Comment

by:hsmtp
ID: 12614124
sokhodom,

Yes, it works. But I'm wondering why? :)
0
 

Author Comment

by:liseperu
ID: 12615957
hmmmm

i will take my vars out of a file and see if it works

thanks
0
 
LVL 8

Assisted Solution

by:sokhodom
sokhodom earned 400 total points
ID: 12619877
You can find your solution here:

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_21210384.html

hsmtp, You are absolutely right :) we only can use Frame name (just found out,hahha)
Cheers pal,
SokhodoM
0
 

Author Comment

by:liseperu
ID: 12620126
thank you both of you for all your help
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question