360tv
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2013
11:38 AM
need help with a tiny piece of code editing an array.
so I have something like...
I've previously been changing the text color by a roByteArray conversion
And that worked fine for one canvas Item. My question is how do I roll thru an array of canvas items and change a value in all the TextAttrs nested Arrays?
canvasItems = [
{
Text:"This is ImageCanvas 1"
TextAttrs:{Color:"#FFFFFFFF", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:390,y:357,w:500,h:60}
},
{
Text:"This is ImageCanvas 2"
TextAttrs:{Color:"#FFFFFFFF", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:390,y:357,w:500,h:60}
},
{
Text:"This is ImageCanvas 3"
TextAttrs:{Color:"#FFFFFFFF", Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:390,y:357,w:500,h:60}
}
]
I've previously been changing the text color by a roByteArray conversion
fadelevel = CreateObject("roByteArray")
fadelevel.fromhexstring(device.nextoverlayfontcolor)
fadelevel[0] = fadelevel[0] - 8 ' or whatever values.
canvasitems = [
Text:"This is ImageCanvas 3"
TextAttrs:{Color:"#" + fadelevel.tohexstring(), Font:"Medium",
HAlign:"HCenter", VAlign:"VCenter",
Direction:"LeftToRight"}
TargetRect:{x:390,y:357,w:500,h:60}
]
canvas.SetLayer(0, {Color:"#FF000000", CompositionMode:"Source"})
canvas.SetLayer(1, canvasItems)
canvas.Show()
And that worked fine for one canvas Item. My question is how do I roll thru an array of canvas items and change a value in all the TextAttrs nested Arrays?
2 REPLIES 2

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2013
12:53 PM
Re: need help with a tiny piece of code editing an array.
If you just want to change the TextAttrs element you don't need to redefine all the other elements. You should be able to do something like this.
for each item in canvasitems
item.TextAttrs.Color = "#" + fadelevel.tohexstring()
end for
360tv
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2013
03:04 PM
Re: need help with a tiny piece of code editing an array.
simple enough!