Progress Tracker

Hi All,

Back on this again, but making some headway finally

So this is what I'd like to do The progress tracker will be Flash in a custom tab When clicked, the tab drops down and displays all tracked topic in the course The topics displayed will be all non-hidden Table of Content entries When you click on any of the topics, it should navigate to the corresponding slide

Here's the code I'm using right now:

"
function TriggerAction()
{
 _parent artModuleAPI("deactivate");
}

function debug_alert(strText)
{
 getURL("javascript:alert(\"" + strText + "\")");
}

var ArtAPI = _level0 ArtAPI;

// get pres info
var P = ArtAPI GetPresentationData();
var slide_count = P Slides[0] Slide length;

// build array of non-hidden slides
var mySlides = new Array();
for (var i=0;i<slide_count;i++) {
 if (P Slides[0] Slide[i] Hidden[0] _value=="false") {
  mySlides[mySlides length] = P Slides[0] Slide[i];
 }
}

var my_slide_count = mySlides length;

// currently limited to 10 slides
if (my_slide_count > 10) my_slide_count = 10;

// build array of buttons
var myButtons = new Array(mcButton1,
        mcButton2,
        mcButton3,
        mcButton4,
        mcButton5,
        mcButton6,
        mcButton7,
        mcButton8,
        mcButton9,
        mcButton10
        );

// hide buttons
for (var i=0;i<myButtons length;i++) {
 myButtons[i] _visible = false;
}

// assign labels and actions to buttons and unhide
for (var i=0;i<my_slide_count;i++) {
 myButtons[i] tfTitle text = mySlides[i] Title[0] _value;
 myButtons[i] _visible = true;
 myButtons[i] onPress = function() {
  // determine index
  for (var i=0;i<myButtons length;i++) {
   if (myButtons[i]==this) break;
  }
// read id from mySlide and use to play correct slide number
var str_slide_num = mySlides[i] _attributes id;
var slide_num = parseInt(str_slide_num);
ArtAPI PlaySlideNum(slide_num);
}

stop();"

So the buttons are displaying correctly, with the names being pulled from the non-hidden slides in the myButtons array The problem seems to be getting these buttons to navigate correctly myButtons array is reading the titles from the mySlides array properly to assign the display names But when each is clicked, it plays the slide as numbered from the ArtAPI index instead of the mySlides index
 
For example, my button 1 should play slide 3 in my presentation, which is the first slide in the mySlides Array - slides 1 and 2 are hidden It's pulling the name for the button from mySlides correctly, but instead of playing slide 3, it plays slide 1 even though it's hidden Likewise, button 2 plays slide 2 instead of the next non-hidden slide, but it does pull the name correctly from the next non-hidden slide

So I think I'm getting this behavior because the "ArtAPI PlaySlideNumber(i) is an absolute reference to the master presentation xml and it's no longer accessing the mySlides array here So to fix that, we are trying to use the Slide id to target the correct slide number So we updated the code under "// read id from mySlide and use to play correct slide number" What we want is to assign the same OnPress function to every button Then when it's pressed, it compares itself to each button in the button array that was defined earlier As long as the button array has the buttons listed in order, this should effectively tell what button was pressed

But now while the buttons have the right names, and the mouse changes when rolled over indicating a link, they don't link anywhere when clicked EXCEPT when I am on the main menu slide (slide 8 or mySlides slide 2) Only there, I can click to the right of the buttons in the graphic and link to slide 47 (myslides slide 8) From all other slides, I can't even roll over the space this link appears

Very wierd Any advice on how to p[roceed would be greatly appreciated

4 Replies
Brian Houle

Hi, A @work:

From a quick overview of your code, the following line jumps out at me:

var slide_count = P Slides[0] Slide length;

I would use instead:

var slide_count = _level0 ArtAPI GetSlideCount();

I think you may be seeing unpredictable behavior because ArtAPI GetPresentationData() returns an associative array, which is an Object and not an Array, therefore the length method won't work  

Brian

Brian Houle

I had a more thorough look at your code  These changes seem to work:

function TriggerAction() 

{

 _parent artModuleAPI("deactivate");

}

function debug_alert(strText)

{

 getURL("javascript:alert(\"" + strText + "\")");

}

var ArtAPI = _level0 ArtAPI;

// get pres info

var P = ArtAPI GetPresentationData();

var slide_count = _level0 ArtAPI GetSlideCount();

// build array of non-hidden slides

var mySlides = new Array();

for (var i=0;i

 if (P Slides[0] Slide[i] Hidden[0] _value=="false") {

//------------------------------------

//BIG CHANGE IS IN THE NEXT LINE  -- LOAD THE ARRAY WITH AN OBJECT LITERAL

//Capture the slide number we'll want to reference on the onPress event

  mySlides push( {slidenum:i+1, slideref:P Slides[0] Slide[i]} );

//------------------------------------

 }

}

var my_slide_count = mySlides length;

// currently limited to 10 slides

if (my_slide_count > 10){

my_slide_count = 10;

}

// build array of buttons

var myButtons = new Array(mcButton1,

        mcButton2,

        mcButton3,

        mcButton4,

        mcButton5,

        mcButton6,

        mcButton7,

        mcButton8,

        mcButton9,

        mcButton10

        );

// hide buttons

for (var i=0;i

 myButtons[i] _visible = false;

}

// assign labels and actions to buttons and unhide

for (var i=0;i

//------------------------------------

//reference anything contained in the slideref prop

myButtons[i] tfTitle text = mySlides[i] slideref Title[0] _value;

//------------------------------------

  myButtons[i] _visible = true;

  myButtons[i] onPress = function() {

  // determine index

  for (var i=0;i

    if (myButtons[i]==this) {

break;

}

  }

//------------------------------------

// reference the actual slide number we saved in the array of objects

ArtAPI PlaySlideNum(mySlides[i] slidenum);

//------------------------------------

}

}

stop();

A @work

Hi Brian,

Awesome! Thanks for the help I still had a few issues, but I figured it out Very excited Nice to have some real progress on this for the first time! Here's the code I ended up with:


function TriggerAction()
{
 _parent artModuleAPI("deactivate");
}

function debug_alert(strText)
{
 getURL("javascript:alert(\"" + strText + "\")");
}

var ArtAPI = _level0 ArtAPI;

// get pres info
var P = ArtAPI GetPresentationData();
var slide_count = _level0 ArtAPI GetSlideCount();

// build array of non-hidden slides
var mySlides = new Array();
for (var i=0;i<slide_count;i++) {
 if (P Slides[0] Slide[i] Hidden[0] _value=="false") {
 mySlides push( {slidenum:i+1, slideref:P Slides[0] Slide[i]} );
 }
}

var my_slide_count = mySlides length;

// currently limited to 10 slides
if (my_slide_count > 10) my_slide_count = 10;

// build array of buttons
var myButtons = new Array(mcButton1,
        mcButton2,
        mcButton3,
        mcButton4,
        mcButton5,
        mcButton6,
        mcButton7,
        mcButton8,
        mcButton9,
        mcButton10
        );

// hide buttons
for (var i=0;i<myButtons length;i++) {
 myButtons[i] _visible = false;
}

// assign labels and actions to buttons and unhide
//------------------------------------CHANGES HERE---------------------------------------
for (var i=0;i<my_slide_count;i++) {
 myButtons[i] tfTitle text = mySlides[i] slideref Title[0] _value;
 myButtons[i] _visible = true;
 myButtons[i] onPress = function() {
  // determine index
  for (var i=0;i<myButtons length;i++) {
   if (myButtons[i]==this) break;
  }
//------------------------------------
  }
  // reference the actual slide number we saved in the array of objects
  ArtAPI PlaySlideNum(mySlides[i] slidenum);

 }
 
}

stop();

Alright, so now that the interface is finally working properly, time to actually figure out the progress tracking I'm going to try using the tracking info in the attributes id of the player I'm sure I'll be back with more questions later this week

Thanks again for all the help