HTML5 Canvas, Button instead of Keyboard - html

Found some nice Open Source code of a snake game, but wanting to make an iphone web version. So I can't use a physical keyboard, is it possible to use a button instead of it?
Have this code:
case 37:
if (direction != "right"){
moveLeft();
}
break;
Got some more questions but this one is the one 's keeping me where I am in the dev.
Sorry for my bad English, I am a dutch guy.
thanks

You don't need Canvas for this, just create a regular HTML button and put that code in its onclick event.

Related

Action script 3.0 onSwipe{ gotoAndPlay(x); {

Action script 3.0
swipe left/down/right/up gotoAndStop/play (x)?? Someone got a skeleton code of this? I know how to make it in Air for ios/android, but not on regular 3.0. Thanks.
Since you're asking in general - you're not showing specific code:
Use MouseEvents in place of TouchEvents - mousedown in place of a touchBegin for example. mouseX for the position, mouseMove event for swipe code, etc.
Unless you're handling gestures, it should be pretty easy to swap.

User interface flash AS 3.0

since the Site seems to be pretty buggy i have to post my question below. Sorry for the inconvenience.
Hi guys
I'm new to flash and i want to create a GUI for my little game.
How can i create a start window where I can select stuff like how many objects to spawn or move speed of my character.
My first idea was to hide everything else on the stage until I click start.
Would that be right. Is the a better way. how to do this anyway.
And where do i put my GUI script. Stage or extern class.
Place your start button in the first frame and put your other elements in second frame. On click of the start button gotoAndPlay to next frame.

ActionScript 3 scrolling issues

I'm trying to make a google maps style interface for a design project. I've got the drag/drop and zoom functions working, but I also want to make it react to gestures on a trackpad (macbook). I assumed 'listening' to the event.delta of a MouseEvent would do the trick, but somehow it's not working. So what's wrong with my code?
stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelEvent);
function onMouseWheelEvent(event:MouseEvent):void {
tafelOrigineel_mc.y += event.delta;
}
I have loaded the flash MouseEvents earlier in the document, so that shouldn't be the problem. After I got this working, I will try to use it on the x-axis too. Is that possible with the MOUSE_WHEEL eventlistener?
Thx in advance
It is a long time problem regarding flash player on MacOS.
MOUSE_WHEEL event won't dispatch on MacOS. Though there are some workarounds involving the use of JavaScript to detect the use of the wheel (over the entire flash content), if it isn't a issue, try checking one of those.
There is a list in this blog post:
http://www.impossibilities.com/v4/2009/03/06/flash-mousewheel-implementations-for-mac-os-x/

deep linking from xml to open function in Actionscript

I have general text in CDATA in my xml which is pulling in content into Flash. This is working well and I am able to add images this way too. What I need though is to wrap that image in an tag which, when clicked on will fire off a function in my Actionscript 2 to launch a video.
Could someone please tell me how I would go about this? Is there a better way than the way I am thinking right now?
Thanks.
I recently did this in AS3 but I found the AS2 way.
Tested it:
function myFunc(arg:String):Void
{
trace ("You clicked me!Argument was "+arg);
}
myTextField.htmlText ='Click Me!';
You just use a href that is set to asfunction with a function name and something to pass along.
See:
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary073.html
Just to give credit I found the initial code at: blog.activepoison.com/?p=25.

Flash & external form fields

Does anybody know if this is possible?
I am trying to create a flash movie that will show / preview what I am typing into a field in a normal HTML form. The call to update the flash movie would most likely be attached to an onKeyUp event.
Any advice or tutorials would be great
cheers!
Decbrad
Assuming you're using actionscript 3....
Check this out
You can also check this link out (its for Flex 3 though... AS3 should be similar for flash I believe)... I've used ExternalInterface in my Flex projects before.
As far as I'm aware, Flashplayer only listens to key events when it has focus (which it wouldn't have if you're typing into an HTML form. I'm not aware of any way to inject events into Flash with javascript.
Is there a particular reason why you can't use a text area in the actual flash movie itself?
My advise would be to grab your favorite event utility for JavaScript and then pair it with ExternalInterface. That way, you can add a callback to the EI in Flash which would mean that you could do something like this:
ExternalInterface.addCallback( "keyboardClicked", dispatcherFunc );
function dispatcherFunc():void
{
dispatchEvent( new Event( "javaScriptKeyClick" ) );
}
document.getElementById( "mySwf" ).keyboadClicked();
Hey guys, thanks for pointing me in the right direction! I haven't touched flash since version 4 so to say that i'm rusty... is an understatement!
The reason I haven't built the text area in the actual flash movie is because the system is 95% complete now and there's a lot of smarts on the server side. The flash preview is more or less the icing, as they say! Bit surprised there's not more of a hook into Flash.
Thanks again!
Dec