problem with setting some attributes by scripts in ScriptingRT

When we write ScriptingRT experiments with between participant manipulations, we want to put as much as possible in scripts, so that we don’t have to create separate versions.

This works well with some attributes. For instance, you can change the contents of a text of a <Text/> at runtime:

After defining the item,

<Item id="p1" type="-"> 
    <mx:Text id="p1upt" verticalCenter="+150" horizontalCenter="0" text="?"/> 
  private function initVars():void {
    p1upt.text = "kite";

This also works for attributes like instruction of an <Instruction/>

However, it does not work when I try to change the attributes positive and negative of a <Testpart/>. I am not sure why this doesn’t work, presumably because this is used to build the item data structure before the item is evaluated at runtime.


4 thoughts on “problem with setting some attributes by scripts in ScriptingRT

  1. This is a very nice and valuable tut.
    I am working with pictures, and tried this in a similar way. Specifically, when I want to randomly select 1 of 48 images for a trial, the names of the images have an identifier – for example, 1.png is the first and 2.png is the second image. Manipulating the “source” of an mx:Image was not successfull, however – maybe the underlying reason (compilation at runtime?) is the same?


    private function initVars():void {
    catchfirst.source = “@Embed(‘…id”+Math.floor(Math.random()*6)+”.png’)”;

  2. yes, that is a similar problem – but here it is more clear that it cannot work, because the embedding is done at compilation time. did you already try to do this with pictures that are not embedded but “live” (with an url?)?

  3. thanks for your mail! it works very smooth in script – storing all images in an array, scrambling them with some random sort algorithm and assigning the source of the corresponding image id. i also assigned the picture name to the item id, in case one picture behaves strangely it can be kicked out in analysis or so – better have it before than scream for it afterwards! or is there a better way of exporting parameters to the output file?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s