ryan February 2016

creating new property - JS / Edge Animate

I am trying to create a property of an object that I can access from another function. I've been trying to figure out dot / bracket notation but I'm not getting it. Would one of you please help me figure how to make the objects state readable from another function.

function twoPhaseSwitch(object,state)
{
    var obj = $(object);
    stage.getSymbol(obj).stop(state);

    obj.click(function(e)
    {
        if(obj.state == 'off')
        {
            stage.getSymbol(obj).stop('on');
            obj.state = 'on';
        }else{
            stage.getSymbol(obj).stop('off');
            obj.state = 'off';
        };
    });
};

function conditionsArray(obj)
{
    for (var i=obj.length;i--;)
    {
        alert(obj[i].state);
    };
};

Answers


ryan February 2016

I'm not sure if this is the correct answer but it works. I ended up using jQuery's .data() call.

//in switch function
obj.data('state',state);

//in conditionArray
alert($(obj[i]).data('state'));


Zarah khan February 2016

Adobe Animate is the best adobe application i have enjoyed a lot.

Post Status

Asked in February 2016
Viewed 3,379 times
Voted 8
Answered 2 times

Search




Leave an answer