You can change this behavior and control when and which resources should be checked for preloading by using the command CheckPreloaded. [js]CheckPreloaded()[/js] creates a PennController trial which, when executed, will pause the experiment until all the resources are preloaded. You can also be more specific and only target resources used by PennController trials with certain labels:
[js]
CheckPreloaded(
startsWith(“practice”)
,
startsWith(“test”)
,
“exitItem”
)
[/js]
This code will create a PennController trial which, when executed, will pause the experiment until preloading is complete for all the resources used by PennController trials whose labels start with practice, by PennController trials whose labels start with test, and by PennController trials whose labels correspond exactly to exitItem, and only by those.
Use the .label command on the PennController trial to label it so you can control when in the flow of your experiment the resources will be checked for preloading (see full example below).
You can also pass a number as the last argument to specify a delay (in milliseconds) after which, even if not all the resources have been preloaded, the next trial in the experiment flow should start anyway:
[js]
CheckPreloaded(
startsWith(“test”)
,
5000
)[/js]
Complete Example
[js try=”data”]Sequence( “welcome” , “preloadPractice” , startsWith(“practice”) , “preloadTest” , startsWith(“Test”) );
CheckPreloaded( startsWith(“practice”) )
.label( “preloadPractice” );
CheckPreloaded( startsWith(“Test”) )
.label( “preloadTest” );
newTrial( “welcome” ,
newText( “message” , “Welcome. The resources are currently being preloaded. The next trial won’t start before all the resources for the ‘practice’ trial are loaded (i.e. 1fishSquareTank.png).”)
.print()
,
newButton(“start”, “Start”)
.print()
.wait()
);
newTrial( “practice-1” ,
newImage(“tank”, “1fishSquareTank.png”)
.print()
,
newText(“description”, “The tank is round.”)
.print()
,
newKey(“validate”, “FJ”)
.wait()
);
newTrial( “practice-2” ,
newImage(“tank”, “1fishSquareTank.png”)
.print()
,
newText(“description”, “The tank is square.”)
.print()
,
newKey(“validate”, “FJ”)
.wait()
);
newTrial( “Test-1” ,
newImage(“tank”, “2fishRoundTank.png”)
.print()
,
newText(“description”, “The tank is round.”)
.print()
,
newKey(“validate”, “FJ”)
.wait()
);
newTrial( “Test-2” ,
newImage(“tank”, “2fishRoundTank.png”)
.print()
,
newText(“description”, “The tank is square.”)
.print()
,
newKey(“validate”, “FJ”)
.wait()
);
[/js]
Index
- Tutorial
- Commands by element categories
- Standard Element Commands
- Audio element
- Button element
- Canvas element
- DropDown element
- EyeTracker element
- Function element
- Html element
- Image element
- Key element
- MediaRecorder element
- Scale element
- Selector element
- Text element
- TextInput element
- Timer element
- Tooltip element
- Var element
- Video element
- Youtube element
- Special clear command
- Special end command
- Global PennController Commands
- PennController
- PennController.AddHost
- PennController.AddTable
- PennController.CheckPreloaded
- PennController.Debug
- PennController.DownloadVoiceButton
- PennController.FeedItems
- PennController.Footer
- PennController.GetTable
- PennController.GetURLParameter
- PennController.Header
- PennController.InitiateRecorder
- PennController.PreloadZip
- PennController.ResetPrefix
- PennController.SendResults
- PennController.Sequence
- PennController.SetCounter
- PennController.Template
- Installing PennController
- Ontology
- Aesthetics
- Preloading resources
- ZIPped resources
- Spreadsheet (CSV)
- Canvas creation
- Setup for audio recordings collection