Symbol Off On Problems

onOffSwitch.hype.zip (14.4 KB)Trying to control symbols, and they can drive me nuts… but i’m sure its just me… I have attached a simple on and off method. I’m truly trying to seek the gotoAndStop on a time line from flash. So I have put this together. Any help would be great!

I have helped myself, as I have figured it out… .hopefully this will help someone else with the same problem.

Resolved with this file
onOffSwitch.hype.zip (14.3 KB)

1 Like

And one more to help any one else like me who would like to set up a marquee. This is only a couple hours, after I discovered how to turn a symbol off and on. Enjoy!
If you have any ways of simplifying the code I would be interested.
marquee64.hype.zip (23.7 KB)

That is a great effect, thanks for sharing it.

1 Like

Very cool! :thumbsup:

3 Likes

Hey dude,
Just saw your code and it was gigantic i thought there has to be an easier way than that
What if you just use the class names. This way you dont need to keep renaming your symbol and just use the same class. It also doesn’t have a set limit, it’s set to the amount of bulbs on the stage so if you add more it will still work.

var bulbs = document.getElementsByClassName("lb");
function blinkOnce(z,OnOff){
	if(typeof bulbs[(z)]!=='undefined'){
		if(OnOff==true){
			hypeDocument.getSymbolInstanceById(bulbs[z].id).goToTimeInTimelineNamed(1, 'lever');
		}
		else{
			hypeDocument.getSymbolInstanceById(bulbs[z].id).goToTimeInTimelineNamed(0, 'lever');
		}
	}
}
var blinker = window.setInterval(blink, 200);
var gap=4;
var blinkCount=0;
function blink() {
	blinkCount++
	if(blinkCount==gap){ blinkCount=0; }
	for(i=0;i<bulbs.length/gap;i++){
		//console.log(i*gap);
 		blinkOnce(i*gap+blinkCount,true);
 		blinkOnce(i*gap+blinkCount-1,false);
	}
	
}

This does the same thing, you can set the gap of the animation and its a lot lighter. Just wanted to share this way of working since it’s solved me a lot of work in coding!
marquee64-lucky.zip (20.6 KB)
Thanks

3 Likes

We are very lucky to have Lucky around here! Thanks to all

Lucky, wow, that is awesome. I knew it could be simplified, but way beyond my imagination. Thanks you, after playing with this i’m sure you are helping me become the code monster… :slight_smile: Just in time for halloween!

1 Like

Hahah no worries!
Class names are great :smile:

1 Like

Ok one more time. Couldn’t figure out why the marquee was split in half and going to different ways… so my venture to learn how lucky did what he did. Can’t thank you enough. So when I built the stage for the marquee i was coping pasting selecting all copy and pasting the symbols. And started at 1 instead of 0 for my labeling system. However VS. if adding only one symbol on at a time, then i think lucky’s code would have worked perfectly.

So I looked at the code tweeted and kicked a bit, and ended up with the final! Sharing is fun and educational.

marquee64-luckyde-krazay.hype.zip (25.2 KB)

1 Like