layer_sequence_destroy

With this function you can destroy (remove from the room) a sequence element and its corresponding sequence instance.

You supply the sequence element ID as returned by layer_sequence_create() or by one of the layer element functions and the sequence will be destroyed.

The function frees the sequence instance struct and all the structs under it. Any structs under the sequence instance struct that have been assigned to a variable are not freed at that point, e.g. if you assigned one of the track structs under activeTracks to a variable then that struct will only be freed when the variable no longer references it.
The function also destroys all instances that were created for the sequence's object tracks. This also applies to instances created from an override object defined with sequence_instance_override_object.
Already existing instances that were provided as a replacement for an object index using sequence_instance_override_object are not destroyed automatically.

Syntax:

layer_sequence_destroy(sequence_element_id)

ArgumentTypeDescription
sequence_element_idSequence Element IDThe unique ID value of the sequence element to target

 

Returns:

N/A

 

Example 1:

var a = layer_get_all_elements(layer);
for (var i = 0; i < array_length(a); i++;)
{
    if layer_get_element_type(a[i]) == layerelementtype_sequence
    {
        layer_sequence_destroy(a[i]);
    }
}

The above code gets the IDs for all the elements assigned to the layer of the instance running the code. The code then checks to see if any of the returned elements are sequence assets and if they are then they are destroyed.

Example 2:

var a = layer_get_all_elements(layer);
var track_struct;
for (var i = 0; i < array_length(a); i++;)
{
    if layer_get_element_type(a[i]) == layerelementtype_sequence
    {
        var ins = layer_sequence_get_instance(a[i]);
        track_struct = ins.activeTracks[0];
        layer_sequence_destroy(a[i]);
    }
}
show_debug_message(track_struct);

The above code gets the IDs for all the elements assigned to the layer of the instance running the code. The code then checks to see if any of the returned elements are sequence assets. If they are, it then gets the instance struct using layer_sequence_get_instance. Next it assigns the first element of the activeTracks array to a temporary variable track_struct and it destroys the sequence afterwards.

After going through all the sequence elements and destroying them it shows a debug message with the contents of the variable track_struct. While the sequences were destroyed, track_struct still contains the struct of the first track of the last encountered sequence instance.