Can a object do multiple animations but not in the same time

Give me a min…

sure :blush:

??? sir @MarkHunte

That was not a literal minute… :roll_eyes:

Looking at your project and living my life…

:grinning::blush:

but sir can u help me @MarkHunte

Yes…

yai:heart_eyes:

??? sir???

First thing.
You can edit your posts in particular the last ones so we do not get a long stream of all amendments…

Please stop pushing for replies. Remember anyone who helps you here is doing so in their own time…

There are no time limits on when we reply or guarantees that we will indeed reply.

ok.
Lets use the bedroom as an example.

The bedroom ID is ‘bedroom’ in lower case.
The target timeline is ‘BEDROOM’ in upper case.

an id and a timeline name are both case sensitive.

Meaning when you want a timeline named ‘bedroom’ the timeline name must be ‘bedroom’ and not ‘BEDROOM’

So we need to change the timeline name to a lower case version.

We can do that by going to the Scene inspector.
Double click on the timeline name and rename it.

(I know you are thinking it is easier to just change the ID from ‘bedroom’ to ‘BEDROOM’
It is but IDs normally start in lower case so let stick with convention. )


Next.

You removed the timeline controlling the light element so you could target it in Javascript ( not java).

To target it we need to give it an id also.

so we give it the id of ‘bedroomLight’


Note on ids:

IDs are used so we can target specific elements

All elements in hype get an id when ruining in the browser but these are given to them by hype when it loads the project in the browser so we effectively never know what these ids are before hand.

We use the ID field in the inspector to override the auto IDs of an element and give it a known id of our choosing. _
( No two elements must use the same id or that will lead to sleeping with the wrong twin. )


Now all we need to do in the startLight function is add the line

hypeDocument.getElementById(myRoom + 'Light').style.backgroundColor = myColor

We construct the id we are looking for
The color string + the string ‘Light’

Which for purple would come out as

purpleLight

.style.backgroundColor = myColor

is the Javascript way of setting the style attribute background-colour of an element.


2 Likes

thank you so much :hugs:

1 Like

i made it work but . stil confused how to change color name ugh !! this is so confusing. because now it is only working in only one color for all as it coming only white

As I said above your timeline names need to match the ids.

As shown here the timeline bedroom is correct
The others like LIVING ROOM arena CAPS so you need to make them lower case.

Also the id must be the same word.

i.e
The living room has the id of living
And the Time line is name LIVING ROOM

We use the id to find the timeline.

The is no timeline named living
So you you need to change the time line name from LIVING ROOM to living
Now the id and time line name matches.

48
.

You use elements that you use to show the light colour.
The living room one.
49

Give this element an id.

This id should include the room id word and another word that we can use to find this element by its id.

So for these elements we use the room id and the word Light

Therefore the living room’s light element’s id should be:
livingLight

The script I show above will now find the living room light by looking for livingLight

Also change the code line from

document.querySelector('#'+ myRoom + 'Light').style.backgroundColor = myColor

to

hypeDocument.getElementById(myRoom + 'Light').style.backgroundColor = myColor

That was me after a long day just having a brain fart. Hype can use the style css.

INTERFACE_v3.hype 2.zip (940.6 KB)

3 Likes

so i just change the name of the color for it to change color for each room?

cause it was working for all rooms and colors but it was just coming in one color it wasnt changing color as it was coming only in white

only for bedroom its changing color the other rooms its staying white i changed all the id and timeline so it matches

but the colors are not changing for the otehr rooms execept bedroom

It’s id not name. But yes. ( And make sure you do the other changes I mention. )

I am scared to put this but here goes.

Do all of the above. Then look at this bit


One change that may help in the future is that the id of the colour may be purple but you want the colour to be a colour you do not know the name of?.
08

So we can leave the colour id’s as they are ( i.e with the changes above )

But change the code so that it gets the colour elements background colour and applies that to the light.

This way you can use any colour you want without having to figure out what to put in the light’s id

This is a very simple change to the code.

Instead of getting and using the colours id

var myColor = element.id;

we get it’s background colour.

var myColor = element.style.backgroundColor ;

3 Likes

i changed but i am not sure what is wrong cause the color is still not changing for all the other rooms

INTERFACE.hype.zip (1.5 MB)

i changed all the ids and change the java script code and whatever changes you told me to do, but i am not sure what is wrong cause the color is still not changing for all the other rooms