Get total amount of scenes number


(jangeltun) #1

I know how to get individual scene name/number, but is there a way through javascript to get the total number of scenes?

I currently have this code:
var scenenumber = hypeDocument.currentSceneName();

if {
hypeDocument.getSymbolInstanceById(‘sceneNameSymbol1’).element().children[0].children[0].innerHTML = scenenumber.concat(’/17’); // change total slide number
}


(Mark Hunte) #2

Of the top of my head.

	var currentSceneName = hypeDocument.currentSceneName();
var sceneNameArray = hypeDocument.sceneNames();

var sceneNumber = sceneNameArray.indexOf(currentSceneName) + 1;
 
 hypeDocument.getSymbolInstanceById('sceneNameSymbol1').element().children[0].children[0].innerHTML = sceneNumber + "/" + sceneNameArray.length; // change total slide number

#3

Another way:

var numberofscenes = hypeDocument.sceneNames().length

This requires that each scene name is unique.


(jangeltun) #4

Awesome! Thanks @MarkHunte and @Daniel


(Mark Hunte) #5

Also have a look at


(jangeltun) #6

I’ve made a demo of what I have so far, and have a new dilemma. I have certain scenes that I don’t want included in the total scene number. Basically, I only want the scenes strictly with numbers to be counted. Is there a way to use RegExp?

total scene number.hype.zip (74.7 KB)


(Mark Hunte) #7

Maybe something like

var numberofscenes = hypeDocument.sceneNames(); 

 var sceneNumbers =[];

for (i = 0; i < numberofscenes.length; i++) { 
 var hasLetters = numberofscenes[i].match(/\D/g);
  
  if (!hasLetters){
  sceneNumbers.push(numberofscenes[i]);
  }
 
 
}
console.log(sceneNumbers);

By the way check out the new hypeDocument.sceneInfo Extension


(jangeltun) #8

Thanks @MarkHunte. I added this to get the last number in that array.

var finalSceneNumber = sceneNumbers.slice(-1)[0]

Here is my updated sample:
total scene number 2.hype.zip (81.7 KB)