Qwerty example in as3
does anyone have an example of a keyboard updating a text
area in AS3?
Thanks.
Albert
Better explanation of your problem would help. From what I
get out of this, I would say you need to add listeners for the keys
you want to invoke functions from.
Similar Messages
-
Hi
Can you please give me the best sites/examples of as3 application..
ThanksIn addition to that:
http://active.tutsplus.com/
http://www.gotoandlearn.com/ -
Need an example of AS3 to duplicate form
I have been trying to solve this problem for 4 days to no avail. The entire site is done with the exception of this one hangup. I need to have 2 email forms on 2 different places in the timeline going to 2 different addresses. I have the PHP for both, but am having problems getting the 2nd form to function.
When I try to reuse the same code for the 2nd email, I get a load of errors regarding duplicate functions.
Can anybody edit, copy and paste an example of the following script (the one that works with the first form). I believe can figure out the instance name changes, etc. if I have something to work with.
I am a total newbie and don't know a thing about AS3 and I have a hard time understanding the explanations. I just need a script that won't conflict with the first form as duplicating functions etc. Thanks (PS: The string in red is for the 1st email form. I also have a PHP file "send_email_02.php" for the 2nd email form.
stop();
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
send_button.addEventListener(MouseEvent.CLICK, submit);
reset_button.addEventListener(MouseEvent.CLICK, reset);
var timer:Timer;
var var_load:URLLoader = new URLLoader;
var URL_request:URLRequest = new URLRequest( "send_email.php" );
URL_request.method = URLRequestMethod.POST;
function submit(e:MouseEvent):void
if( contact_name.text == "" || contact_email.text == "" ||
contact_subject.text == "" || contact_message.text == "" )
message_status.text = "Please complete all text fields.";
else if( !validate_email(contact_email.text) )
message_status.text = "Please enter a valid email address.";
else
message_status.text = "sending...";
var email_data:String = "name=" + contact_name.text
+ "&email=" + contact_email.text
+ "&subject=" + contact_subject.text
+ "&message=" + contact_message.text;
var URL_vars:URLVariables = new URLVariables(email_data);
URL_vars.dataFormat = URLLoaderDataFormat.TEXT;
URL_request.data = URL_vars;
var_load.load( URL_request );
var_load.addEventListener(Event.COMPLETE, receive_response );
function reset(e:MouseEvent):void
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
function validate_email(s:String):Boolean
var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var r:Object = p.exec(s);
if( r == null )
return false;
return true;
function receive_response(e:Event):void
var loader:URLLoader = URLLoader(e.target);
var email_status = new URLVariables(loader.data).success;
if( email_status == "yes" )
message_status.text = "Success! Your message was sent.";
timer = new Timer(500);
timer.addEventListener(TimerEvent.TIMER, on_timer);
timer.start();
else
message_status.text = "Failed! Your message was not sent.";
function on_timer(te:TimerEvent):void
if( timer.currentCount >= 10 )
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
timer.removeEventListener(TimerEvent.TIMER, on_timer);There are several ways to do this. The way that I like best is using a User Setting.
1) Pick a name for your setting.
2) Enter the name of the setting in the web service configuration for the two (or more) web services that want to share the setting. Any portlet that needs to "see" the setting must have it specified its web service configuration.
3) When a user clicks on a link in one of your portlets, set the setting: IPortletResponse.SetSettingValue(SettingType.User, "settingName", "settingValue")
4) In another portlet, get the setting and display it: IPortetRequest.GetSettingValue(SettingType.User, "settingName")
The nice thing about doing it this way is that even if your portlets are set to be cached "forever," they will change whenever you change the user setting (assuming you followed step 2).
Hope this helps,
Chris Bucchere
[email protected]
Bucchere Development Group
http://www.bucchere.com| 415.516.3941 -
Hi Has anyone got an example of his?
An example of what? You should describe the specifics of what
you are looking for... -
Custom event example in as3
Hi,
Event listener model in cs3 looks nice it is not same as we
were heaving earlier in as2 or till flash 8.
Here is an example of using and making your own custom event
in as3.
This example allow user to load n number of XML file when XML
file is loaded then dispatch an event "XMLLoaded" which can be
listen by any other class any where.
There are two class
1. CustEvent
2. DEvt
Here are the definition of both class
CustEvent.as
* Author - Sanjeev Rajput
* Date - 16-July-07
* class is used to load any XML file and dispatch an event
when XML is loaded
package eventDispatch{
import flash.events.Event;
public class CustEvent extends Event {
public static const XMLLoaded:String = "XMLLoaded";// Event
Name
public var XMLData:XML // loaded XML data
public var XMLRef:String // XML file name
public function CustEvent(type:String,
param:String,param1:XML) {
this.XMLData= param1;
this.XMLRef=param;
super(type);
DEvt.as
* Author - Sanjeev Rajput
* Date - 16-July-07
* class is used to load any XML file and dispatch an event
when XML is loaded
package eventDispatch{
import flash.events.EventDispatcher;
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
public class DEvt extends EventDispatcher {
private var xmlLdr:URLLoader;
private var urlr:URLRequest;
private var xmlpath_str:String;
public var XMLData:XML;
private var counter:int=0;
private var xmlRequestArr:Array
public function DEvt():void {
this.xmlRequestArr=new Array()
public function loadXML(fileRef:String,xmlRef:String):void {
this.xmlpath_str=fileRef;
this.xmlRequestArr.push(xmlRef)
this.xmlLdr = new URLLoader();
this.urlr=new URLRequest(this.xmlpath_str);
this.xmlLdr.addEventListener(Event.COMPLETE,
completeHandler);
this.xmlLdr.load(this.urlr);
private function completeHandler(evt:Event) {
this.XMLData=new XML(evt.target.data);
this.dispatchEvent(new
CustEvent(CustEvent.XMLLoaded,this.xmlRequestArr[this.counter],this.XMLData));
this.counter++
evtDispatchExample.fla
Inside this fla on very first frame I have following code
import eventDispatch.*;
var DEvt_obj:Evt=new DEvt();
DEvt_obj.loadXML("xml.xml",'xml0 File');
DEvt_obj.loadXML("xml1.xml",'xml1 File');
DEvt_obj.loadXML("xml2.xml",'xml2 File');//----and so on---
DEvt_obj.addEventListener(CustEvent.XMLLoaded,XMLL oaded);
function XMLLoaded(evt:CustEvent) {
//--- here we can check which XML file is loaded----
if(evt.XMLRef=='xml0'){
//--- do necessary task when this file loaded
//---XML data can be found in evt.XMLData
trace(evt.XMLData) //-- property of CustEvent class
if(evt.XMLRef=='xml1'){
//--- do necessary task when this file loaded
//---XML data can be found in evt.XMLData
trace(evt.XMLData) //-- property of CustEvent class
//---- and so on for n number of XML file----
}Have you tested this online with varyious file sizes? Seems
to me there that
there is no guarantee as to when a loader will complete its
task. If the
second request completed before the first, how would you
dispatch the
correct information? -
How to add flex SDK to IntelliJ
how to add flex free SDK to intelliJ6 or any IDE
I don't have any issues with playing MP4. You must understand that mp4 should meet MP4 format requirements. If your video can't be played - this may be caused by issues with that mp4 video file but not Adobe Air.
For example this AS3 code succesfully play mp4 video that meet mp4 requirements by format (not Adobe whimsy). Also you may note that StageVideo available on Direct render mode. Auto or CPU will not support native mp4 playing.
package {
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.StageVideo;
import flash.geom.Rectangle;
public class sv extends Sprite {
private var nc : NetConnection;
private var ns : NetStream;
private var client : Object = {};
private var StageVideoContainer : StageVideo;
public function sv() {
client.onMetaData = onMetaDataCallback;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.client = client;
StageVideoContainer = stage.stageVideos[0];
StageVideoContainer.attachNetStream( ns );
StageVideoContainer.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
ns.play("162447510.mp4");
private function onMetaDataCallback(e:Object):void{
Here is Windows 7 Adobe Air project config from Flash CC. MP4 works prefect!
In this sample app I use Adobr Air 4.0.0.1390 from latest official release. You can chat to my skype therabbitwindfall and I will support you with my mp4 and Win7 project.
P.S. this mp4 works fine on iOS also. -
How to populate ComboBox with images?
Hello, I was just wondering if it is possible to populate a
ComboBox with images or icons? If it is possible, I want each item
to have both a picture and text. Any help on this matter would be
great!I'm using Flash AS3. I currently have the code working for
the tileList component. I load the "label:", "source:" and "data:"
from a php script. It works great! Tried to do the same method for
the comboBox with no luck. I have spent lots of time searching the
web for help on this, but unfortunately AS3 is still relatively new
and much differant from previous versions of actionscript, so it is
hard to find any good examples. Although the help and examples for
AS3 is pretty extensive on adobes website, it seems that I can
never find the help and examples that relate to any problems I
might encounter. -
Hello.
I am brand new to Flash, Programming, and Network Mechanics in general. I am working with an old version of Flash (Macromedia Flash 8).
My goal is to build a fully functional browser version of the popular MMORPG "Ultima Online" in Flash by the height of this summer (August) for distribution on the Facebook platform.
The server emulator is fully coded freeware (http://www.runuo.com) and I believe the packets are fully documented by a few hobbyists.
Any pointers/tips you can give me would be much appreciated. I have plenty of time and I am willing to learn whatever programs and systems you name.
Thanks!Building a game is no small feat, especially the size in which you entail. There are so many technologies available today you can leverage to aid you that you can't use I wouldn't even know where to begin.
Here's a start. Take a look at the Stage3D API and classes. Half way down this page links you to several frameworks (Flare, Alternativa, Starling, etc) that are designed to leverage the brand new GPU powered Stage3D framework. They do a lot of the work for you.
http://www.adobe.com/devnet/flashplayer/stage3d.html
For your purposes I would look into Starling first. If it's going to be on Facebook then your audiences computers capabilities will be the entire gaumet from horrifically old win98 laptop to brand new ivy bridge 64gb ram RAID0 SSD gaming rigs. You need to cover them all. So you should start off from the gates using the technology Adobe is promising will adequately power online gaming in the future.
The ever popular Facebook game Cafe World was a good example of AS3 simply not handling lots going on at the same time. It would even bog down a quad core. People would argue flash is not threaded and can't utilize more than one CPU but they don't understand how a CPU works. Aside that, Stage3D removes this problem and opens up the gates up to (as Adobe states) 1000x faster speeds.
Starling is 2D. It is very easy to use and has support from Adobe. They have some nice tutorials to get you up and running.
Problem is, you're on Flash 8. So I'd download the latest Flash Builder and Flash trials. Use Flash Builder to code in and use Flash just to manage assets. Flash CS6 can now even cut out its own spritesheets so you won't need something like Texture Packer (free) to make sprite sheets.
After you make your assets in Flash (graphics, audio, etc) and give it actionscript linkages (classes) you can export that as a SWC. This is optional, you can do the whole thing 100% in Flash Builder, but it's much faster in Flash. Regardless, then you import your SWC into Flash Builder (4.6 is the latest). Make sure you update to the latest release version of Flash (11.2) and AIR (3.2). Then start doing Starling tutorials.
You will find the vast majority of tutorials on any Stage3D or advanced content and examples to be Flash Builder tutorials rather than Flash. There's a reason. It's a better coding app.
There are alternatives to Flash Builder like the FDT eclipse plugin or FlashDevelop. Although not many tutorials utilize them and you'll find yourself spending a lot of time converting what they say into how your particular software does it. And sometimes your software can't do it at all.
If you have any very specific questions, fire away. It's a little large of a target to just ask how to code a game though. But there's a good place to start. -
I have a simple game with a dial and a needle. I have made two "right" and "wrong" buttons. Simply, I need to be able to make the needle move forward when the "right" buttons is clicked, and backward when the "wrong" button is clicked, regardless of the needle position on the dial. What would be the simplist way to accomplish this? I am a beginner with Actionscript, and I've tried all I know to do. Thanks for any reply.
Showing what you've tried to do will help. You essentially just need to change the rotation value of the needle depending on the button selected...
objectName.rotation += someValue;
Where some value is either a positive or a negative number representing degrees. In that example line, AS3 (rotation) is used. In AS2 it would be _rotation. -
Need assistance with buttons pulling in different MC's
Hi I would like to have a screen with multiple buttons and
when the button is clicked different MC's will be imprted into the
.fla file. For instance button 1 will import 1_MC, button 2, 2_MC,
button 3, 3_MC etc.
Can someone point me to a tutorial or give me a down and
dirty example using AS3?You don't need to make the buttons as movieclips, but you
could if you had a reason for it. Like if you wanted to load the
images into the buttons themselves... then you'd need them to be
movieclips. You can use the same code for the event listeners for
movieclips as you would for buttons...
myButton1.addEventListener(MouseEvent.CLICK, addMovie1);
But you don't add this code to the buttons (like you used to
be able to sort of do in AS2)... it sits in the actions layer you
create in the timeline where most of your code goes. As long as
your button in in the same timeline and has the same instance name
assigned to it as the code (ex. myButton1 above), the code will
play for the button.
You can position instances using AS by setting their x and y
coordinates, even before they appear. You can pretty much set any
property before you add it to the stage....
function addMovie1(e:MouseEvent):void
var myMovie1:Movie1 = new Movie1();
myMovie2.x = ...
myMovie2.y =...
myMovie1.name = ...
myMovie1.alpha = ...
etc...
mcContainer1.addChild(myMovie1);
I think I've handled all of your questions with the snippets
I just provided, so give it a go. Tutorials are handy, but you're
doing the right thing if you find yourself struggling to figure
stuff out without them... it's a better learning process... it
tends to burn in better and last longer from having to solve
it. -
I have a problem while typing in my MacBook pro. it is showing different characters when i type. for example: qw`e§r]t[y= this is how when we type "qwerty|" can anyone help me pls?
You could just try changing your Input Sources under System Preferences>Language & Text:
But I kind of doubt that's going to work. It may be a hardware problem or a system problem. If you take it into Apple they might be able to determine which and might advise a reinstallation of System software. I would take it to an Apple Store or an AASP but, first, make sure that you have a backup just in case they suggest a clean install of the system.
Good luck,
Clinton -
Downloaded the latest Sprite10 (v0.93) release. I see lots of MXML based examples. However, OSMF is supposed to be able to be leveraged in AS3 or MXML. Where's the AS3 examples?
There's a number of AS-only samples in the http://opensource.adobe.com/svn/opensource/osmf/trunk/apps/samples/framework folder, for example:
HelloWorld
HTMLMediaContainerSample
LayoutSample
MediaContainerSample
OSMFPlayer
Cheers,
Edwin -
How to use this example code in Flash AS3?
Hi,
How can I use this AS3 code in my Flash CS4 document? The following code is in the below link:
http://pv3d.org/2009/12/18/tweenmax-tweening-a-timeline-advanced-tweening/#
Please help.
Thanks.Hi,
It is working quite nice. I want to use the same code but instead of as "Document Class" I want to put that code in a first key frame of my project. I tried the following but gets an error:
The error is : 1131: Classes must not be nested.
And the following code I tried is:
import com.greensock.TimelineMax;
import com.greensock.TweenMax;
import com.greensock.easing.Linear;
import com.greensock.easing.Quart;
import flash.display.Sprite;
* @author John Lindquist
[SWF(width="900", height="480", frameRate="31")]
class EasingATimeline extends Sprite
private var square:Sprite;
private static const STEP_DURATION:Number = 1;
public function EasingATimeline()
square = new Sprite();
square.graphics.beginFill(0xcc0000);
square.graphics.drawRect(0, 0, 50, 50);
square.graphics.endFill();
square.x = 100;
square.y = 50;
addChild(square);
//set all the eases of your steps to Linear.easeNone
var step1:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 700, y: 50, ease: Linear.easeNone});
var step2:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 700, y: 350, ease: Linear.easeNone});
var step3:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 100, y: 350, ease: Linear.easeNone});
var step4:TweenMax = TweenMax.to(square, STEP_DURATION, {x: 100, y: 50, ease: Linear.easeNone});
var timeline:TimelineMax = new TimelineMax();
timeline.append(step1);
timeline.append(step2);
timeline.append(step3);
timeline.append(step4);
//pause your timeline
timeline.pause();
//tween your timeline with whatever ease you want
TweenMax.to(timeline, timeline.totalDuration, {currentTime: timeline.totalDuration, ease: Quart.easeInOut, repeat: -1});
Please help me to solve this problem.
Thanks. -
Basic example on Check-boxes using AS3.0 in flash
Hi all,
I need a basic example containing 3 or 5 check-boxes and
should display the names of check-boxes which are
selected in a text-box.
Thanx a lot...Go to the help subject "CheckBox class" and click "view
examples": The example is an exact answer to your question :-) -
Creating an "if" Statement in AS3
I've been having a problem trying to implement 2 email forms in the same scene at different places in the timeline. If I do just one form, there isn't a problem, but there is a problem with the 2nd form (I've tried using different instance names to no avail). However, it appears I have most of it figured out, but am still having a problem, which I believe I may have a solution for by using an "if" statement. In the following AS3 code is a string that reads var URL_request:URLRequest = new URLRequest( "send_email.php" ); I believe I may be able to resolve the problem if I had a 2nd string (in the same code) that read var URL_request:URLRequest = new URLRequest( "send_email_02.php" ); Is there a way to include that string in the same AS3 by using an "if" statement telling the code to "submit" the 2nd form? If so, could someone please give me an example of how to write that "if" statement? This form has been driving me nuts for 4 days now and any help would be greatly appreciated. Thank you.
stop();
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
send_button.addEventListener(MouseEvent.CLICK, submit);
reset_button.addEventListener(MouseEvent.CLICK, reset);
var timer:Timer;
var var_load:URLLoader = new URLLoader;
var URL_request:URLRequest = new URLRequest( "send_email.php" );
URL_request.method = URLRequestMethod.POST;
function submit(e:MouseEvent):void
if( contact_name.text == "" || contact_email.text == "" ||
contact_subject.text == "" || contact_message.text == "" )
message_status.text = "Please complete all text fields.";
else if( !validate_email(contact_email.text) )
message_status.text = "Please enter a valid email address.";
else
message_status.text = "sending...";
var email_data:String = "name=" + contact_name.text
+ "&email=" + contact_email.text
+ "&subject=" + contact_subject.text
+ "&message=" + contact_message.text;
var URL_vars:URLVariables = new URLVariables(email_data);
URL_vars.dataFormat = URLLoaderDataFormat.TEXT;
URL_request.data = URL_vars;
var_load.load( URL_request );
var_load.addEventListener(Event.COMPLETE, receive_response );
function reset(e:MouseEvent):void
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
function validate_email(s:String):Boolean
var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var r:Object = p.exec(s);
if( r == null )
return false;
return true;
function receive_response(e:Event):void
var loader:URLLoader = URLLoader(e.target);
var email_status = new URLVariables(loader.data).success;
if( email_status == "yes" )
message_status.text = "Success! Your message was sent.";
timer = new Timer(500);
timer.addEventListener(TimerEvent.TIMER, on_timer);
timer.start();
else
message_status.text = "Failed! Your message was not sent.";
function on_timer(te:TimerEvent):void
if( timer.currentCount >= 10 )
contact_name.text = contact_email.text = contact_subject.text =
contact_message.text = message_status.text = "";
timer.removeEventListener(TimerEvent.TIMER, on_timer);While the overall scenario isn't all that clear to me, you don't necessarily need an if statement, but just have the different submit buttons assign the different URL_request values before they intiate any other processing.
Maybe you are looking for
-
How to create a report to bring all data from two different Info providers
Hi All, I have a peculier problem while creating a report. I have two custom info providers one DSO and another Cube. There are only two common fields between these two Info providers . I need to create a report such that the report displays all the
-
Exporting Avid project to iDVD on a Macbook Pro
First, let me say that I know this is a Final Ct forum. But it's also a MacBook pro forum, and I know that many FCP editors also edit on Avid (like me). I hope someone here can help me. I created a project on Avid Media Composer. It was shot in 4:3 b
-
Analysis of DV vs. Component Beta-SP on 10-bit timeline
Alright, this may not be the most scentific experiment, but last week I started using a Blackmagic decklink extreme PCIe card with a new G5 dual 2G and FCP5. Importing Beta-SP. Had been accustomed to bumping Beta-SP to DV and working completely withi
-
Acrobat vs Livecyle - which is better for making accessible PDF's
I am having a very hard time making my PDF accessible. The source program I use to create my document is InDesign 5.5. I convert to PDF and am attempting to tag it using Acrobat X. I tried tagging my form using the articles panel in InDesign but it d
-
Transferring iphoto's from my old imac to my new Christmas imac
How do I transfer all the photos? The 'library' does not want to be dragged anywhere