Underneath

Richmond richmondmathewson at gmail.com
Sat Aug 27 14:55:49 EDT 2016


The problem, and it is a problem, is that I have a set of alphabet tiles 
called names such as

"A.png", "B.png" and "C.png" [trying to be original here]

and they all contain this script:

on mouseDown
    put the short name of me into IMENA
    delete the last char of IMENA
    delete the last char of IMENA
    delete the last char of IMENA
    delete the last char of IMENA
    clone me
    set the name of the last image to IMENA
    set the script of img IMENA to fld "fscrip"
end mouseDown

So field "fscrip" has to contain a UNIVERSAL script that will work with 
every new tile without
any reference to the name of a target over which it is dragged:

I have been trying by having this in fld "fscrip":

on mouseDown
grab me
end mouseDown

on mouseUp
    put the short name of me into IMENA
    if within(img ("%" & IMENA), the mouseLoc) OR within(img ("^" & 
IMENA), the mouseLoc) OR within(img ("#" & IMENA), the mouseLoc) then
          --nix
          else
             move me to 1000,700
          end if
end mouseUp

The main problem being that that script throws a "bluey" if there are 
not 3 targets called,
for example "%A", "^A" and "#A"

Ultimately this is far from satisfactory as there could be anywhere 
between 0 (zero) and about 12 targets.

As the specific targets are unknown for each letter they cannot be 
specified.

Richmond.



On 27.08.2016 17:43, Randy Hengst wrote:
> Well, assuming you are following the same sort of naming procedure for all tiles and grid names… then what about
>
> on mouseDown
> grab me
> end mouseDown
>
> local tShortNameOfTarget
>
> on mouseUp
>     put the short name of target into tShortNameOfTarget
>     
>     repeat with x = 1 to the number of controls
>        if the loc of target is within the rect of control x then
>           if (tShortNameOfTarget is in the short name of control x) AND (the ID of the target is not the ID of control x) then
>              set the loc of target to the loc of control x
>              exit repeat
>           else
>              move me to 350,350
>           end if
>        end if
>     end repeat
> end mouseUp
>
>
>
>> On Aug 27, 2016, at 9:38 AM, Richmond <richmondmathewson at gmail.com> wrote:
>>
>> Well, let's contextualise that:
>>
>> It works in my example stack #3: http://forums.livecode.com/viewtopic.php?f=7&t=27837&p=145849#p145849
>>
>> but NOT in my stack with multiple targets.
>>
>> Richmond.
>>
>> On 27.08.2016 17:29, Richmond wrote:
>>> That works!
>>>
>>> Thank you.
>>>
>>> R.
>>>
>>> On 27.08.2016 16:24, Randy Hengst wrote:
>>>> Try this in the image “P” script
>>>>
>>>> on mouseUp
>>>>     repeat with x = 1 to the number of controls
>>>>        if the loc of target is within the rect of control x then
>>>>           if ("P" is in the short name of control x) AND (the ID of the target is not the ID of control x) then
>>>>              set the loc of target to the loc of control x
>>>>              exit repeat
>>>>           else
>>>>              move me to 350,350
>>>>           end if
>>>>        end if
>>>>     end repeat
>>>> end mouseUp
>>>>
>>>>
>>>>> On Aug 27, 2016, at 3:22 AM, Richmond <richmondmathewson at gmail.com> wrote:
>>>>>
>>>>> I'm obviously getting something rather wrong, so I have uploaded something here as explaining things without a sample stack and a pretty picture is well-nigh impossible:
>>>>>
>>>>> http://forums.livecode.com/viewtopic.php?f=7&t=27837
>>>>>
>>>>> Richmond.
>>>>>
>>>>> On 27.08.2016 00:59, Jeanne A. E. DeVoto wrote:
>>>>>> At 12:27 AM +0300 8/27/2016, Richmond wrote:
>>>>>>> This doesn't seem to work because this cycles through ALL the controls, and, of course,
>>>>>>> the object being dragged is also a control.
>>>>>> Ah. Forgot about that. You'll need to add a condition:
>>>>>>
>>>>>>     if within(control x, the mouseLoc) \
>>>>>>        AND ("P" is not in the short name of control x)
>>>>>>        AND (the ID of the target is not the ID of control x) then
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> use-livecode mailing list
>>>>>> use-livecode at lists.runrev.com
>>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> use-livecode at lists.runrev.com
>>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list