View Full Version : Help with arrays

08-14-2006, 11:27 AM
I'll try to explain my project:
I have done a CD-ROM which includes 4 products with some supporting material in pdf's. There are 4 categories in every product, and they are the same for all products (handouts, lesson plans, question and answers). Every product page is in a keyframe in my timeline. I've set arrays for every category including the name of the pdfís in order.


var LessonPlan:Array = new array("LPACH.EXE","LPALD.EXE","LPABA.EXE","LPDDB.EXE");
var Questions:Array = new array("QACH.EXE","QALD.EXE","QABA.EXE","QDDB.EXE");

From frame 10 to 13 I have 4 products with 4 buttons (always the same buttons). Every button has an action script like:

on (release) {

fscommand("Exec", LessonPlan[0]);


(thatís to get the lesson plan)

on (release) {

fscommand("Exec", Questions[0]);


Here is my question:

Itís easy to introduce the action script manually for 4 products, but the end product will have 40.
The array position to get the right pdf is always the same, doesnít matter if itís for the lesson plans, questions, answers or handouts. I donít think there is a way to copy the action script of my lesson plan (what Iíve set manually, creating 4 keyframes in the timeline for the lesson plan button) to the button of another category. I was thinking to use the timeline position to get the array element, but I cannot figure out how.


From frame 10 to 13 I have 4 products. I want to get in frame 10 the array element 0, so I thought:

var framevalue = timeline.currentFrame-10;
on (release) {

fscommand("Exec", LessonPlan[framevalue]);


that way I would only need one action script for the button, but, itís not working. Is there a way to do it?

Iím sorry about my crappy description of the problem, I hope somebody understands it.

08-14-2006, 11:53 AM
try _currentFrame

08-14-2006, 12:03 PM
The problem seems to be with the syntax in this script:

on (release) {

fscommand("Exec", LessonPlan[_currentFrame]);

It gives me a syntax error.

08-14-2006, 12:44 PM
There is no "on (release)" in AS 3.0.

you have to put you code on a frame and add a listener to your clip to listen to MouseEvent.CLICK.