View Full Version: remote control

lassie >>Seeking Talent >>remote control


<< Prev | Next >>

NigeC- 10-02-2008
remote control
Could anyone help with a remote controller for a TV in Flash? it would have 10 buttons (0 to 9) on a remote and a text field on the TV to show which channel you've inputed on the 3rd digit it would either go to a right channel or just rest I've look around google and i can't find an AS2 one, i have done one but its based on a AS1 template and it wont migrate to a AS2 document without someone way cleverer than me :oops: a working example is here the right channel is 123 lol, this one needs you to press enter i would rather it changed on the 3rd digit which sends it to frame 2: http://nigecstudios.co.uk/games/sore/promo/tv.html if your feeling brave the FLA is here: http://nigecstudios.co.uk/games/sore/promo/tv.rar

fatbuoy1- 10-02-2008

Id give it a go but I never used AS1 and only touched slightly on AS2 before moving on2 AS3 (thanks to Greg). However, the way I'd do it (and Greg might know a better way) is create an empty array, with your textfield displaying whats in the array. Clicking a button adds that button's value to the array and updates the textfield. Have a check to see if the array has 3 values and if it does, check to see if they'r the right ones. If not, clear the array and start again, and if so go to the right channel.

bigmac- 10-03-2008

Three cheers for Chris! Yep, good plan. In rough AS2 code, it would look like this: var _inputs:Array = new Array(); function _addInputValue(val:Number):Void { // reset array if there are currently three digits. if (_inputs.length == 3) { _inputs = new Array(); } // add new value to the array. _inputs.push(val); // update text display with the joined contents of the array. textDisplay.text = _inputs.join(""); // -*test*-('") if array has three digits and has amassed the correct sequence key. if (_inputs.length == 3 && _inputs.join("") == "XXX") { // if so, trigger your success action here! } } onClickAnyButton():Void { _addInputValue(buttonNumber); } I think arrays were first supported in FlashPlayer 5, so you should be able to do all of this in AS1. You'll just have to strip out my data typing and change the operators to be AS1 compliant... as I recall AS1 used verbiage operators like "and" rather than the ECMA standard "&&".

NigeC- 10-03-2008

Thanks Greg, i've give it a try.. I don't want AS1, I have a whole room based AS2 and at the moment this remote control scene is a separate entity which is is messing up returning to the the main scene, so i want to add the remote into the main scene TBH Lassie is starting to croak, arghhhhh! i think i have 20+ sprites in one scene and now they are doing crazy sh*t, i have a door sprite that has two phases and for some reason the second phase grows and moves, the only thing i can do is edit the _data.as to relocate the thing.. So i'm just going to go for a finished item and not bother with a lot of the original plan thanks guys :D

NigeC- 10-03-2008

onClickAnyButton(): its coming up with a syntax error on that line, my heads battered juggling sprites so i'm probably missing something obvious

bigmac- 10-03-2008

hehe... yes: "onClickAnyButton" is a pseudo code dummy method that I wrote in as an example. It's not a real ActionScript method. You'd need to put a click action on each button in your remote so that each one can call "_addInputValue(#BUTTON NUMBER#);" with their respective button's number. Sorry, I probably should have better noted that I was writing simplified pseudo code.

NigeC- 10-04-2008

Thanks Greg! I just got it working :D Its quite easy ONCE you know how.. :roll:

bigmac- 10-06-2008

Good, congrats!

Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.