AS3 Flixel Setting control keys as variables - actionscript-3

I would like to store keyboard input as a variable in the class (not the function), that way they're not hardcoded.
if(FlxG.keys.(myKeyVar))
any help is appreciated.

Was overlooking this.
FlxG.keys.pressed(myKeyVar);
ugh

Related

Anyone know a list of flash.includes? (as3)

I'm looking for a list of flash.include.whatever.whatever for as3.
If no one knows a list then can someone tell me the flash.include to use for drawing rectangle with the startFill and endFill things? Thanks for any help.
I didn't find anything on either of these googling, and the place I got the code for drawing a rectangle of course didn't have the flash.includes included in the example code... is their a reason so many people do that? Any way I can get around it?
Do you mean you want a list of the packages and classes that come with AS3? That is typically called the documentation and can be found here:
Adobe ActionScript® 3 API Reference
For drawing a Rectangle, you can start at flash.display.Shape. It has a graphics object with the methods .beginFill() and .endFill().
you can using a Graphics.
The Graphics class contains a set of methods that you can use to
create a vector shape. Display objects that support drawing include
Sprite and Shape objects. Each of these classes includes a graphics
property that is a Graphics object. The following are among those
helper functions provided for ease of use: drawRect(),
drawRoundRect(), drawCircle(), and drawEllipse(). You cannot create a
Graphics object directly from ActionScript code. If you call new
Graphics(), an exception is thrown.
The Graphics class is final; it cannot be subclassed.
here is a sample
import flash.display.*;
this.graphics.beginFill(0xff0000);
this.graphics.drawRect(0,0,100,100);
here is a Adobe Tutorial
AS3 all display class list here
You do not necessarily need to default AS3 include. fine compile. But include only the code you can see the hint. perhaps, CS4 after that if you use a specific class will automatically include. or ctrl+space is autocompletion.
As follows by default when you install the flash is because of the SWC path.
As per I know, there is not such a thing like Flash.include. May be you're trying to ask something else or may be i am still unknown about this feature.
If you found any positive thing about this, please let me know, i want to know that new thing.

Working with OOP and TimeLine

I'm having a problem using flash CS6 (or CS*), where I want to be able to create symbols in the interface and link them to an as3 class. The problem is that when editing the class the code hints don't work correctly, i suppose because the CS* interface doesn't tell the code the object types.
For example:
I create a symbol and link it to a class (myclasses.SomeDisplayObject)
I now create and edit this class in the flash pro code editor, but the editor doesn't know any of the object properties.
To combat the problem I've been creating private properties on the class and assigning them in the construct. This way I can set the type and code hinting works. This is a real nuisance and I have in one class 50 lines of variable assignments.
There must be a better way of doing it and I'm hoping someone here knows about it.
Just turn off "declare stage instances automatically" and declare them as public properties. For more specifics on how to deal with OOP on the timeline, check out http://www.developria.com/2010/04/combining-the-timeline-with-oo.html and http://www.meetup.com/atlflex/files/
The IDE (or any other code tool you choose to use, like Flash Builder), should then recognize your instances.
You could use a different editor. For instance, there is FlashDevelop

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

Is there a workaround for the missing ExternalInterface.objectID in ActionScript 2

I'm downporting some ActionScript 3 to ActionScript 2 (some ad agencies sadly still refuse to embrace the future) and I've run into the issue that in ActionScript 2 ExternalInterface has no objectID property, as it does in ActionScript 3.
The code I'm working on calls a lot of JavaScript, and some of that code requires the script to know the ID of the Flash object/embed (for example to find the position on the page, and to resize the object/embed).
Is there a simple workaround to get hold of the object/embed ID in ActionScript 2?
I have managed to write some JavaScript code that basically searches all object and embed nodes on the page until it finds one with a special method (set with ExternalInterface.addCallback) and that way managed to get the ID into the ActionScript environment, but it feels like a hacky and unsafe method to rely on. Surely there is a simpler way?
Edit: I don't have control over the code that embeds the SWF, so passing in the ID doesn't work.
Is this what you looking for?
Simple actionscript 2 class that find it owns flash html object id.
http://sourceblogg.se/lang/en/mina-projekt/isitme-get-flash-html-object-id-within-flash/
What about passing the ID to the SWF via FlashVars? You should know the ID when you embed it, so it should be easy enough to add it as one of the FlashVars variables passed to Flash. Then store that somewhere your code that calls ExternalInterface can get at it.
Try the Flash Javascript Integration kit http://weblogs.macromedia.com/flashjavascript/ .
As far as I'm aware, the ExternalInterface class in AS3 was a formalisation of this AS2 solution.