[Xerte] What is the correct way to set the properties of script duplicated text Icons?

Johnathan Kemp johnathan.kemp at cxstaffs.co.uk
Mon Oct 5 09:23:29 BST 2009


Hello Xerte Team,

I am trying to develop a Xerte project that will display the keyboard of
a button accordion, with the user able to select from a range of
keyboard sizes.

I have tried two different approaches to achieving this, both on the
same basic idea of having a page with a text Icon that is then
duplicated as many times as there are keys on the keyboard, by script at
run time. 

Which ever method I use I have not been able to correctly change the
newly generated textIcon properties.
I am sure it must be something simple I am missing.

I need to be able to change the x and y properties to position the key,
To change its text to display the Note of the key, 
to change its colour and its alpha property and to draw a circular
border around it.

I think once I can get the correct expression to change one property I
will be able to resolve everything else, because then the correct syntax
for accessing the icon, to get at its properties and methods will have
been identified.

Can you give me an example of how I should be setting the properties, so
that I can stop banging my head against the wall ? :-)

Method 1. By using duplicateIcon
Page
	textIcon (id = protoKey)
	script


I use the following in the script
=============================================================
allKeys = new Array();
allKeys[0]= protoKey.duplicateIcon(0);
allKeys[1]= protoKey.duplicateIcon(0);
// this is a test my intention will be to use a loop to create the
elements of the array 
// that will repeat once for each key on the keyboard 
// new icons are created but I cannot set the properties.

allKeys[0].clip()._y=100; 
// this is shifting the whole project display, leaving a blank area 100
deep at the top of the project 
============================================================

Method 2. By using duplicate
Page
	script
	textIcon (no ID)

I then use in the script
===============================================
// create the number of text icons - each text icon will eventually be a
key on the keyboard display
if (icon.attributes.built != "true"){

  icon.nextSibling.duplicate(5);
  icon.attributes.built = "true"; 
// the figure 5 is for testing to prove the concept, eventually it will
be set by the user in an earlier
// interaction when they select the keyboard size

// create an array of the text icons
allKeys = new Array();
allKeys = icon.parentNode.findChildNodes("type","text");

// I then want to be able to set properties for allKeys[0], allKeys[1]
etc.
================================================


Kind regards

Johnathan


Johnathan Kemp
ICT Development Coordinator
Connexions Staffordshire
www.cxstaffs.co.uk
01785 355714

This email and any files transmitted with it are confidential and are intended solely for the use of the individual(s) or entity(s) to whom they are addressed. All messages are monitored for virus, high risk files and inappropriate content. As a result users should be aware that this mail maybe accessed, read and the right is reserved to reject, return, remove attachments or delete if considered to be inappropriate or unsuitable. Liability cannot be accepted for any loss or damage arising from this email (or any attachments) or from scripts or any virus transmitted.

This communication represents the originator's personal views and opinions, which do not necessarily reflect those of Connexions Staffordshire. If you are not the original recipient or the person responsible for delivering the email to the intended recipient, be advised that you have received this email in error, and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. If you received this email in error, please immediately reply to the sender or notify postmaster at cxstaffs.co.uk


Connexions Staffordshire Limited is registered in England No.4355170
Registered office: Foregate House, 70 Foregate Street, Stafford, Staffordshire, ST16 2PX



More information about the Xerte mailing list