Fireflies using AS3, conversion from AS2

Hey guys. I'm new to AS3. I do know the bare basics. I figure someone on here will know more than my teacher. (I'm paying for a class to learn actionscript, and as it turns out, he does as little of it as possible.) I wanted to have fireflies floating on my project, like particle effects. I have everything working with a tweaked version of an AS2 file I came across. Everything works in AS2, but I have no idea how to convert the syntax to work in my AS3 file. I get that they're different from each other, but can someone help me acheive the same results in AS3?
http://www.mediafire.com/?o3qcc9bbt8b4p73
The original is the file I'm trying to modify, and fireflies.fla is my modifications, in case anyone wants to see how poorly coded my translation was. It keeps telling me that it can't set the value for a String, though I'm not sure why.
There are two basic components. "Pointer" is an invisible instance that the fireflies use as an anchor (so they can't go off the page), and mcObj is called from the library and is the firefly graphic with coding.
The actionscript for the the parent is:
Stage.align = "";
Stage.scaleMode = "noScale";
Stage.showMenu = false;
Stage.onResize = false;
damp = 0.65;
Fat = 2;
limx = 1000;
limy = 100;
maxScale = 8;
bugNum = 15;
startX = pointer._x;
startY = pointer._y;
pointer._visible = 0;
for (i=1; i<=bugNum; i++) {
    attachMovie("bug", "bug"+i, i);
    dot = eval("bug"+i);
    dot._xscale = dot._yscale=maxScale;
    dot.color = new Color(dot);
    dot.color.setRGB("0xFFFF66");
    dot._x = startX+Math.random()*600;
    dot._y = startY+Math.random()*200;
btn.onRollOver = function() {
    _root.light.gotoAndPlay(2);
btn.onRollOut = function() {
    _root.light.gotoAndStop(1);
And the coding for the firefly is:
this._x = this._x+this.vx;
this._y = this._y+this.vy;
this.vx = this.vx+(Math.random()*2-1);
this.vy = this.vy+(Math.random()*2-1);
this.vx = this.vx*_parent.damp;
this.vy = this.vy*_parent.damp;
this._xscale = this._xscale-_parent.fat;
this._yscale = this._yscale-_parent.fat;
if (_parent.startX+_parent.limx<this._x) {
    this.vx = -this.vx;
    this._x = _parent.startX+_parent.limx;
if (this._x<_parent.startX-_parent.limx) {
    this.vx = -this.vx;
    this._x = _parent.startX-_parent.limx;
if (_parent.startY+_parent.limy<this._y) {
    this.vy = -this.vy;
    this._y = _parent.startY+_parent.limy;
if (this._y<startY.startY-_parent.limy) {
    this.vy = -this.vy;
    this._y = _parent.startY-_parent.limy;
if (_parent.maxScale<this._yscale || this._yscale<_parent.maxScale/25) {
    _parent.fat = -_parent.fat;
Anyone who can help, please do. I need to have this done by the end of the week :/

//stage.align = "";
stage.scaleMode = "noScale";
stage.showDefaultContextMenu = false;
var damp:Number = 0.65;
var Fat:Number = 2;
var limx:Number = 1000;
var limy:Number = 100;
var maxScale:Number = 8;
var bugNum:int = 15;
var startX:Number = pointer.x;
var startY:Number = pointer.y;
pointer.visible = false;
for (var i:int=1; i<=bugNum; i++) {
    //attachMovie("bug", "bug"+i, i);
this["bug"+i]=new but();  // assign class
addChild(this["bug"+i]);
   var  dot:MovieClip = this["bug"+i];
    dot.scaleX = dot.scaleY=maxScale;
var ct:ColorTransform=dot.colorTransform;
ct.color = 0xFFFF66;dot.colorTransform=ct;    dot.x = startX+Math.random()*600;
    dot.y = startY+Math.random()*200;
btn.addEventListener(MouseEvent.MOUSE_OVER,onRollOverF);
btn.addEventListener(MouseEvent.MOUSE_OUT,onRollOutF);
function onRollOverF(e:MouseEvent):void {
    MovieClip(root).light.gotoAndPlay(2);
function onRollOutF(e:MouseEvent):void {
    MovieClip(root).light.gotoAndStop(1);
And the coding for the firefly is:
var initialized:Boolean;
if(!initialized){
this.vx=0;
this.vy=0;
initialized=true;
this.x += this.vx;
this.y += this.vy;
this.vx = this.vx+(Math.random()*2-1);
this.vy = this.vy+(Math.random()*2-1);
this.vx = this.vx*MovieClip(parent).damp;
this.vy = this.vy*MovieClip(parent).damp;
this.scaleX -= MovieClip(parent).fat;
this.scaleY = this.scaleX;
if (MovieClip(parent).startX+MovieClip(parent).limx<this.x) {
    this.vx = -this.vx;
    this.x = MovieClip(parent).startX+MovieClip(parent).limx;
if (this.x!=MovieClip(parent).startX-MovieClip(parent).limx) {
    this.vx = -this.vx;
    this.x = MovieClip(parent).startX-MovieClip(parent).limx;
if (MovieClip(parent).startY+MovieClip(parent).limy<this.y) {
    this.vy = -this.vy;
    this.y = MovieClip(parent).startY+MovieClip(parent).limy;
if (this.y!=MovieClip(parent).startY-MovieClip(parent).limy) {
    this.vy = -this.vy;
    this.y = MovieClip(parent).startY-MovieClip(parent).limy;
if (MovieClip(parent).maxScale<this.scaleX || this.scaleY<MovieClip(parent).maxScale/25) {
    MovieClip(parent).fat = -MovieClip(parent).fat;

Similar Messages

  • Coloring using AS3 instead of AS2

    Hello Adobe,
    I'm making my final year project which is education game and one of the game is coloring game, so I've finished it and all works well, then i just found out that the code I was using is AS2, meanwhile all the other game and files is running in AS3, so I've to make this coloring game code into AS3, but just can't fix it how hard I try.
    Here is the view of what I made, not done the graphic part yet, looks really bad
    http://i51.tinypic.com/t6qeyv.jpg
    Here is the code I have and works on AS2
    colorvalue="";
    RedColourBtn.onRelease=function(){
    colorvalue="0xFF0000";
    BlueColourBtn.onRelease=function(){
    colorvalue="0x0000FF";
    area1.onRelease=function(){
    colour= new Color(this);
    colour.setRGB(color_value);
    area2.onRelease=function(){
    colour= new Color(this);
    colour.setRGB(color_value);
    Thanks for your time

    Here is the convertion
    RedColourBtn.addEventListener(MouseEvent.CLICK, determineColor);
    BlueColourBtn.addEventListener(MouseEvent.CLICK, determineColor);
        var colorvalue:uint;
    function determineColor(arg:MouseEvent)
        var colorSquareName:String = arg.currentTarget.name;
        if (colorSquareName == "RedColourBtn")
            colorvalue= 0xFF0000;
        else if (colorSquareName == "BlueColourBtn")
            colorvalue= 0x0000FF;
    area1.addEventListener(MouseEvent.CLICK, area1fn);
    area2.addEventListener(MouseEvent.CLICK, area2fn);
    function area1fn(e:MouseEvent):void{
        var colorTransform:ColorTransform = area1.transform.colorTransform;
        colorTransform.color = colorvalue;
         area1.transform.colorTransform = colorTransform;
    function area2fn(e:MouseEvent):void{
        var colorTransform:ColorTransform = area2.transform.colorTransform;
        colorTransform.color = colorvalue;
        area2.transform.colorTransform = colorTransform;

  • I want to make it a AS3 project from AS2

    I am working on a flash file made with AS 1&2, with lots
    of layers and library items. I want to make it a AS3 project. How
    should I go about this?

    First, change as much of the code as you can to be AS3 code.
    Then, change your publish settings to AS3. Then, run the file and
    fix all of the errors that arise... the first list of errors is not
    likely all of them. Errors are often revealed in stages... as one
    is fixed, another is detected.
    Another option is to start from scratch. This may be better
    if you have no familiarity with AS3--you will learn about it in the
    process. You can build it gradually and test as you go rather than
    starting with a potential flock of code issues.

  • Using Quicktime Conversion

    I can't find "Using Quicktime Conversion" from Final Cut X.   Can anyone tell me where to find it?

    Choose File->Share->Export File. This will use Quicktime to export in one of several possible options; like Tom said, the options are somewhat limited.
    If you need a different export, then create a Master File, and use MPEG Streamclip to export that with the settings you want.

  • Draw a Line From any Point A To any Point B Dynamically Using AS3

    I am trying to make an anmation where there are several locations(say A,B,C,D,......) made on a  map. If a person clicks on one location A and then another location B, I wanted to draw a dotted line from point A (from  destination of the plane) to point B(to destination of the plane)  using AS3. Please help me........

    Here is a quick and dirty timeline code that does it (class is below):
    var line:Shape;
    var lineGraphics:Graphics;
    var clickSwitch:int = 0;
    var mousePositions:Array = [];
    var conversion:Number = 180 / Math.PI;
    init();
    function init():void {
         drawBackground();
         line = new Shape();
         addChild(line);
         lineGraphics = line.graphics;
         stage.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(e:MouseEvent):void
         clickSwitch = 1 - clickSwitch;
         mousePositions[clickSwitch] = new Point(mouseX, mouseY);
         if (clickSwitch == 0) {
              drawLine();
         else {
              removeLine();
    function removeLine():void
         lineGraphics.clear();
         line.rotation = 0;
    function drawLine():void
         lineGraphics.lineStyle(1, 0xff0000);
         lineGraphics.moveTo(0, 0);
         var dotDistance:Number = 2;
         var nextX:Number = dotDistance;
         while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
              lineGraphics.lineTo(nextX, 0);
              nextX += dotDistance;
              lineGraphics.moveTo(nextX, 0);
              nextX += dotDistance;
         line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
         line.x = mousePositions[1].x;
         line.y = mousePositions[1].y;
    function drawBackground():void
         var s:Shape = new Shape();
         var g:Graphics = s.graphics;
         g.beginFill(0xC0C0C0);
         g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
         g.endFill();
         addChild(s);
    Class:
    package
         import flash.display.Graphics;
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.events.MouseEvent;
         import flash.geom.Point;
         public class DottedLine extends Sprite
              private var line:Shape;
              private var lineGraphics:Graphics;
              private var clickSwitch:int = 0;
              private var mousePositions:Array = [];
              private var conversion:Number = 180 / Math.PI;
              public function DottedLine()
                   init();
              private function init():void {
                   drawBackground();
                   line = new Shape();
                   addChild(line);
                   lineGraphics = line.graphics;
                   stage.addEventListener(MouseEvent.CLICK, onClick);
              private function onClick(e:MouseEvent):void
                   clickSwitch = 1 - clickSwitch;
                   mousePositions[clickSwitch] = new Point(mouseX, mouseY);
                   if (clickSwitch == 0) drawLine();
                   else removeLine();
              private function removeLine():void
                   lineGraphics.clear();
                   line.rotation = 0;
              private function drawLine():void
                   lineGraphics.lineStyle(1, 0xff0000);
                   lineGraphics.moveTo(0, 0);
                   var dotDistance:Number = 2;
                   var nextX:Number = dotDistance;
                   while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
                        lineGraphics.lineTo(nextX, 0);
                        nextX += dotDistance;
                        lineGraphics.moveTo(nextX, 0);
                        nextX += dotDistance;
                   line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
                   line.x = mousePositions[1].x;
                   line.y = mousePositions[1].y;
              private function drawBackground():void
                   var s:Shape = new Shape();
                   var g:Graphics = s.graphics;
                   g.beginFill(0xC0C0C0);
                   g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
                   g.endFill();
                   addChild(s);

  • CF11 Actionscript 3 - I'm migratiing from AS2 and can't use REMOTING, so how to use cfc's and process their results?

    The CF11 integration notes describe how to do use Flash Remoting. I use that in my AS2 code and it works fine. I'm trying to migrate to AS3 where there is no Remoting. I have done the following:
    import flash.net.*;
    import flash.events.*;
    var CFCService = new NetConnection()
    CFCService.objectEncoding = 0;
    CFCService.connect("http://localhost:8500/flashservices/gateway/")
    var responder2 = new Responder(getActiveUsers_Result, onFault);
    CFCService.call("cfc.SyslockComponents.getActiveUsers", responder2);
    stop();
    function getActiveUsers_Result(result:Object):void
        trace("getActiveUsers Result Status: " + result.STATUS);
        for (var property:String in result)
            trace(property +" : " +result[property]);
    The OUTPUT of my program shows the contents of the STRUCT returned by the CFC:
    getActiveUsers Result Status: ALLOK  <<<<<< the CFC completed successfully
    RECCOUNT : 1  <<<<<<<< There was one record select by query
    DETAILS : [object Object]  /<<<<<< this contains the query results
    STATUS : ALLOK
    I don't know how to process DETAILS because RECORDSET is not available in AS3.

    S/he's only offering six Dukes here:
    http://forum.java.sun.com/thread.jsp?forum=54&thread=469450&start=0&range=15#2169975
    This problem has been done before. Break this down into something simpler. You don't need an applet. Just do it on the command line. You don't need a database. Just create a flat file if you need some persistent data. Do the simple thing first, then build out from there.
    Click on the special tokens link up above and learn how to use [ code][ code] tags.
    Your code is a big, unreadable mess. You've got pare this down into something sensible. If you can't understand it, it's unreasonable to expect someone on this forum to wade through all of that. - MOD

  • How can you run an executable from AS2 code without using fscommand() or a projector?

    Just using some short .asc files made out of Notepad for some back-end server stuff, but without using fscommand() or projectors, how can you call an executable? There's a C++ program that I want to run from more-or-less the same directory as the .asc files, which handles some logging, and I need to be able to pass it arguments when telling it to run.
    Please note that I have Googled this with no useful results and that I'm on an assignment that necessitates this question. Also I'm open to the possibility that it can't be done.
    Thanks!

    The swf is on a different server and using AS3.  The little bit of AS2 back-end stuff is on a few different servers that the swf is hooking up to for streaming video and audio.  The executable would be on the AS2 servers.

  • Since downloading Firefox 4, I am having problems archiving gmail conversations from my inbox view. Also, when I go to enter a new event in google calendar, I now have to click the cursor in the box to type the event (it used to let me just start typing).

    Since downloading Firefox 4, I am having problems archiving gmail conversations from my inbox view (either one or several conversations) as it says "No Conversations Selected" when I have selected one or several. Also, when I go to enter a new event in google calendar, I have to click the cursor in the box to type the event (it used to let me just start typing) or else it flips out and starts jumping to day view or another month. Does anyone know how to fix either of these?

    I have had this problem; but while trying to fix another problem, I reset my preferences for Firefox and it fixed this problem as well. To reset preferences, follow this link: http://support.mozilla.com/en-US/kb/Resetting%20preferences

  • How can I print a text message conversation from my iPhone? Not using screenshots.

    How can I print a text message conversation from my iPhone? Not using screenshots. It's around 500 messages so screenshots is not a option.

    Yes, you can delete from iphone:
    http://manuals.info.apple.com/enUS/iPhone_iOS4_UserGuide.pdf
    It is covered in the manual.
    Page 172:
    "Delete a podcast: In the Podcasts list in iPod, swipe left or right over the podcast, then
    tap Delete. "

  • Is there an app i can use to listen or record conversations from i5s to i6plus ?

    is there an app i can use to listen or record txts and conversations from i6plus to i5s ?

    Maybe you should ask Apple.
    This forum is just users like yourself who can do absolutely nothing to change the way the iPhone works.
    Allan

  • 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 code

    Okay, 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;

  • Is it possible to view a conversation from whatsapp or other application from my iphone 5S using my appled ID or iCloud?

    I recently bought my iPhone 5S, and my gf knows my Apple ID. She managed to read my conversation from one of my applications (whatsapp) using the Apple ID.
    How the F*** did she do it? Anyone knows or experienced this? Pls. help, I'll greatly appreciate it.

    I am guessing this is still the case with exchange 2007..
    If anyone has a work around please share

  • Can I use my email and phone number to start a new conversation from iMessage?

    Can I use my email and phone number to start a new conversation from iMessage?

    Can I use my email and phone number to start a new conversation from iMessage?

  • Trouble exporting 320x240 from 720x480 sequence using QT conversion

    (Opps, put this on the FCP Express discussion 1st...)
    Hi,
    Everytime I try to export a 720x480 sequence from FCP with "using QT Conversion" to a 320x240 size, it exports out as 640x480. Everytime. Used to work just fine. Same thing happens using a compressor setting to 320x240 and exporting right from the QT export size setting. Anyone know what gives? I tried trashing prefs in both FCP and QT. No luck.
    Thanks!

    This is the first time I've heard of this problem so no real basis to go on. Try the QT prefs delete again and if not that, then the QT reinstall.
    To do a full quicktime reinstall.
    Go to /library/receipts and delete any files that say Quicktime followed by a number e.g. Quicktime703.pkg
    Go to the Apple quicktime site and download the appropriate version of Quicktime to your hard drive.
    Run the Quicktime installer.
    Repair Disk Permissions for your System Disk (Disk Utility > Select the system disk > Repair Disk Permissions)
    Reboot
    Good luck.
    x

Maybe you are looking for

  • Error While Running a ADF Page from JDeveloper

    Hi I am facing the following problem while running a page from JDeveloper 11g please find the below stack trace and help me in fixing this IntegratedWebLogicServer startup time: 181886 ms. IntegratedWebLogicServer started. [Running application TestAp

  • How to debug file content conversion problems?

    Hi, I'm trying to debug a file content conversion problem.  I'm mapping a few nodes in an IDOC to a file of fixed length fields.  I'm using the "<Node A>.fieldFixedLengths", "<Node B>.fieldFixedLengths", "<Node C>.fieldFixedLengths", etc. parameters

  • How to create a condition with out join

    Hi all, I m using Oracle Discovere Desktop. I want to know that how can i use outer join in conditions. e.u. category(+) = 'E' Regards

  • Running SAP XI in High Availability

    Bonjour a vous tous ! I am looking for best practices when running SAP Exchange Infrastructure (3.0, well it is now XI 7.0 with the new NW2004s – SP9) in High Availability mode. The customer that I work with does not know yet on which platform its pr

  • Setting session attributes at the Role level

    I am running AM7.1 in Legacy mode and I am trying to create a role and assign session attributes at this role level. I followed the instructions for doing this but it does not seem to be working. I created the role and added the session service to it