intermittent mainly not working onoff switch builds after but not including 585

[code]
function newOnOffSwitch( x, y, startingValue )
– Staring value can either be “on” or “off”
print(“new on off switch”)

– declare groups
local onOffSwitch = display.newGroup() --> holds entire switch

– START DEFAULT VAUES:

if not x then x = 0;print(“not x”); end
if not y then y = 0;print(“not y”); end

if not startingValue then
onOffSwitch.value = “on”
print(“s v on”)
else
–onOffSwitch.value = “off”
onOffSwitch.value = startingValue
print("starting value ",startingValue)
end

– // END DEFAULT VALUES

– create the actual on/off switch graphic
local onOffSwitchGraphic = display.newImageRect( “coronaui_onoffslider.png”, 156, 36 )

– if onOffSwitch is set to “off”, change it’s position
if onOffSwitch.value == “off” then
onOffSwitchGraphic.x = -54
print(“onoffv switch off”)
end

onOffSwitchGraphic.prevPos = onOffSwitchGraphic.x

onOffSwitch:insert( onOffSwitchGraphic )

– create a bitmap mask and set it on the whole group
local onOffMask = graphics.newMask( “coronaui_onoffslidermask.png” )
onOffSwitch:setMask( onOffMask )

onOffSwitch.maskScaleX, onOffSwitch.maskScaleY = .5, .5

– START TOUCH LISTENER FOR ACTUAL ON/OFF SLIDER:

function onOffSwitchGraphic:touch( event )
print(“event”)
if event.phase == “began” then
print(“touch event”)
display.getCurrentStage():setFocus( self )
self.isFocus = true

self.delta = 0

elseif( self.isFocus ) then
if event.phase == “moved” then
print(“moved”)
–self.x = event.x - event.xStart
self.delta = event.x - self.prevPos
self.prevPos = event.x

self.x = self.x + self.delta

if self.x < -54 then self.x = -54; end
if self.x > 0 then self.x = 0; end

elseif event.phase == “ended” or event.phase == “cancelled” then
display.getCurrentStage():setFocus( nil )
self.isFocus = false
print(“ended”)
if self.tween then transition.cancel( self.tween ); self.tween = nil; end

local assessSwitch = function()
if self.x > -23 then
self.parent.value = “on”
hswitch = “on”
print(“on”)
propertyBag:setProperty(“hswitch”, “on”)
propertyBag:SaveToFile()

else
self.parent.value = “off”
hswitch = “off”
print(“off”)
propertyBag:setProperty(“hswitch”, “off”)
propertyBag:SaveToFile()
end
end

if self.parent.value == “off” then
self.tween = transition.to( self, { time=200, x=0, transition=easing.outQuad, onComplete=assessSwitch } )
else
self.tween = transition.to( self, { time=200, x=-54, transition=easing.outQuad, onComplete=assessSwitch } )
end
end
end
end

onOffSwitchGraphic:addEventListener( “touch”, onOffSwitchGraphic )

– // END TOUCH LISTENER FOR ON/OFF SLIDER

– finally, position entire group:
onOffSwitch.x = x
onOffSwitch.y = y
qgroup2:insert(onOffSwitch)
return onOffSwitch
end
hintlabel = display.newText (“hint text”, centre-32, 5, “Helvetica”, 18 );
print("hswitch ",hswitch)

hswitch = propertyBag:getProperty (“hswitch”)
if hswitch == “on” then
print(“on”)
newOnOffSwitch( centre+28, 50, “on” )
–propertyBag:setProperty (“hswitch”, “on”)
–propertyBag:SaveToFile()
elseif hswitch == “off” then
print(“off”)
newOnOffSwitch( centre+28, 50, “off” )
–propertyBag:setProperty (“hswitch”, “off”)
–propertyBag:SaveToFile()
end
qgroup2:insert(hintlabel)
–end of hint switch
[/code] [import]uid: 2131 topic_id: 13825 reply_id: 313825[/import]

Was this ever fixed? I am experiencing the same problem under build 704 and later. From what I can tell from other threads, it has to do with the mask (verified by commenting the mask assignment out). This code was working fine and has not changed since the app was originally published (almost a year ago). However, I needed to rebuild due to new iPad scaling problem and now it no longer works!

Any help would be appreciated! [import]uid: 50537 topic_id: 13825 reply_id: 101962[/import]

We are aware of some mask related issues and are currently looking into them. (If you have a test project we can run please submit a bug and include it.)

Thanks,
Peach :slight_smile: [import]uid: 52491 topic_id: 13825 reply_id: 102023[/import]

Thanks Peach - I just fixed it by adding isHitTestMasked to the coronaui code that I was using for the onOff switches. However, I would suggest for future builds, if undefined, that property automatically defaults to the false value internally - to avoid any unpleasantries. [import]uid: 50537 topic_id: 13825 reply_id: 102037[/import]