Symbol Off On Problems


(Steve) #1

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!


(Steve) #2

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)


(Steve) #3

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)


(Greg) #4

That is a great effect, thanks for sharing it.


#5

Very cool! :thumbsup:


(Lucky) #6

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


(Greg) #7

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


(Steve) #8

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!


(Lucky) #9

Hahah no worries!
Class names are great :smile:


(Steve) #10

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)