Trying to convert as1 code to as3
Hi,
I have to convert a as1 site to as3.
The only part of the whole thing that i'm not sure of is this:
on(release){
loadvariables ("save.aspx?cmd=addemail&adresse=" add string(adresse.text),this)
Object.prototype.alert = function (message) {
getURL("javascript:alert('"+message+"')");
alert("We received your email, thank you.");
adresse.text="";
It's basically a newsletter subscription box done in as1.
Will the same code work if I only include it in a as3 MouseEvent.CLICK like this:
function btn_click(event:MouseEvent):void {
loadvariables ("save.aspx?cmd=addemail&adresse=" add string(adresse.text),this)
Object.prototype.alert = function (message) {
getURL("javascript:alert('"+message+"')");
alert("We received your email, thank you.");
adresse.text="";
Thanks
Thanks Ned for guiding me.
I looked into both (URLLoader / ExternalInterface) and I came up converting the original As1 code:
on(release){
loadvariables ("save.aspx?cmd=addemail&adresse=" add string(Adresse.text),this)
Object.prototype.alert = function (message) {
getURL("javascript:alert('"+message+"')");
alert("We received your email, thank you.");
Adresse.text="";
into this As3 code:
lbl.text = "ExternalInterface.available: " + ExternalInterface.available;
var myLoader:URLLoader;
var myVars:URLVariables;
var Response:String = "We received your email, thank you.";
//////////////////////////////////////////////////////////////////////////////This is my button
button.enabled = ExternalInterface.available;
button.addEventListener(MouseEvent.CLICK, sendEmail);
/////////////////////////////////////////////////////////////////////This is Onclick
function sendEmail(e:MouseEvent):void
myLoader = new URLLoader();
myVars = new URLVariables();
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
myVars.email = Adresse.text; // Text from textfield
myLoader.data = myVars;
myLoader.addEventListener(Event.COMPLETE, messageSent, false, 0, true);
myLoader.load(new URLRequest("save.aspx?cmd=addemail&adresse="+myVars.email));
///////////////////////////////////////////////////////////////This is the response
function messageSent(e:Event):void
ExternalInterface.call("alert", Response);
Adresse.text="";
The thing is that I don't have access to the server and aspx file and i'd just like to make sure i'm heading in the right direction so far.
Similar Messages
-
Trying to convert AS2 code to AS3
I had this code in AS2 and it worked I am trying to convert
it to AS3 however and am stuck Please Help!!
Thanks,
Alexjust add your click listeners and handlers:
-
Dummy Guide needed for converting AS2 code into AS3
I have to convert my existing AS2 code into AS3, but I might as well be reading chinese. I never even began to learn AS3, it was still fairly new at the time and the class ended before we had an opportunity to even touch on it. My major was not web design, it was the print side of design. I took an additional class, after I graduated, to learn web design and our teacher told us, basically, that we were designers, not coders so we won't be getting much into actionscripting, beyond the basics. At the time I was relieved, but looking back, I really wish we would have gotten more into it. Bottom line, I need to learn now.
Is there ANYONE that can help me out? I will list my code below, buy I am way beyond lost any help that can be provided, I would be so grateful!!!!
On the main timeline I have the basic..
stop(); -- I found the AS3 version, but I don't know what I'm looking at. I get "not_yet_set.stop()" and there are are 8 options I can choose from. I just want the timeline to stop until I tell it where to go next. And what is "not_yet_set"
Then I have my buttons, which are, basically...
on (release) {
gotoAndStop("Home");
Or "gotoAndPlay("Whatever");"
I also have buttons for scrolling...
on (press) {
play();
on (release) {
stop();
AND
on (press) {
_root.AboutMe_Controller.gotoAndPlay(…
on (release) {
_root.AboutMe_Controller.gotoAndStop(…
For the on(release) command, this is what I found as the AS3 version: not_set_yet.dispatchEvent()because that's really as1 code, you have steeper learning curve than going from as2 to as3.
first, remove all code from objects, assign instance names to your buttons and you can then start on as3:
// so, if you name your home button, home_btn:
home_btn.addEventListener(MouseEvent.CLICK,homeF);
function homeF(e:MouseEvent):void{
gotoAndStop("Home");
p.s. the not_yet_set stuff is there because you tried to use script assist or some other actionscript shortcut. -
Can AS1 code call AS3 code?
I was wondering if there was any way for AS1 code to call AS3
code.
I need to write a server extension for SmartFox Pro. I just
found out that the only version of action script that SmartFox
sever extensions can be written in is AS1. However, I have a bunch
of code already written in AS3 that I need to use. I have all of
the source for the AS3 code.
Is there a way for me to use my existing code, or am I out of
luck?
Thanks in advance
John Lawrieyou may be able to use swfbridge to do so, basically
implementing the LocalConnection class
http://www.gskinner.com/blog/archives/2007/07/swfbridge_easie.html -
Please help me to convert this code..............
for (i = 1; i <= nextballs; i++)
nextarray[i] = new Array(0, 0, 0);
attachMovie("balls", "nextballs" + i, kkk++);
_loc2.inGame["nextballs" + i]._x = xnext;
_loc2.inGame["nextballs" + i]._y = ynext + i * 60;
_loc2.inGame["nextballs" + i]._xscale = 140;
_loc2.inGame["nextballs" + i]._yscale = 140;var nextballs:int = 4; // <- nextballs needs to be defined, though need not be defined this way.
for (var i:int = 1; i <= nextballs; i++)
var nextarray[i]:Array = new Array(0, 0, 0);
this["nextballs"+i]=new balls();
addChild(this["ballballs"+i]);
// xnext and ynext need to be defined and should probably be updated in this for-loop
// this part of your code makes no sense given your attachMovie() statement.
_loc2.inGame["nextballs" + i].x = xnext;
_loc2.inGame["nextballs" + i].y = ynext + i * 60;
_loc2.inGame["nextballs" + i].scaleX = 1.4;
_loc2.inGame["nextballs" + i].scaleY = 1.4; -
Convert as2 code to as3 please help
function fDieList()
if (pDieList.length > 0)
_root.inSFX.die.start();
for (var _loc2 = 0; _loc2 <= pDieList.length; ++_loc2)
pDieList[_loc2].fDie();
} // end of for
pDieList = [];
actioner.pKills = true;
} // end if
} // End of the function
function fDieListSetup()
if (pDieList.length > 0)
for (var _loc1 = 0; _loc1 <= pDieList.length; ++_loc1)
pDieList[_loc1].fDieSetup();
} // end of for
} // end if
} // End of the function
function recur(fromx, fromy, tox, toy)
var _loc2 = fromy;
var _loc1 = fromx;
var _loc3 = toy;
if (_loc1 == tox && _loc2 == _loc3)
return (true);
else
++len;
drum[len][0] = _loc1;
drum[len][1] = _loc2;
wa[_loc1][_loc2] = 1;
if (_loc1 > tox && _loc2 > _loc3)
if (_loc1 > 1 && wa[_loc1 - 1][_loc2] == 0)
ok = recur(_loc1 - 1, _loc2, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc2 > 1 && wa[_loc1][_loc2 - 1] == 0)
ok = recur(_loc1, _loc2 - 1, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc1 < limits && wa[_loc1 + 1][_loc2] == 0)
ok = recur(_loc1 + 1, _loc2, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc2 < limits && wa[_loc1][_loc2 + 1] == 0)
ok = recur(_loc1, _loc2 + 1, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
else if (_loc1 <= tox && _loc2 > _loc3)
if (_loc2 > 1 && wa[_loc1][_loc2 - 1] == 0)
ok = recur(_loc1, _loc2 - 1, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc1 < limits && wa[_loc1 + 1][_loc2] == 0)
ok = recur(_loc1 + 1, _loc2, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc2 < limits && wa[_loc1][_loc2 + 1] == 0)
ok = recur(_loc1, _loc2 + 1, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc1 > 1 && wa[_loc1 - 1][_loc2] == 0)
ok = recur(_loc1 - 1, _loc2, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
else if (_loc1 > tox && _loc2 <= _loc3)
if (_loc1 > 1 && wa[_loc1 - 1][_loc2] == 0)
ok = recur(_loc1 - 1, _loc2, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc2 < limits && wa[_loc1][_loc2 + 1] == 0)
ok = recur(_loc1, _loc2 + 1, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc1 < limits && wa[_loc1 + 1][_loc2] == 0)
ok = recur(_loc1 + 1, _loc2, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc2 > 1 && wa[_loc1][_loc2 - 1] == 0)
ok = recur(_loc1, _loc2 - 1, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
else
if (_loc2 < limits && wa[_loc1][_loc2 + 1] == 0)
ok = recur(_loc1, _loc2 + 1, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc1 < limits && wa[_loc1 + 1][_loc2] == 0)
ok = recur(_loc1 + 1, _loc2, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc2 > 1 && wa[_loc1][_loc2 - 1] == 0)
ok = recur(_loc1, _loc2 - 1, tox, _loc3);
if (ok)
return (ok);
} // end if
} // end if
if (_loc1 > 1 && wa[_loc1 - 1][_loc2] == 0)
ok = recur(_loc1 - 1, _loc2, tox, _loc3);
if (ok)
return (ok);
} // end else if
} // end else if
} // end else if
--len;
return (ok);
} // end else if
} // End of the function
function way(fromx, fromy, tox, toy)
len = 0;
ok = false;
for (i = 1; i <= limits; i++)
for (j = 1; j <= limits; j++)
wa[i][j] = ma[i][j];
} // end of for
} // end of for
wa[fromx][fromy] = 0;
return (recur(fromx, fromy, tox, toy));
} // End of the function
function init()
var _loc2 = _root;
scorerule = new Array(40, 50, 60, 70, 80);
score = 0;
totalballs = 7;
nextballs = 3;
limits = 9;
kkk = 1000;
xnext = next1._x - 19;
ynext = next1._y + 21;
ballsput = 0;
drum = new Array();
wa = new Array();
st = new Array();
for (i = 1; i <= limits * limits; i++)
drum[i] = new Array(0, 0);
} // end of for
for (i = 1; i <= limits * limits; i++)
wa[i] = new Array(limits + 1);
} // end of for
selected = new Array(0, 0);
ma = new Array();
for (i = 1; i <= limits; i++)
ma[i] = new Array(limits + 1);
for (j = 1; j <= limits; j++)
ma[i][j] = 0;
_loc2.inGame["balls" + i + j].x = i;
_loc2.inGame["balls" + i + j].y = j;
} // end of for
} // end of for
nextarray = new Array();
for (i = 1; i <= nextballs; i++)
nextarray[i] = new Array(0, 0, 0);
attachMovie("balls", "nextballs" + i, kkk++);
_loc2.inGame["nextballs" + i]._x = xnext;
_loc2.inGame["nextballs" + i]._y = ynext + i * 60;
_loc2.inGame["nextballs" + i]._xscale = 140;
_loc2.inGame["nextballs" + i]._yscale = 140;
} // end of for
actioner2.swapDepths(20000);
} // End of the function
function generatenext()
var _loc2 = _root;
if (ballsput <= 81 - nextballs)
togenerate = nextballs;
else
togenerate = 81 - ballsput;
} // end else if
for (i = 1; i <= togenerate; i++)
do
x = random(limits) + 1;
y = random(limits) + 1;
} while (ma[x][y] != 0)
nextarray[i][0] = random(totalballs) + 1;
nextarray[i][1] = x;
nextarray[i][2] = y;
_loc2.inGame["nextballs" + i].gotoAndStop(nextarray[i][0] + 1);
_loc2.inGame["nextballs" + i].buton._visible = false;
} // end of for
for (i = togenerate + 1; i <= nextballs; i++)
_loc2.inGame["nextballs" + i].gotoAndStop("blank");
} // end of for
nextballs3.buton._visible = false;
} // End of the function
function putnextballs()
var _loc2 = _root;
_loc2.inSFX.grow.start();
if (ballsput <= 81 - nextballs)
togenerate = nextballs;
else
togenerate = 81 - ballsput;
} // end else if
for (i = 1; i <= togenerate; i++)
if (ma[nextarray[i][1]][nextarray[i][2]] == 0)
ma[nextarray[i][1]][nextarray[i][2]] = nextarray[i][0];
else
do
x = random(limits) + 1;
y = random(limits) + 1;
} while (ma[x][y] != 0)
nextarray[i][1] = x;
nextarray[i][2] = y;
ma[nextarray[i][1]][nextarray[i][2]] = nextarray[i][0];
} // end else if
_loc2.inGame["balls" + nextarray[i][1] + nextarray[i][2]].gotoAndStop(nextarray[i][0] + 1);
line(nextarray[i][1], nextarray[i][2], ma[nextarray[i][1]][nextarray[i][2]]);
} // end of for
ballsput = ballsput + togenerate;
if (ballsput == limits * limits)
_loc2.fEndGame();
} // end if
} // End of the function
function line(x, y, c)
var _loc4 = 0;
var _loc6 = new Array();
var _loc5 = new Array();
var _loc2 = new Array();
var _loc3 = new Array();
for (var _loc4 = 1; _loc4 <= limits; ++_loc4)
_loc6[_loc4] = new Array(2);
_loc5[_loc4] = new Array(2);
_loc2[_loc4] = new Array(2);
_loc3[_loc4] = new Array(2);
} // end of for
var _loc7 = 0;
fl = 0;
for (var _loc4 = 1; _loc4 <= limits; ++_loc4)
if (ma[_loc4][y] == c)
if (fl == 0)
++_loc7;
_loc6[_loc7][0] = _loc4;
_loc6[_loc7][1] = y;
} // end if
continue;
} // end if
if (_loc7 < 4)
_loc7 = 0;
continue;
} // end if
fl = 1;
} // end of for
st1 = 0;
fl = 0;
for (var _loc4 = 1; _loc4 <= limits; ++_loc4)
if (ma[x][_loc4] == c)
if (fl == 0)
++st1;
_loc5[st1][0] = x;
_loc5[st1][1] = _loc4;
} // end if
continue;
} // end if
if (st1 < 4)
st1 = 0;
continue;
} // end if
fl = 1;
} // end of for
fl = 0;
st2 = 0;
imin = x;
for (jmin = y; imin > 1 && jmin > 1; jmin--)
--imin;
} // end of for
imax = x;
for (jmax = y; imax < limits && jmax < limits; jmax++)
++imax;
} // end of for
if (imin == 1)
for (var _loc4 = imin; _loc4 <= imax; ++_loc4)
if (ma[_loc4][jmin + _loc4 - 1] == c)
if (fl == 0)
++st2;
_loc2[st2][0] = _loc4;
_loc2[st2][1] = jmin + _loc4 - 1;
} // end if
continue;
} // end if
if (st2 < 4)
st2 = 0;
continue;
} // end if
fl = 1;
} // end of for
else
for (var _loc4 = jmin; _loc4 <= jmax; ++_loc4)
if (ma[imin + _loc4 - 1][_loc4] == c)
if (fl == 0)
++st2;
_loc2[st2][0] = imin + _loc4 - 1;
_loc2[st2][1] = _loc4;
} // end if
continue;
} // end if
if (st2 < 4)
st2 = 0;
continue;
} // end if
fl = 1;
} // end of for
} // end else if
fl = 0;
st3 = 0;
imin = x;
for (jmin = y; imin > 1 && jmin < limits; jmin++)
--imin;
} // end of for
imax = x;
for (jmax = y; imax < limits && jmax > 1; jmax--)
++imax;
} // end of for
if (imin == 1)
for (var _loc4 = imin; _loc4 <= imax; ++_loc4)
if (ma[_loc4][jmin - _loc4 + 1] == c)
if (fl == 0)
++st3;
_loc3[st3][0] = _loc4;
_loc3[st3][1] = jmin - _loc4 + 1;
} // end if
continue;
} // end if
if (st3 < 4)
st3 = 0;
continue;
} // end if
fl = 1;
} // end of for
else
for (var _loc4 = jmax; _loc4 <= jmin; ++_loc4)
if (ma[jmin - _loc4 + jmax][_loc4] == c)
if (fl == 0)
++st3;
_loc3[st3][0] = jmin - _loc4 + jmax;
_loc3[st3][1] = _loc4;
} // end if
continue;
} // end if
if (st3 < 4)
st3 = 0;
continue;
} // end if
fl = 1;
} // end of for
} // end else if
destroyed = 0;
if (_loc7 >= 4)
for (var _loc4 = 1; _loc4 <= _loc7; ++_loc4)
pDieList.push(_root.inGame["balls" + _loc6[_loc4][0] + _loc6[_loc4][1]]);
ma[_loc6[_loc4][0]][_loc6[_loc4][1]] = 0;
} // end of for
destroyed = destroyed + _loc7;
score = score + scorerule[_loc7 - 4];
} // end if
if (st1 >= 4)
for (var _loc4 = 1; _loc4 <= st1; ++_loc4)
pDieList.push(_root.inGame["balls" + _loc5[_loc4][0] + _loc5[_loc4][1]]);
ma[_loc5[_loc4][0]][_loc5[_loc4][1]] = 0;
} // end of for
destroyed = destroyed + st1;
score = score + scorerule[st1 - 4];
} // end if
if (st2 >= 4)
for (var _loc4 = 1; _loc4 <= st2; ++_loc4)
pDieList.push(_root.inGame["balls" + _loc2[_loc4][0] + _loc2[_loc4][1]]);
ma[_loc2[_loc4][0]][_loc2[_loc4][1]] = 0;
} // end of for
destroyed = destroyed + st2;
score = score + scorerule[st2 - 4];
} // end if
if (st3 >= 4)
for (var _loc4 = 1; _loc4 <= st3; ++_loc4)
pDieList.push(_root.inGame["balls" + _loc3[_loc4][0] + _loc3[_loc4][1]]);
ma[_loc3[_loc4][0]][_loc3[_loc4][1]] = 0;
} // end of for
destroyed = destroyed + st3;
score = score + scorerule[st3 - 4];
} // end if
if (destroyed >= 10)
--destroyed;
} // end if
ballsput = ballsput - destroyed;
scoretxt = score;
if (destroyed != 0)
fDieListSetup();
_root.inSFX.pickup.start();
} // end if
return (destroyed != 0);
} // End of the function
function fromactioner(fromx, fromy, tox, toy)
var _loc3 = toy;
var _loc2 = tox;
var _loc4 = fromy;
ma[_loc2][_loc3] = ma[fromx][_loc4];
ma[fromx][_loc4] = 0;
_root.inGame["balls" + fromx + _loc4].gotoAndStop("blank");
_root.inGame["balls" + fromx + _loc4].ball.gotoAndStop(1);
_root.inGame["balls" + _loc2 + _loc3].gotoAndStop(ma[_loc2][_loc3] + 1);
_root.inGame["balls" + _loc2 + _loc3].ball.gotoAndStop(1);
selected[0] = 0;
selected[1] = 0;
line(_loc2, _loc3, ma[_loc2][_loc3]);
actioner.gotoAndPlay(2);
} // End of the function
function move(fromx, fromy, tox, toy)
var _loc2 = _root;
var _loc3 = false;
if (way(fromx, fromy, tox, toy))
_loc3 = true;
fromactioner(fromx, fromy, tox, toy);
_loc2.inGame["balls" + _loc2.inGame.drum[ii][0] + _loc2.inGame.drum[ii][1]].gotoAndStop("blank");
} // end if
return (_loc3);
} // End of the function
function movetest(fromx, fromy, tox, toy)
var _loc1 = false;
if (way(fromx, fromy, tox, toy))
_loc1 = true;
} // end if
return (_loc1);
} // End of the function
pLastClicked = "none";
pLastClickedType = 1;
pClicked = false;
pDieList = [];
init();
generatenext();
putnextballs();
generatenext();
stop ();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. -
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(). -
Help! Convert simple Flash AS2 code to AS3
Hi everyone,
I'm a Flash beginner and followed a tutorial: http://www.webwasp.co.uk/tutorials/018/tutorial.php ... to learn how to make a "live paint/draw" effect. I didn't realize that if I made something in AS2, I wouldn't be able to embed it (and have it work) into my root AS3 file, where I've got a bunch of other stuff going on. I've tried following tips on how to change AS2 code to AS3, but it just doesn't work. I know it's simple code, and that some genius out there can figure it out, but I'm at a loss. Please help!
Here's the AS2 code:
_root.createEmptyMovieClip("myLine", 0);
_root.onMouseDown = function() {
myLine.moveTo(_xmouse, _ymouse);
ranWidth = Math.round((Math.random() * 10)+2);
myLine.lineStyle(ranWidth, 0xff0000, 100);
_root.onMouseMove = function() {
myLine.lineTo(_xmouse, _ymouse);
_root.onMouseUp = function() {
_root.onMouseMove = noLine;
Thanks in advance!
Signed,
Nicolle
Flash DesperadoConsidering the code is on timeline:
var myLine:Sprite = new Sprite();
addChild(myLine);
var g:Graphics = myLine.graphics;
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
function onMouseDown(e:MouseEvent):void {
var ranWidth:Number = Math.round((Math.random() * 10) + 2);
g.clear();
g.lineStyle(ranWidth, 0xFF0000, 1);
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
function onMouseMove(e:MouseEvent):void {
g.lineTo(mouseX, mouseY);
function onMouseUp(e:MouseEvent):void {
removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); -
Hello guys.
Could you help me to take this code to as3?
Thanks
on (press) {
i = Number(i)+1;
duplicateMovieClip("/circle", "circle" add i, i);
setProperty("circle" add i, _x, getProperty("/mousexy", _x));
setProperty("circle" add i, _y, getProperty("/mousexy", _y));i created a CircleClass.as and put inside this code
package
public class CircleClass
public function CircleClass()
after that i put in .fla the code you told me
stage.addEventListener(MouseEvent.MOUSE_DOWN,f);
function f(e:Event):void{
var circle_mc:CircleClass=new CircleClass();
addChild(circle_mc);
circle_mc.x=e.stageX;
circle_mc.y=e.stageY;
I got this error
TypeError: Error #1034: Type Coercion failed: cannot convert CircleClass@2ec2f31 to flash.display.DisplayObject.
at movt_fla::MainTimeline/f()[movt_fla.MainTimeline::frame1:9] -
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 -
I have a code that I wrote in AS2 and I am now trying to
convert it into AS3 . . . When I converted it this is what I came
up with but I can still not get it to work.
Can someone help me fix it? I used a coverter for some of it
http://www.5etdemi.com/convert/index.php
. . . does anyone know of a better one?
Thanks for any help fixing the code:
-
Hi,
I have a problem with an PropertyGrid enum property that uses a type converter.
In general it works, but when I double clicking or using the scoll wheel, an error message appears:
"Property value is not valid"
Details: "Object of type 'System.String' cannot be converted to type 'myCompany.myProject.CC_myCustomProperty."
I noticed that the CommitValue method (in PropertyGridView.cs) tries to convert a string value to a CC_myCustomProperty object.
Here is the code that causes the error (see line 33):
(Using the .net symbols from the PropertyGridView.cs file)
1
internal bool CommitValue(GridEntry ipeCur, object value) {
2
3
Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose, "PropertyGridView:CommitValue(" + (value==null ? "null" :value.ToString()) + ")");
4
5
int propCount = ipeCur.ChildCount;
6
bool capture = Edit.HookMouseDown;
7
object originalValue = null;
8
9
try {
10
originalValue = ipeCur.PropertyValue;
11
12
catch {
13
// if the getter is failing, we still want to let
14
// the set happen.
15
16
17
try {
18
try {
19
SetFlag(FlagInPropertySet, true);
20
21
//if this propentry is enumerable, then once a value is selected from the editor,
22
//we'll want to close the drop down (like true/false). Otherwise, if we're
23
//working with Anchor for ex., then we should be able to select different values
24
//from the editor, without having it close every time.
25
if (ipeCur != null &&
26
ipeCur.Enumerable) {
27
CloseDropDown();
28
29
30
try {
31
Edit.DisableMouseHook = true;
32
/*** This Step fails because the commit method is trying to convert a string to myCustom objet ***/
33
ipeCur.PropertyValue = value;
34
35
finally {
36
Edit.DisableMouseHook = false;
37
Edit.HookMouseDown = capture;
38
39
40
catch (Exception ex) {
41
SetCommitError(ERROR_THROWN);
42
ShowInvalidMessage(ipeCur.PropertyLabel, value, ex);
43
return false;
44
I'm stuck.
I was wondering is there a way to work around this? Maybe extend the string converter class to accept this?
Thanks in advance,
Eric
Hi,
Thank you for your post! I would suggest posting your question in one of the MS Forums,
MSDN Forums » Windows Forms » Windows Forms General
located here:http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=8&SiteID=1.
Have a great day! -
Runtime error while trying to convert script to pdf and sending in mail
Hi all,
I m trying to convert the standard script into pdf using convert_otf fm and trying to send it as an attachment using 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
I m using fm 'SSF_FUNCTION_MODULE_NAME' to get the function module name.
But i m getting a runtime error while executing the program..
Can anyone help me in this issue please.
Thanks in advance,
AshokHi Ramesh,
I m getting an runtime error function module not found. I ll paste the code here.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc = 0.
error handling ent_retco = sy-subrc.
perform protocol_update_i.
ENDIF.
ls_control_param-getotf = 'X'.
DATA: l_document_output_info TYPE ssfcrespd,
l_job_output_info TYPE ssfcrescl,
l_job_output_options TYPE ssfcresop.
check ent_retco eq 0.
CALL FUNCTION 'lf_fm_name'
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = ' '
zxekko = l_doc-xekko
zxpekko = l_doc-xpekko
zxaend = l_doc-xaend
IMPORTING
document_output_info = l_document_output_info
job_output_info = l_job_output_info
job_output_options = l_job_output_options
TABLES
l_xekpo = l_doc-xekpo[]
l_xekpa = l_doc-xekpa[]
l_xpekpo = l_doc-xpekpo[]
l_xeket = l_doc-xeket[]
l_xtkomv = l_doc-xtkomv[]
l_xekkn = l_doc-xekkn[]
l_xekek = l_doc-xekek[]
l_xaend = l_doc-xaend[]
l_xkomk = l_xkomk
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
TABLES
otf = l_job_output_info-otfdata
lines = tb_pdf
EXCEPTIONS
err_max_linewidth = 0
err_format = 1
err_conv_not_possible = 2
OTHERS = 3. -
My version of Acrobat XI Pro will not activate when trying to convert to an Acrobat form from an existing Word document. Acrobat not responding.
Please advise
John BHi johnb69345359,
I am sorry for the inconvenience caused. Lets try to resolve this issue.
I would require few details in order to diagnose the issue correctly :-
1) Are you able to launch Acrobat XI pro ?
If yes, please try Help -> Repair option to repair Acrobat XI pro. Then try to perform the covert operation.
2) Let me know the Operating system installed on your computer.
3) Is there any error code or error message?
Regards,
Aadesh -
Convert XML Code into Transformation
Hi,
I am currently trying to convert this xml string back to my structure but i have been unsuccessful so far using tcode STRANS. Initially i keep getting illegal operation but now i manage to retrieve only part of my xml data.
my XML string:
<?xml version="1.0" ?>
- <Root>
- <Transaction_Status>
<Status>Success</Status>
<Description>No. of records found = 6</Description>
</Transaction_Status>
- <Processing_Exceptions>
- <Report>
- <Record>
<Reason>Validation failed for pan field</Reason>
<Field_Name>ID_PAN_CARD</Field_Name>
<Field_Value />
</Record>
- <Record>
<Reason>Validation failed for passport field</Reason>
<Field_Name>ID_PASSPORT</Field_Name>
<Field_Value />
</Record>
- <Record>
<Reason>Father name field is null</Reason>
<Field_Name>NULL</Field_Name>
<Field_Value />
</Record>
- <Record>
<Reason>Pin field is null</Reason>
<Field_Name>NULL</Field_Name>
<Field_Value />
</Record>
- <Record>
<Reason>Invalid Mobile Number</Reason>
<Field_Name>MOBILE_NUM</Field_Name>
<Field_Value />
</Record>
- <Record>
<Reason>CITYISNULL</Reason>
<Field_Name>DC_CITY</Field_Name>
<Field_Value />
</Record>
</Report>
<Reject />
</Processing_Exceptions>
- <Output>
- <Record>
<search_id>2861</search_id>
<MATCHED_CUSTOMER_ID>100268</MATCHED_CUSTOMER_ID>
<defined_match_criteria>[INDV_NAME:70]</defined_match_criteria>
<actual_matched_criteria>(INDV_NAME : 96.15 )</actual_matched_criteria>
<CUSTOMER_ID>100268</CUSTOMER_ID>
<INDV_NAME>BIJENDER SINGH</INDV_NAME>
<FATHER_NAME />
<CUR_CITY>DELHI</CUR_CITY>
<CUR_STATE>DELHI</CUR_STATE>
<CUR_PIN>110041</CUR_PIN>
<MOBILE_NUM />
<ID_PAN_CARD />
<CUR_PHONE />
<BIRTH_DATE />
</Record>
- <Record>
<search_id>2861</search_id>
<MATCHED_CUSTOMER_ID>115993</MATCHED_CUSTOMER_ID>
<defined_match_criteria>[INDV_NAME:70]</defined_match_criteria>
<actual_matched_criteria>(INDV_NAME : 100.0 )</actual_matched_criteria>
<CUSTOMER_ID>115993</CUSTOMER_ID>
<INDV_NAME>BIRENDER SINGH</INDV_NAME>
<FATHER_NAME />
<CUR_CITY>GURGAON</CUR_CITY>
<CUR_STATE>HARYANA</CUR_STATE>
<CUR_PIN>122001</CUR_PIN>
<MOBILE_NUM>9813736856</MOBILE_NUM>
<ID_PAN_CARD />
<CUR_PHONE />
<BIRTH_DATE>1979-08-26 00:00:00.0</BIRTH_DATE>
</Record>
</Output>
</Root>
Please help . Thanks in Advance.
Regards,
NileshHi Sandra,
Thanks for Reply.
I have create XSLT code like
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<xsl:for-each select="//Root/Output/Record">
<item>
<CUSTOMER_ID>
<xsl:value-of select="CUSTOMER_ID"/>
</CUSTOMER_ID>
<INDV_NAME>
<xsl:value-of select="INDV_NAME"/>
</INDV_NAME>
<FATHER_NAME>
<xsl:value-of select="FATHER_NAME"/>
</FATHER_NAME>
<CUR_CITY>
<xsl:value-of select="CUR_CITY"/>
</CUR_CITY>
<CUR_STATE>
<xsl:value-of select="CUR_STATE"/>
</CUR_STATE>
<CUR_PIN>
<xsl:value-of select="CUR_PIN"/>
</CUR_PIN>
<MOBILE_NUM>
<xsl:value-of select="MOBILE_NUM"/>
</MOBILE_NUM>
<ID_PAN_CARD>
<xsl:value-of select="ID_PAN_CARD"/>
</ID_PAN_CARD>
<CUR_PHONE>
<xsl:value-of select="CUR_PHONE"/>
</CUR_PHONE>
<BIRTH_DATE>
<xsl:value-of select="BIRTH_DATE"/>
</BIRTH_DATE>
</ITEM>
</ABAP>
</xsl:transform>
and calling program like
TYPES: BEGIN OF i_det,
CUSTOMER_ID(10),
INDV_NAME(20),
FATHER_NAME(20),
CUR_CITY(15),
CUR_STATE(15),
CUR_PIN(06),
MOBILE_NUM(10),
ID_PAN_CARD(18),
CUR_PHONE(10),
BIRTH_DATE(10),
END OF i_det.
DATA: i_data TYPE TABLE OF i_det,
w_data type i_det.
DATA: xml_string TYPE string." type ref to cl_fx_reader .
DATA: xslt_error TYPE REF TO cx_xslt_exception,
xslt_message TYPE string .
try .
call transformation ('ZXSLT_CODE')
source xml xml_string
result i_data = i_data.
catch cx_xslt_exception into xslt_error.
xslt_message = xslt_error->get_text( ).
endtry.
Waiting for Response.
Regards,
Nilesh
Maybe you are looking for
-
To read 512 bytes using serial communication
I want to read 512 bytes of data using rs 232 with the timeout of 30ms. I am using "Serial read with timeout -Palm.vi". Is there a limitation of the number of bytes I can specify to this VI? Thanks!! Attachments: Serial_Read_with_Timeout--Palm.vi 63
-
Getting error message when trying to buy my book 'Cannot access Apple Store, please try later' Anyone experienced this?
-
постояно моргает экран. размножается процесThumbnailExtractionHost.exe Thumbnail Handler Extraction Host что делать
-
Message "CVRJC-3802-1" While Importing P6 Project
Pals, C the message, please advise..... * EXCEPTION REPORT * Date: 13-Sep-09 09:37 Executable: PM.exe Application: Primavera Project Management Event Code: CVRJC-3802-1 Message: TCCustomVirtualRow.getJoinedColItems: UDFVALUE row has blank fk_id Conte
-
Deleting Software Update entries? Part II
The previous topic has been marked answered - http://discussions.apple.com/thread.jspa?messageID=11217724� Reason for part II I would also like to know how to delete updates that you want to skip because you do not need them. *Can you delete