AS2 to AS3 migration of code...
==============
This code is in AS2
==============
_root.createEmptyMovieClip("tmp",900);
_root.createEmptyMovieClip("tmpLoded",101);
_root.interval = setInterval(_root.logger,5000);
loadVariables("http://www.site.com/trackL.php?eid="+_root.id+"&rdoc="+_root.rdoc+"&str="+_root.generateRandomStr(),_root.tmpLoded);
function logger () {
loadVariables("http://www.site.com/track.php?eid="+_root.id+"&str="+_root.generateRandomStr(),_root.tmp);
function generateRandomStr () {
var dt = new Date();
var str = dt.getMilliseconds()+""+dt.getSeconds()+""+dt.getMinutes()+""+dt.getHours()+""+dt.getDate ()+""+dt.getMonth()+""+dt.getFullYear();
return str;
trackL.php - tracking if it loads correctly
while
track.php - will be generated periodically every 5 seconds.
How would I pass a variable from flash to php?
I've been in many tutorials in the net but I cannot understand much of the tutorials...
I only saw same method like using URLRequest & URLLoader with the location of the php files then the variables in the php which connects to the database is accessible.
All are accessing the php not passing flash variables to the php file like in the above code.
All help is greatly appreciated.
that's really poor as2 coding so it will translate to really poor as3 coding.
but, to answer your question, you assign a data property to your urlrequest to convey data from flash to php. the data property will be a urlvariables instance and you assign variables/values to your urlvariables instance:
var urlVar:URLVariables=new URLVariables();
urlVar.eid=whatevervalue;
urlVar.rdoc=whatever;
urlVar.str=whateverelse;
yourURLRequest.data=urlVar;
Similar Messages
-
Help Converting AS2 to AS3 Drag and Drop Event
Hi All,
This is the second post on help for converting AS2 to AS3. This code is used in Captivate to allow a drag and drop action between two areas (User presses down, drags, and releases in a second area - They are not dragging any object). If anyone can help me convert this please let me know.
Source for Drag and Drop: (Note: Single MovieClip)
// pause the Captivate movie
_root.rdcmndPause = 1;
// when the user's mouse is let go check if there was a successful drop
_root.onMouseUp = function(){
// If the source area's center coordinate is nearby the destination area's center coordinate then advance the slide
if ( Math.abs(_root.sourceX + _root.sourceWidth / 2 + _root.sourceParentX - (_root.destX + _root.destWidth / 2)) < (_root.destWidth / 2) &&
Math.abs(_root.sourceY + _root.sourceHeight / 2 + _root.sourceParentY - (_root.destY + _root.destHeight / 2)) < (_root.destHeight / 2) )
_root.rdcmndNextSlide = 1;
} else {
// show error movie clip for 2 seconds (60 frames at 30 frames per second)
_root.showErrorMessage = 60;
mc.onEnterFrame = function(){
// continuously update the source area's coordinates and size
_root.sourceX = mc._x;
_root.sourceY = mc._y;
_root.sourceWidth = mc._width;
_root.sourceHeight = mc._height;
_root.sourceParentX = _parent._x;
_root.sourceParentY = _parent._y;
mc.onPress = function(){
// Uncomment following line to have control click capabilities
//if(key.isDown(Key.CONTROL))
// when user clicks on the source area click start the drag
startDrag(this);
mc.onRelease = function(){
// stop drag when user releases the source area
stopDrag();
Source for Destination Area (Single MovieClip named destArea)
// Set a root variable to control when the error message is displayed
_root.showErrorMessage = -1;
// Use setCoords variable so we only set the destination coordinates once
var setCoords = 0;
destArea.onEnterFrame = function(){
if (setCoords == 0){
// set the destination x, y, width, and height
_root.destX = _parent._x;
_root.destY = _parent._y;
_root.destWidth = _parent._width;
_root.destHeight = _parent._height;
// destination coordinates have been set, change setCoords so it doesn't get set again
setCoords = 1;
Code for the Error Message (Single MovieClip named errorMessage)
// Don't display the error message initially
errorMessage._alpha = 0;
errorMessage.onEnterFrame = function (){
// If the drag and drop method detects a missed drop
// then show this error message by setting _alpha to 100
if (_root.showErrorMessage > 0){
errorMessage._alpha = 100;
// decrementing this variable controls the time the
// error message will be displayed
_root.showErrorMessage--;
} else {
// Don't display the error message
errorMessage._alpha = 0;use:
MovieClip(parent.parent.parent).rdcmndPause=1;
this.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);
function keydownF(e:KeyboardEvent):void{
fscommand("KEYPRESSED", e.keyCode);
if(e.keyCode==32){
MovieClip(parent.parent.parent).rdcmndNextSlide=1; -
Please help 'Translate' These codes from AS2 to AS3 for me
Hi, i need help 'translating' these codes from Action Script 2 to Action Script 3. Please Do it for me:
toc loadText = new LoadVars();
loadText.load("Curie.txt");
loadText.onLoad = function(success) {
if (success) {
// trace(success);
Curie.html = true;
Curie.htmlText = this.Curie;
Please translate it for me, i need it ASAP thanks
KennethThank you for helping me
Kenneth
Date: Thu, 15 Oct 2009 05:49:14 -0600
From: [email protected]
To: [email protected]
Subject: Please help 'Translate' These codes from AS2 to AS3 for me
Take a look at that:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html
There is a LoadVars section on that.
There is also a tutorial here:
http://www.republicofcode.com/tutorials/flash/as3externaltext/
Cheers,
CaioToOn!
> -
Plz any one convert this code from AS2 to AS3???????reoly me on [email protected]
#initclip
function Dot() {
this.color = new Color(this);
this.color.setRGB(16775372);
this._rotation = 150; /////////////////rotate of object////////////////
this._width = 30; /////////////////width of object////////////////
this._height = 30; /////////////height of object//////////////
this._x = 300+Math.random();//*8-0(X vibration type effect) /////////////X position of object//////////
this._y = 250+Math.random();//*8-0(Y vibration type effect) /////////////Y posotion of object///////////
Dot.prototype = new MovieClip();
Object.registerClass("myfirst", Dot);
Dot.prototype.onEnterFrame = move;
function move() {
this.age++;
this.relage=this.age/12;
R=255<<16;
G=(255-(this.relage*126)); if (G<0) G=0; G=G<<8;
B=(255-(this.relage*1024)); if (B<0) B=0;
this.color.setRGB(R+G+B);
this._x -= Math.random()*-2-1.25;
this._y -=Math.random()*+1.75;
this._alpha -= 3;
this._xscale -= 2;
if (this._alpha<5) {
this.removeMovieClip();
#endinitclipJust remove #initclip and #endinitclip from the code and remove all underscores, example : this._x will be this.x
Hope this helps! -
Major gaming system Migration from AS2 to AS3
I have a major project entirely in AS2. It is made of a
Multimedia Application, which provides access to functions needed
to load games, save information, insert *.jpg files... The 50+
games each have their own graphic.swf and engine.swf, where the
graphics deal with gameplay and the engine communicates with the
Multimedia Application.
If the Multimedia Application is migrated to AS3 but the game
swf files remain the same, will the functions still be able to
communicate (call functions and send references to objects)?No, AS2 and AS3 are absolutely different animals. There are
some techniques (search for as2 as3 bridge in the net) that create
a bridge which are cumbersome in my view. -
So I made this basic game a few years ago which was in AS2 and Flash 6. Now I want to convert this game from AS2 to AS3 but I have no idea where to start. The code is approximalty 4k lines long and I don't know what to change to make it work in AS3. What do you guys suggest?
Are you using external .as files and classes or are you using frame scripts directly in the timeline? Are you used to any other object oriented programming languages? Knowing more about other languages you might know would help a lot.
AS2 very informal and specialized to Flash. It relates to pretty much no other language out there, like JavaScript seldom relates. They're c-esque but only in a very distant 3rd cousin style.
AS3 is much more OOP oriented and typed versus the less formal, error-prone loose dynamic nature of AS2. While your game would benefit greatly from the speed increases and error reduction, I think you're really swinging for the fence on this one. While some classes may resemble their AS2 counterpart and the core global functions work the same, everything else is different. Starting off trying to convert 4,000 lines of code is a little steep.
As mentioned, the resources to learn AS3 are excessive and plentiful from video training to tutorials to the API reference itself. Google has it all.
I think you really should lower your target and just try some really simple, basic things. Draw a shape, add a listener, do something basic when clicked, etc. You'll get a good idea of how different things are with the new display list rather than tearing your hair out converting your as2 game. -
Hello,
i have this code
var url = _level0.video;
player.contentPath = url;
this catch a url and load on flash player.
this works fine in As2, but in As3 dont work.
i use a converter As2 to As3 but the result is it:
package {
var url = _level0.video;
player.contentPath = url;
i not a As programmer i only use video function on flash,
my question is, how to use my code on ActionScript 3 ??
Thank you !!Thanks for reply,
the variable video i get from html and php.
example:
player.swf?video=<?php echo $_GET["video"]; ?>
and the variable video i get from html
<a href="index.php?video=video.flv"></a>
ok, i discard a converter !!
to use a contentPatch source of flash ?
but i can load a external videos ??
without ActionScript ?
Thank you ! -
Issues converting scroll bar components from AS2 to AS3
I am working on editing a document that has scroll bar components that I would like to convert from AS2 to AS3 since everytime I try to open the document it shows a WARNING and won't convert them and when I publish and look at the final document the scroll bar seems to act unusally since it is obviously still on AS2.
Here are two of the scripts I finally was able to find within it. Should I fix it and how so? This first is for the "Creative Scroll Area" and the second is for the "Creative Scrollbar"
package {
import flash.display.MovieClip;
public class Creative Scroll Area extends MovieClip {
public function Creative Scroll Area() {
// constructor code
package {
import flash.display.MovieClip;
public class Creative Scrollbar extends MovieClip {
public function Creative Scrollbar() {
// constructor codeOkay, well I know the code is making a scroll bar and a scroll area and under the "type" it says they are "compiled..." which is unusual since most of the other components I've worked with have been movie clips or bitmaps. Do I need to look up what AS3 components I need to replace the script from above? Because when I looked for that I couldn't specifically find what I needed or really understood if I was looking at the right information.
Here is something I found when trying to "debug" it:
WARNING: The component 'UIScrollBar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
WARNING: The component 'Creative Scrollbar' requires ActionScript 2.0, which is not supported in this version of Flash Professional.
WARNING: The component 'Creative Scroll Area' requires ActionScript 2.0, which is not supported in this version of Flash Professional. -
Declare new color from AS2 to AS3
Hi All,
Could you let me know how to "convert" the following code from AS2 to AS3:
var distracterBkgdColor = new Color(this.distracterBkgd_mc);
Thanks!var ct:ColorTransform = this.distracterBkgd_mc.transform.colorTransform;ct.color = 0xrrbbgg;
this.distracterBkgd_mc.transform.colorTransform=ct; -
As2 and As3 on same Flash Player
If i set AS2 codes to play in Flash Player 9, is it possible
that this swf can load an As3 swf at the same Flash Player using
As2 codes???
These swfs both play in same virtual machine which is player
version 9 but the other is coded with As2 and the other is coded
with As3. How can an AS2 load a swf coded in AS3 on same Flash
player?
Is this possible?
If yes, how? if no, why not?AS2 and AS3 swfs cannot exist in the same Flash Player
virtual machine - each Flash Player instance (version 9 and
greater) create different address spaces/virtual machines because
the requirements of AS3 and AS2 are so different. -
Hello, i'm somewhat decent in flash. I know AS2, i started
learning AS3 today and find it to be more complicated and has so
many extra steps in coding. Number one thing i hate is having to do
all the code on the timeline, it will get so full of code if i have
several buttons/movieclips that need code, no way to do code when
you click on the button/movieclip in AS3 unlike 2.
Would it be dumb for me to continue to use AS2 and learn more
of it, or should i keep trying to learn AS3..... I don't do super
complex stuff, mostly timeline navigation and animations.
I also feel like there is way more room to make errors in 3
because you have to type everything unlike AS2 where i was able to
use the actions frame (use that plus tool that had the drop down
menu).I'm in the same position, just starting to move from
intermediate comfort with AS2 to a fresh beginning with AS3...not
so easy for a guy who has so little logical thinking that I failed
algebra in high school! I too am a bit annoyed by all the extra
steps involved, such as having to add EventListeners for mouse
events, when these really ought to be simplified and there by
default, like in AS2. For example, why can't onMouseDown remain as
a built-in behavior rather than having to take up 2 lines of code
to insert it each and every time now?
On the other hand, I am delighted at the way a lot of the
inconsistencies in AS2 have been gotten rid of. No more having to
remember when to put .x and when ._x, and so on. And now that I'm
finally starting to learn how to use external classes, I see the
beauty in it, and AS3 is custom-made for this. It seems that if you
ever want to really advance in ActionScript programming, you need
to start working with creating your own classes, and as long as
you're going to learn those from scratch, may as well learn it in
AS3.
Putting AS on buttons was outdated practice years ago. It
makes much greater sense to place all script on the timeline, with
comments to separate it. Try programming the simplest game where
objects are moving around and colliding, all controlled by script,
and then a couple coded buttons control them. Bugs are inevitable,
and debugging script when it's partly on the timeline, some is
attached to main movie buttons, and some attached to movie clips
inside movie clips, is a nightmare. Once you do scripting on the
timeline, you'll never want to go back to the crude practice of
attaching script to objects.
Overall, it's a steeper climb than I'd have liked, to upgrade
my knowledge from AS2 to AS3. But ultimately I think it's the best
idea. -
AS2 to AS3 Streaming Video Player
Ok so Im trying to convert a video play that i made in AS2 to
AS3 (I had a problem with nested movie clips and the control bar
and i want to learn AS3) and i am having troblem even connecting to
my rtmp server. With the player i made in AS2 i was able to connect
and stream video no problem. But with AS3 I am not even able to
connect to the rtmp server. Here is the AS2 code and the AS3 code:
AS3:
var video:Video = new Video(853,480);
addChild(video);
var nc:NetConnection = new NetConnection();
nc.connect("rtmp://[ip of server]/sumone4life/videos");
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS,
onStatusEvent);
function onStatusEvent(stat:Object):void
trace(stat.info.code);
var meta:Object = new Object();
meta.onMetaData = function(meta:Object)
trace(meta.duration);
video.attachNetStream(ns);
ns.play("AdobeBand_640");
And I get the error:
ArgumentError: Error #2126: NetConnection object must be
connected.
at flash.net::NetStream/construct()
at flash.net::NetStream()
at videoPlayer_fla::MainTimeline/frame1()
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095:
flash.net.NetConnection was unable to invoke callback onBWDone.
error=ReferenceError: Error #1069: Property onBWDone not found on
flash.net.NetConnection and there is no default value.
at videoPlayer_fla::MainTimeline/frame1()
Flash media server 3 Administrative Panel also shows that I
am infact connected to the server but there is nothing being
streamed from the server.
AS2 Works:
//Video Loading Controls
var fileName:String = "AdobeBand_640";
var nc:NetConnection = new NetConnection();
var ns:NetStream;
nc.onStatus = function(info){
trace(info.code);
if(info.code == "NetConnection.Connect.Success"){
playVideo();
function playVideo(){
ns = new NetStream(nc);
ns.onMetaData = onMetaDataHandler;
videoObject.attachVideo(ns);
_root.createEmptyMovieClip("vSound",
_root.getNextHighestDepth());
vSound.attachAudio(ns);
ns.setBufferTime(5);
ns.onStatus = function(info){
trace(info.code);
if(info.code == "NetStream.Buffer.Full"){
bufferClip._visible = false;
if(info.code == "NetStream.Buffer.Empty"){
bufferClip._visible = true;
if(info.code == "NetStream.Play.Stop"){
ns.seek(0);
ns.play(filename);
//connects the stream
nc.connect("rtmp://[ip of server]/sumone4life/videos");
Can anyone offer any insite as to why it would be workin in
AS2 and not in AS3? Or what i am doing wrong...I have a similar problem. Did you get your to work?
-
Looking for a copy of Patrick Mineault's AS2 to AS3 converter.
Anybody have a copy of Patrick Mineault's AS2 to AS3 converter sitting around? His website closed down in May and he changed careers.
Thanks!See if this is it:
http://download.info.apple.com/Apple_Support_Area/Manuals/powerbooks/0301677CPBU G.PDF -
Migrating Sybase code to Oracle 11g
Hi All,
We have to migrate Sybase code to Oracle 11g.
When we are doing a SELECT .. INTO in Sybase , even if the query is returning more than 1 row , sybase selects 1 of the rows and populates the variables.
But while migrating this code to oracle, we are getting TOO_MANY_ROWS Exception.
We need to migrate the code from SYBASE to ORACLE without disturbing the logic.
Can someone please tell me the logic applied by SYBASE to pick up the record?
And if someone has faced this issue, then what can be done to resolve this.
Regards,
Riddhisha KhamesraThe result 3 is the last entered record (not the amount of records..).
So the first approach to write a dummy procedure that will select all records in Oracle like:
CREATE OR REPLACE PROCEDURE last_record
v_arg1 OUT NUMBER
AS
BEGIN
SELECT col1
INTO v_arg1
FROM tt_tmp ;
END;
and hopefully returns only the last record will fail with:
SQL> variable outvar number
SQL> exec last_record (:outvar)
BEGIN last_record (:outvar); END;
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "SYSTEM.LAST_RECORD", line 9
ORA-06512: at line 1
One possible approach to get the last (and only the last) record that was entered into the table is to use rownum:
The select might look like "select col1 from (select col1, rownum from tt_tmp order by rownum desc) where rownum=1;"
So the procedure can be coded as:
CREATE OR REPLACE PROCEDURE last_record
v_arg1 OUT NUMBER
AS
BEGIN
SELECT col1
INTO v_arg1
from (select col1, rownum from tt_tmp order by rownum desc) where rownum=1;
END;
Now calling it in SQL*Plus:
SQL> variable outvar number
SQL> exec last_record (:outvar)
PL/SQL procedure successfully completed.
SQL> print :outvar
OUTVAR
7
The value 7 is the last record I've inserted into my tt_tmp table:
SQL> select * from tt_tmp;
COL1 COL2
1 1
2 2
8 8
7 7 -
HTML Link -AS2 fine, AS3 weird behaviour
Hi Guys, I'm working on a project at the moment, and am
seeing weird behaviour with the way my swf handles html links
inside dynamic textboxes. When rendered as a AS2 file, the link
works on a release as expected. When its inside a AS3 file the link
will only work if the user right click and chooses 'open in new
window' was there a change in behaviour how AS3 handles these
links, or is there now an declaration needed to be made to allow
these link to have the old behaviour?
The project calls for xml data and embedded in that is a html
link. Originally I thought it might have been the way I'd formed
the xml so I tried with a hardcoded version instead (dynamic
textbox, add text -> highlight -> add link through properties
tab). But I still see the same behaviour between the as2 and as3
versions.
Any help would be greatly appreciated.
Cheers.Actually, the ''href'' attribute is supposed to direct the browser to a new URL, etc., not run a script. Instead, use the ''onclick'' event attribute:
''<a onclick = “$('.div-feedback').fadeIn();”></a>''.
Happy coding!
Maybe you are looking for
-
How to set default mail client
I occasionally respond to a email address and Microsoft outlook express comes up instead of gmail, which I prefer. How can I keep Outlook from butting in?
-
Stopping invoice Parking for Second time Parking for a frame work PO...
Hi SAP Guru's.. there is a Requirement from Client site that .. for a Frame work PO which comes with a Invoice plan .. we should be able to Stop Second time invoicing Maintained in Invoice Plan... How to Go for this ... Any workable suggestion would
-
Hi all, If i want to delete a PERNR i will go to PU00 Tcode and give the pernr no. and select the respective infotypes data and delete. From this it is not possible to delete the PD(Org. Management) data,I mean the data will be remain in HRP tables f
-
Issue with using SSXA region templates with Content Presenter.
I am using Content Presenter taskflow in Webcenter Portal. When i try to use the SSXA region template with content presenter, it doesnot render the html markup. But if i use normal UCM region templates(hscp), its rendering the html markup properly. H
-
Getting the value of a String through reflection
I have a class with a member variable that is of type String. How can I retrieve this value through reflection? I have tried the following String x = (String) myclass.getClass().getField("myvar").get(new String()); If I try this I get IllegalArguemtn