local i=1;
local firstView1 = display.newGroup()
local firstView2 = display.newGroup()
local firstView3 = display.newGroup()
– to set the image with their image id for each group
local function create_Instances(groupView, X, Y)
local img=display.newImage(“custm.png”,X,Y);
img.id=i;
i=i+1;
groupView:insert(img)
end
– touch event where i m dragging the group
function onTouch(event)
local t=event.target;
if event.phase == “began” then
print(“Touch Began Event Fired…”);
local parent =t.parent;
parent:insert(t);
display.getCurrentStage():setFocus( t )
event.target.alpha = 0.5;
t.isFocus=true;
t.x0 = event.x - t.x
t.y0 = event.y - t.y
elseif t.isFocus then
if “moved” == event.phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif event.phase== “ended” or event.phase == “cancelled” then
print(“Touch Ended Event Fired…”);
event.target.alpha = 1;
display.getCurrentStage():setFocus(nil);
t.isFocus = false
end
end
return true;
end
–create_Instances of Views
create_Instances(firstView1,70,200);
create_Instances(firstView2,70,250);
create_Instances(firstView3,100,250);
–Registering touch event to the group object
firstView1:addEventListener(“touch”,onTouch);
firstView2:addEventListener(“touch”,onTouch);
firstView3:addEventListener(“touch”,onTouch);
here the problem is how do access the img.id of firstView1, or firstView2 or firstView3,in touch event… that is how to know that id of current object which is tapped or dragged [import]uid: 42177 topic_id: 8222 reply_id: 308222[/import]
… I know about event.source and event.name but here my problem is to identify the object tat is which group object is currently accessing the touch event or function and how can i access their property… Actually i have to change the image of that particular group… while dragging it to different region on screen… if you any other idea to do so please tell me… thanks [import]uid: 42177 topic_id: 8222 reply_id: 29813[/import]