(actionscript 3) How can I create virtual keys that simulate specific keyboard inputs - actionscript-3

i'm new to AS3 (and to Stack as well), so I actually wanted to get an old swf game into apk, I did not have the source so I just embedded it into a AS3 fla file.
Luckly the game works fine, but I have no buttons.
I don't have any contact with the game source code so I just want to simulate several keys (A,Z,Q,W,S,C,V...)
TLDR : How can I make virtual buttons (aka gamepad) for an embedded flash game in an APK?
Any help will be appreciated.

Related

Controlling Sound / Volume

I added a sound to the Flash Professional CC library and had the program convert it to MP3. If I create a layer and drag-and-drop the sound onto the stage the sound plays fine (even after passing it through Swiffy), however that is all I am able to do so far.
I need some way to control when the sound plays as well as volume. I tried the giving the sound a class (Sound Properties -> ActionScript -> Export for ActionScript and assigned a class name mySound).
Then added this ActionScript to the first frame:
var myAudio:Sound = new mySound();
myAudio.play();
However, after passing it through Swiffy, I get the following errors:
The ActionScript class flash.media.Sound is not supported.
The ActionScript method flash.media.Sound.play() is not supported.
So I can't use the base Sound class in Flash? Is there another base class that can be used and is it compatible with the flash.media.Sound class? Is there some other way to control playback so that it can be played at a specific time -- such as on mouse roll-over or when something is clicked?
You could try using SoundJS. BTW, Flash Pro CC does have an HTML Canvas document type that uses CreateJS (which SoundJS is part of) under the hood. It won't convert AS3 to JS, though, you have to write the JS code yourself.

Creating Preloader for SWF in AS3 Flash Builder

I'm a relatively new developer in AS3 using Flash Builder. My objective is to create a quick/fast loading small SWF preloader for a larger (30mg) SWF application. I can't include the larger SWF inside the preloader, but I can use external interface calls to get jquery to tell me what the speed of internet the users are using and figure out how long it should take to load based on the size of the larger SWF.
Right now, we have a large web application that takes around 5 mins to load if the client has a slow internet connection. So, we wanted to use a small SWF preloader that will display a loading circle or loading bar, and display options if the SWF takes longer than 5 mins to load. Kind of like error handling. For instance, for Safari, sometimes the player actually has to click the SWF in order for it to load. Is it possible to have a button on the SWF that will make it start loading?... Is it easier to create the preloader in jQuery? I'm just wondering if it's just going to create more issues using a SWF to load a SWF. Any ideas?...
Any ideas on how to tackle this beast? I've read almost every article about preloaders but there is nothing that references preloaders created in Flash Builder.
I can't use Flash Professional or timeline. It has to be in Flash Builder.
So I tried to use the below tutorial and I wasn't able to actually get anything to appear when I test it. I'm getting an error at the "run()" function:
Error: Error #2136: The SWF file http://local.myproj.com/MyProject.swf contains invalid data.
at Preloader/run()[/Development/MyProject/src/Preloader.as:109]
at Preloader/onEnterFrame()[/Development/MyProject/src/Preloader.as:46]
References:
http://fortheloss.org/how-to-preloader-in-flash-builder-4-7/
I worked until two years ago with a lot of these things and I know I have a few good scripts in my databases, but you are talking about Preloaded & activated loading were as in a preloader it is out of the hands of say a visitor what he or she can or cannot do, and in using a button (possible of course) the visitor has a choice to download or not! From memory there was never really a lot published yet over years of using Flex Builder I have collected some good AS3 scripts and modified them (including a progress-bar - but without time Indicator) to download in web Apps. or FLEX AIR etc. with AS3.
The small problem would only be to adapt any of it from mx to fx depending on what FLEX Builder you use!
I used my scripts mainly to download high resolution Images, Calendars, SWFs etc. with up to compressed 22 mB! Anyway, if Interested I have to look up my FLEX databases & Application to get it to you! rgs Aktell

Problems implementing a Timline Editor in my level editor in Adobe AIR.

I'm currently working on an Adobe AIR project to pump out my level editor but I'm running into an issue. I basically need to implement an interactive movie editor. My question is how would you recommend I get the timeline editing started? Functionality wise it needs to be able to set tween key frames for position, scale, and alpha. Any ideas?
I've also been trying to look into pulling tween data from a swf. I'm not entirely sure how applicable this would be.
I'm not sure what you mean by movie editor - movie as in a sequence of images(bitmaps) or movie as in flash MovieClip ?
If it's the later, you could use a tweening engine like TweenLite to do the hard lifting and then it's up to you how you organize the scrollable GUI for the timeline (plenty of examples out there, starting with Flash/After Effectts/Blender/etc.) Feedback from your designer/animator is crucial I presume.
Pulling data from Flash could also be possible. If you'd like to parse the swf you can try Claus Wahlers' awesome as3swf library. Be sure to check some of his posts:
SWF Timeline Reconstruction with as3swf
Flash IDE Inspired Flex 4 Timeline Component
Another option would be to use jsfl (JavaScript scripting in the Flash IDE) and parse the tweens your designer/animator creates. It should be a matter of parsing a XML for the tween(be it old/classic or new/motion). If you go the JSFL route, you might also find the xJSFL project useful.
Also, for inspiration on game/animation tools check out Spriter

ActionScript 3 Best place to bind events

I am writing a small Flash game using air for android and have encountered a slight issue.
The game has 3 screens (excluding the game screen) which are main menu, load game & create new game. On the load game and create new game screens I want to add a button which take the user back to the main menu.
I know how to add event listeners to buttons but I am wondering where do I bind the event listener for back to main menu, binding in the constructor of my main class produces an error at run time and binding after going to the frame is knocking out the other buttons when back at the main screen.
At present the app is across multiple frames (probably a better structure to this instead of loading a single frame with each menu), I am new to actionscript so I am not entirely certain on best practices for this sort of thing.
Thanks.
I recommend you to use only one frame in your Fla, then use a Document Class. In that main Class, you should place all your display objects using ActionScript.
I hope you know how to instantiate Class as library clips.

ActionScript not showing up in Actions - Frame window in Flash CS5

In an existing fla file, I'm not able to find strings within actionscript that is contained within certain frames (regardless of which frame it's in). So for example in frame 1 there is the following code:
stop();
But searching for 'stop' (without quotes) doesn't turn up any results.
If I create a new fla file, I'm able to find actionscript in all keyframes. Furthermore, I've noticed that the "Actions - Frame" window shows me a tree of all the ActionScript in the scene, organized by frame. This isn't happening in the first .fla file - I can open up and edit actionscript for a frame, but the tree/index never gets built.
Has anyone run into a situation like this? Is the first .fla corrupt in some way, or is there a setting to allow me to easily find actionscript within all frames? Thanks!
Have you checked the settings in the search box? Maybe the search is document based and the specific file you are having trouble with has different settings from the default one. Try to compare the working file with your "corrupt" file. Actionsctipt should be enabled.