Converting short code from as2 to as3
Some of these functions wont work in as3, and i would like it to be using gestures instead of mouse clicks.. Any help please?
_root.attachMovie("brush","brush",10)
_root.brush.onEnterFrame=function()
Mouse.hide()
startDrag(this,true)
new Color (this.brushColor).setRGB(_root.brushColor)
on(press)
new Color(this).setRGB(_root.brushColor)
onClipEvent (load) {
myColor = 0x0000CC
new Color(this).setRGB(myColor);
on (release) {
_root.brushColor= myColor;
no code should be attached to objects.
most of that looks like it's useless or worse than useless. in particular, everything in the enterframe loop looks like it serves no purpose and repeatedly does useless things. if it is doing something useful, it doesn't need to be done in a loop.
and setting the rgb of a color instance does nothing useful.
the only thing useful is setting brushColor when that brush movieclip is clicked.
so, if you have a movieclip with class = "brush" in your library, you can use:
var brushColor:uint;
var blackBrush:brush=new brush();
blackBrush.col = 0x000000;
addChild(blackBrush);
blackBrush.addEventListener(MouseEvent.CLICK,clickF);
function clickF(e:MouseEvent):void{
brushColor = MovieClip(e.currentTarget).col
Similar Messages
-
Convert simple code from as2 to as3
Hello, i am looking for some help here for something simple (i think)
var txt:String = link1;
btn.onRelease = function():Void {
if( sample_id )
getURL("http://www.website.com/registration?partner_id=" + sample_id + "sampleURLCode", "_blank");
else
getURL("http://www.website.com/registration?sampleURLCode", "_blank");
Is there a way to make this simple code into AS3?Hi, Apparantly that's because the 'link1' and 'sample_id' variables are not within the scope of the code you posted above, Perhaps you have defined them outside on a different frame or class. You can either define them with the same code like:
var sample_id:Number=1234; //Use your own variable type and value here
var link1:String = "your string or link URL here";
var txt:String = link1;
btn.addEventListener(MouseEvent.CLICK, gotoURL);
function gotoURL(e:MouseEvent)
if( sample_id )
navigateToURL(new URLRequest("http://www.website.com/registration?sample_id=" + sample_id + "sampleURLCode"),"_blank");
else
navigateToURL(new URLRequest("http://www.website.com/registration?sampleURLCode"),"_blank");
Or you can put a direct reference to your existing variable like (If your variables are defined on root/frame 1) :
var link1:String = "your string or link URL here";
var txt:String = MovieClip(this.root).link1;
btn.addEventListener(MouseEvent.CLICK, gotoURL);
function gotoURL(e:MouseEvent)
if( MovieClip(this.root).sample_id )
navigateToURL(new URLRequest("http://www.website.com/registration?sample_id=" + sample_id + "sampleURLCode"),"_blank");
else
navigateToURL(new URLRequest("http://www.website.com/registration?sampleURLCode"),"_blank");
try that, or you can share your .fla !
cheers -
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!
> -
Please, HELP to convert code from AS2 to AS3!!!
there is source code from paint application, thank to human who will convert this code, it's codeimportant for us.
stop();
var arrSloy:Array = new Array();
//Initial
//OnMove
_root.onMouseMove = function() {
if (checkPole() && onTool) {
Mouse.hide();
_root.kist._visible = true;
_root.eras._visible = true;
_root.pen._visible = true;
_root.line._visible = true;
} else {
Mouse.show();
_root.kist._visible = false;
_root.eras._visible = false;
_root.pen._visible = false;
_root.line._visible = false;
updateAfterEvent();
//OnMove
//New
_root.panelMane.butNew.onRelease = function() {
_root.newClip1.removeMovieClip();
_root.clipMask.removeMovieClip();
onTool = false;
Mouse.show();
_root.pen.removeMovieClip();
_root.line.removeMovieClip();
_root.gotoAndStop("newImg1");
_global.XO = null;
_global.YO = null;
_global.WO = null;
_global.HO = null;
//creatNewPalitra
function creatNewPalitra(color:String, w:Number, h:Number) {
XO = 120;
YO = 130;
WO = w;
HO = h;
gotoAndStop(51);
_root.createEmptyMovieClip("newClip1",0);
newClip1.lineStyle(0,"0xFFFFFF");
newClip1.beginFill(color);
newClip1.moveTo(XO,YO);
newClip1.lineTo(XO+w,YO);
newClip1.lineTo(XO+w,YO+h);
newClip1.lineTo(XO,YO+h);
newClip1.lineTo(XO,YO);
newClip1.endFill();
_root.createEmptyMovieClip("clipMask",1);
clipMask.lineStyle(0,"0xFFFFFF");
clipMask.beginFill("0xFFFFFF");
clipMask.moveTo(XO,YO);
clipMask.lineTo(XO+w,YO);
clipMask.lineTo(XO+w,YO+h);
clipMask.lineTo(XO,YO+h);
clipMask.lineTo(XO,YO);
clipMask.endFill();
newClip1.setMask(clipMask);
function checkPole() {
if (WO == null) {
return false;
if ((_xmouse>=XO && _xmouse<=XO+WO) && (_ymouse>=YO && _ymouse<=YO+HO)) {
return true;
} else {
return false;
//New
_root.panelTool.butCursor.onRelease = function() {
onTool = false;
Mouse.show();
_root.kist.removeMovieClip();
_root.pen.removeMovieClip();
_root.line.removeMovieClip();
//PEN
creatClip = 10;
_root.panelTool.butPen.onRelease = function() {
onTool = true;
_root.attachMovie("pensil","pen",1000000);
Mouse.hide();
_root.pen.startDrag(true);
function drawPen() {
creatClip++;
lineSize = _root.panelProperties.poleSizeLine.text;
lineColor = _root.panelProperties.poleColorLine.text;
lineAlpha = _root.panelProperties.poleAlphaLine.text;
clip = _root.newClip1.createEmptyMovieClip("newClip"+creatClip, creatClip);
arrSloy.push(clip);
_root.pen.onMouseDown = function() {
if (checkPole()) {
drawPen();
pen_draw_flag = true;
clip.lineStyle(lineSize,lineColor,lineAlpha);
clip.moveTo(this._x,this._y);
_root.pen.onMouseUp = function():Void {
pen_draw_flag = false;
_root.pen.onMouseMove = function():Void {
if (pen_draw_flag) {
if (checkPole()) {
clip.lineTo(this._x,this._y);
updateAfterEvent();
//BRUSH
_root.panelTool.butkist.onPress = function() {
onTool = true;
_root.attachMovie("kister","kist",1000000);
Mouse.hide();
_root.kist.startDrag(true);
function drawKist() {
creatClip++;
lineSize = _root.panelProperties.poleSizeLine.text;
lineColor = _root.panelProperties.poleFill.text;
lineAlpha = _root.panelProperties.poleAlphaLine.text;
clip = _root.newClip1.createEmptyMovieClip("newClip"+creatClip, creatClip);
arrSloy.push(clip);
_root.kist.onMouseDown = function() {
if (checkPole()) {
drawKist();
kist_draw_flag = true;
clip.lineStyle(lineSize,lineColor,lineAlpha);
clip.moveTo(this._x,this._y);
_root.kist.onMouseUp = function():Void {
kist_draw_flag = false;
_root.kist.onMouseMove = function():Void {
if (kist_draw_flag) {
if (checkPole()) {
clip.lineTo(this._x,this._y);
updateAfterEvent();
//LINE
_root.panelTool.butLiner.onRelease = function() {
onTool = true;
_root.attachMovie("liner","line",1000000);
_root.line.startDrag(true);
Mouse.hide();
function drawLine() {
creatClip++;
lineSize = _root.panelProperties.poleSizeLine.text;
lineColor = _root.panelProperties.poleColorLine.text;
lineAlpha = _root.panelProperties.poleAlphaLine.text;
clip = _root.newClip1.createEmptyMovieClip("newClip"+creatClip, creatClip);
arrSloy.push(clip);
thisx = thisy=null;
_root.line.onMouseDown = function() {
if (checkPole()) {
drawLine();
line_draw_flag = true;
thisx = this._x;
thisy = this._y;
_root.line.onMouseUp = function():Void {
line_draw_flag = false;
_root.line.onMouseMove = function():Void {
if (line_draw_flag) {
if (checkPole()) {
clip.clear();
clip.lineStyle(lineSize,lineColor,lineAlpha);
clip.moveTo(thisx,thisy);
clip.lineTo(this._x,this._y);
updateAfterEvent();
//ERASER
_root.panelTool.butEras.onPress = function() {
onTool = true;
_root.attachMovie("eraser","eras",1000000);
Mouse.hide();
_root.eras.startDrag(true);
function drawEras() {
creatClip++;
lineSize = _root.panelProperties.poleSizeLine.text;
lineColor = "0xFFFFFF";
lineAlpha = "100";
clip = _root.newClip1.createEmptyMovieClip("newClip"+creatClip, creatClip);
arrSloy.push(clip);
_root.eras.onMouseDown = function() {
if (checkPole()) {
drawEras();
eras_draw_flag = true;
clip.lineStyle(lineSize,lineColor,lineAlpha);
clip.moveTo(this._x,this._y);
_root.eras.onMouseUp = function():Void {
eras_draw_flag = false;
_root.eras.onMouseMove = function():Void {
if (eras_draw_flag) {
if (checkPole()) {
clip.lineTo(this._x,this._y);
updateAfterEvent();
//CURV
_root.panelTool.butCurv.onRelease = function() {
onTool = true;
_root.attachMovie("liner","line",1000000);
_root.line.startDrag(true);
Mouse.hide();
anchor1X = anchor2X=controlX=null;
anchor1Y = anchor2Y=controlY=null;
onClic = 0;
function drawCurv() {
creatClip++;
lineSize = _root.panelProperties.poleSizeLine.text;
lineColor = _root.panelProperties.poleColorLine.text;
lineAlpha = _root.panelProperties.poleAlphaLine.text;
clip = _root.newClip1.createEmptyMovieClip("newClip"+creatClip, creatClip);
arrSloy.push(clip);
_root.line.onMouseDown = function() {
if (onClic == 0) {
if (checkPole()) {
drawCurv();
anchor1X = this._x;
anchor1Y = this._y;
onClic = 1;
_root.attachMovie("point","point1",1000001);
point1._x = anchor1X;
point1._y = anchor1Y;
} else if (onClic == 1) {
if (checkPole()) {
anchor2X = this._x;
anchor2Y = this._y;
onClic = 2;
_root.attachMovie("point","point2",1000002);
point2._x = anchor2X;
point2._y = anchor2Y;
} else if (onClic == 2) {
if (checkPole()) {
controlX = this._x;
controlY = this._y;
onClic = 0;
curv_draw_flag = true;
point1.removeMovieClip();
point2.removeMovieClip();
clip.lineStyle(lineSize,lineColor,lineAlpha);
clip.moveTo(anchor1X,anchor1Y);
clip.curveTo(this._x,this._y,anchor2X,anchor2Y);
_root.line.onMouseUp = function():Void {
curv_draw_flag = false;
_root.line.onMouseMove = function():Void {
if (curv_draw_flag) {
if (checkPole()) {
clip.clear();
clip.lineStyle(lineSize,lineColor,lineAlpha);
clip.moveTo(anchor1X,anchor1Y);
clip.curveTo(this._x,this._y,anchor2X,anchor2Y);
updateAfterEvent();
//STAR
_root.panelTool.butStar.onRelease = function() {
onTool = true;
_root.attachMovie("liner","line",1000000);
Mouse.hide();
_root.line.startDrag(true);
function drawStar() {
creatClip++;
lineSize = _root.panelProperties.poleSizeLine.text;
lineColor = _root.panelProperties.poleColorLine.text;
lineAlpha = _root.panelProperties.poleAlphaLine.text;
clip = _root.newClip1.createEmptyMovieClip("newClip"+creatClip, creatClip);
arrSloy.push(clip);
thisx = thisy=null;
_root.line.onMouseDown = function() {
if (checkPole()) {
drawStar();
star_draw_flag = true;
clip.lineStyle(lineSize,lineColor,lineAlpha);
thisx = this._x;
thisy = this._y;
clip.moveTo(thisx,thisy);
_root.line.onMouseUp = function():Void {
star_draw_flag = false;
_root.line.onMouseMove = function():Void {
if (star_draw_flag) {
if (checkPole()) {
clip.moveTo(thisx,thisy);
clip.lineTo(this._x,this._y);
updateAfterEvent();
//KVADRAT
_root.panelTool.butRecttangle.onRelease = function() {
onTool = true;
_root.attachMovie("liner","line",1000000);
_root.line.startDrag(true);
Mouse.hide();
function drawRecttangle() {
creatClip++;
lineSize = _root.panelProperties.poleSizeLine.text;
lineColor = _root.panelProperties.poleColorLine.text;
lineAlpha = _root.panelProperties.poleAlphaLine.text;
fillColor = _root.panelProperties.poleFill.text;
clip = _root.newClip1.createEmptyMovieClip("newClip"+creatClip, creatClip);
arrSloy.push(clip);
thisx = thisy=null;
_root.line.onMouseDown = function() {
if (checkPole()) {
drawRecttangle();
kvadrat_draw_flag = true;
thisx = this._x;
thisy = this._y;
_root.line.onMouseUp = function():Void {
kvadrat_draw_flag = false;
_root.line.onMouseMove = function():Void {
if (kvadrat_draw_flag) {
if (checkPole()) {
clip.clear();
clip.lineStyle(lineSize,lineColor,lineAlpha);
clip.beginFill(fillColor,lineAlpha);
clip.moveTo(thisx,thisy);
clip.lineTo(this._x,thisy);
clip.lineTo(this._x,this._y);
clip.lineTo(thisx,this._y);
clip.lineTo(thisx,thisy);
clip.endFill();
updateAfterEvent();
//Clear
_root.panelMane.butClear.onRelease = function() {
for (a=0; a<arrSloy.length; a++) {
clip = arrSloy[a];
clip.removeMovieClip();
delete arrSloy[a];
//Back
_root.panelMane.butBack.onRelease = function() {
i = arrSloy.length-1;
clip = arrSloy[i];
clip.removeMovieClip();
arrSloy.pop();
Thank you very much!!!Zhanbolat,
In theory, conversion of this code is not difficult, especially because it is clear what the logic is designed to do. The issue is that you will not have an expected result once only this code is converted in isolation. This puppy uses some other objects that are written in AS2 including entities in the FLA library.
In short, it looks like this application needs a total overhaul at every level in order for it to properly function as an AS3 program.
With that said, although this is, again, not a difficult task, it is unlikely to find someone to do it for free. You may have a better luck if you start conversion yourself and post focused questions as you go. -
Convert simple animation code from as2 to as3
Hi everyone,
I have a simple animation that is controlled by the y movement of the mouse. The code for the animation is put in frame 1 and is as follows:
var animationDirection:Boolean = false;
var prevMousePosition:Boolean = false;
var mouseListener = new Object();
mouseListener.onMouseMove = function () {
var curMousePosition = _ymouse;
if(curMousePosition > prevMousePosition) {
animationDirection = false;
}else if(curMousePosition < prevMousePosition) {
animationDirection = true;
prevMousePosition = curMousePosition;
Mouse.addListener(mouseListener);
function onEnterFrame() {
if(animationDirection && _currentframe < _totalframes) {
nextFrame();
}else if(!animationDirection && _currentframe > 1) {
prevFrame();
Is it possible to use this code in as3 or do I need to convert it? I am grateful for any help. Best wishesYes, you need to convert the code. Here is what looks like a similar logic in AS3:
import flash.events.Event;
import flash.events.MouseEvent;
var animationDirection:Boolean = false;
var prevMousePosition:Boolean = false;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
function onMouseMove(e:MouseEvent):void {
var curMousePosition = mouseX;
if (curMousePosition > prevMousePosition)
animationDirection = false;
else if (curMousePosition < prevMousePosition)
animationDirection = true;
prevMousePosition = curMousePosition;
function onEnterFrame(e:Event):void
if (animationDirection && _currentframe < _totalframes)
nextFrame();
else if (!animationDirection && _currentframe > 1)
prevFrame(); -
Converting code from as2 to as3 and getting errors
I am trying to get a counter that I found in as2 to work in as3 but I am getting errors when I publish.
Here is my code:
stop();
var currSlide;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(evt:Event):void
currSlide = root.rdinfoCurrentSlide +1;
this.curSlide_txt.text = currSlide;
this.totSlide_txt.text = root.rdinfoSlideCount;
any suggestions?no code should be attached to objects.
most of that looks like it's useless or worse than useless. in particular, everything in the enterframe loop looks like it serves no purpose and repeatedly does useless things. if it is doing something useful, it doesn't need to be done in a loop.
and setting the rgb of a color instance does nothing useful.
the only thing useful is setting brushColor when that brush movieclip is clicked.
so, if you have a movieclip with class = "brush" in your library, you can use:
var brushColor:uint;
var blackBrush:brush=new brush();
blackBrush.col = 0x000000;
addChild(blackBrush);
blackBrush.addEventListener(MouseEvent.CLICK,clickF);
function clickF(e:MouseEvent):void{
brushColor = MovieClip(e.currentTarget).col -
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; -
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. -
Converting small amount of AS2 to AS3
Hi All,
I’m struggling to convert this block of AS2 code into AS3. It is a Netstream video component and I have made the scrubber able to be dragged anywhere inside the player. (Vertical and Horizontal). The scrubber is also coded so that it controls the frame position of the player (I have links that appear at certain points to load in other videos)
Here is the as2 version; http://websites.danielnwilliams.co.uk/crankmedia/
Im just trying to convert this as2 code to as3;
MovieClip.prototype.scrubbb2 = function (x)
var f2:Number = Math.round (this._totalframes * x);
this.gotoAndStop (f2);
var isPlaying2:Boolean = true;
var scrubInterval2;
function scrubit2() {
ns2.seek(Math.floor((scrubmain.scrubbuttonmain._x/760) * duration2));
scrubmain.scrubbuttonmain.onPress = function() {
ns2.pause();
if (isPlaying2) {
ns2.pause(true);
scrubmain.scrubbuttonmain.cog_pausemain._visible = true;
scrubmain.scrubbuttonmain.cog_playmain._visible = false;
trace("paused");
isPlaying2 = false;
} else {
ns2.pause(false);
scrubmain.scrubbuttonmain.cog_pausemain._visible = false;
scrubmain.scrubbuttonmain.cog_playmain._visible = true;
trace("playing");
isPlaying2 = true;
clearInterval(videoInterval2);
scrubInterval2 = setInterval(scrubit2,10);
this.startDrag(false,0,-392,760,0);
this.onMouseMove = function()
var x:Number = this._x;
scrubbb2 (x / 760);
scrubmain.scrubbuttonmain.onRelease = scrubmain.scrubbuttonmain.onReleaseOutside = function () {
clearInterval(scrubInterval2);
videoInterval2 = setInterval(videoStatus2,100);
this.stopDrag();
Finding this chunk really hard to to so, so would really appreciate it if someone could help me out!
Much appreciated
DanIt is unlikely that someone would be able/willing to attempt the full conversion. No only it is time consuming - there are some things in your AS2 version that are not straight forward.
Here is a link that may help you:
http://livedocs.adobe.com/flex/201/langref/index.html?migration.html&all-classes.html
Also, read about MouseEvent for this is how you enable buttons functionality. -
Preloader (from as2 to as3)
Hey ladies and gentlemen
I'm currently converting one of my project to as3 and I hit a
wall with this preloader problem.
Before, with as2, I was using getBytesLoaded() and
getBytesTotal() in a frame loop to display a progress bar and know
when the loading was finished. I can't seem to find how to do this
in as3.
I read as3 language reference and some examples but they all
deal with loading an external swf or file.
I would think that the main swf would trigger progress events
as it gets loaded so I made this little piece of code, which
doesn't work.
function ProgressHandler(theEvent:ProgressEvent)
trace("bytes Loaded: " + theEvent.bytesLoaded + "
bytesTotal: " + theEvent.bytesTotal);
addEventListener(ProgressEvent.PROGRESS, ProgressHandler);
stop();
Can anyone point me back in the right direction?
ThanksI just wanna make it clear that I'm trying to preload the
main swf itself, I still can't find anything on the net about that.
Anyone?
Thanks! -
How to convert the code from 8.2 to 7.1
Hello friends
I have to convert the one vi from 8.2 to 7.1 Version.How to convert this code.
JayavelHello Friends
i attached the code in 8.2 version.Convert this code into 7.1
Jayavel
Attachments:
FreenrunTest.vi 1456 KB -
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. -
How do you convert this code from AS3 to AS2?
Hi,
I created some AS3 code that is working perfectly for us.
However now we need to convert it to AS2 so that it can be Flash
Player 8 compatible. If it could also be compatible for Flash
Player 7 that would be ideal but not a requirement.
Thanks in advance.Are you wanting someone to do the conversion for you, or are
you asking for general tips for doing the conversion yourself?
i can give you tips:
have a look at the
ActionScript
2.0 Migration page.
In this you'll find the property conversions eg(going from
AS3 to AS2). y becomes _y, height becomes _height, scaleX becomes
_xscale, void becomes Void etc.
you'll find that events need to be converted, eg.
particle.addEventListener(Event.ENTER_FRAME,
animateParticle);
becomes:
particle.onEnterFrame=animateParticle;
the onEnterFrame class doesn't pass an Event parameter to the
event listener. Instead, the event listener is automatically in the
scope of the event dispatcher, so instead of 'event.target' you
will be able to just target 'this'.
You'll need to use setInterval() instead of the Timer class.
You'll need to use attachMovie() instead of
addChild(). -
Hi.
Below I have a bit of code that determines the bandwidth that a user has. It is written in ActionScript 2. The problem is that I am unfamiliar with AS2, and I wanted to use this in conjunction with a live streaming video player built in AS3. I was wondering if anyone could give me the equivalent code in AS3, or if there's any way to tell flash that a portion of the code will be written in AS2.
Thank You,
Ari Amiri
nc = new NetConnection();
nc.onStatus = function(info) {
trace("Level: "+info.level+" Code: "+info.code);
if (info.code == "NetConnection.Connect.Success") {
trace("--- connected to: " + this.uri);
nc.onBWDone = function(kbitDown, deltaDown, deltaTime, latency) {
trace("onBWDone: kbitDown:"+kbitDown+" deltaDown:"+deltaDown+" deltaTime:"+deltaTime+" latency:"+latency);
// app logic based on the bandwidth detected follows here
detected_bw = kbitDown;
// close the Netconnection to bwcheck
this.close();
nc.onBWCheck = function() {
trace("onBWCheck");
return ++counter; // Serverside, just ignore any return value, For now return the call count
nc.connect("rtmp://localhost/bwcheck", true);
stop();Yah very important point from NetDragon. As of version 3.0
the netconnection " class was dynamic in ActionScript 2.0 but is
now sealed. " so you can't just do something like:
netconnection.client.somefunction = function() {...}
The default netconnection.client = this, so you need to
extend it with a custom class or an object to be able to add
callback functions
But be careful, I wrote an entire app that worked with the
AS2.0 technique ...without an error from the compiler.....(flex
2.0). -
EventListener...: From AS2 to AS3..?
I'm trying to rewrite som AS2 code so it will fit to AS3 but
some minor problem occurs...
Here's the AS2 code:
panel.onRollOver = panelOver;
function panelOver() {
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
The idea here is to create an EventListener in AS3 that will
trigger when the pointer is rolling over the movieclip "panel".
So far, so good...
Here's the AS3 code so far:
panel.addEventListener(MouseEvent.MOUSE_OVER, panelOver);
function panelOver(myEvent:MouseEvent):void {
this.onEnterFrame = scrollPanel;
Now, the problem is to rewrite [delete this.onRollOver;] so
it will work in AS3...
Could it be something like:
delete this.EventListener(panel)?
I'm really struggling these days finding my way through AS3
but I do feel that I'm starting to get a hang of it...
Thank you for any help I get...!
PS.
I think I might run into some more problems after solving
this one.. But we're all here to learn, aren't we?panel.removeEventListener(MouseEvent.MOUSE_OVER, panelOver);
(parameters should match as in addEventListener)
delete doesn't work.
this.onEnterFrame = scrollPanel; wont work either. infact
there is nothing called onEnterFrame in AS3..
it would be like
this.addEventListener(Event.ENTER_FRAME, scrollPanel);
Maybe you are looking for
-
Windows XP or Window 7 installation problem through bootcamp
Hi, I tried to install Window XP through boot camp and successfully made partition, boot the xp cd and copies all the windows installation files on NTFS drive. After restarting system for installation it gives error system32/hal.dll file not found. C
-
What kind of cable I need ?
I want to connect my Mac mini with my monitor ....I will do this via the hdmi to dvi adapter that's given with the mac. My monitor has a dvi output , so I will connect it with a dvi cable via the adapter.the question is, do I need a single link or du
-
How do I fix error code MZCommerce.JmsSendError_message
When I tried to update Clash of Clans this morning, I got the error, "MZCommerce.JmsSendError_Message." Of course, I went to my computer to try to do the update. When I try it there, I get error code "11111." It will not allow me to update any of my
-
Page 5 problem with some word documents (Page 4.3 fine)
Pages 5.0 (newest version) is unable to open some of my word documents. It is impossible for me to predict which file will cause problem and the error (typical Apple) does ot help at all: "The document cannot be opened". The documents that cannot ope
-
Hi all, I have been working for years with RV042 and RV082 routers wihout any problem. Now, I have set up a RV082 connected to a router (cisco) from my Internet provider (Fiber) that provides 30Mb. I am unable to download more than 10Mb/s. I can upl