Math.Random in a document with Flash Pro class

Hello.

in a previous discussion, I had help with randomization of the position of the "appeaance" on an mc on the stage (http://forums.adobe.com/thread/946317?tstart=0), with code is in the file Flash Pro.

Here, I ask help randomizing positioning using Math.random but by using a class of documents, in order to avoid rewriting the code for the film of many clips I have in the library.

Clips in the library begin and end with about 15 blank keyframes: they have 2 layers, one for action script and the other for the graphics (which are also filmed sequences,) while the level of the AS in the video clip is longer than the layer containing art, on both ends, beginning and end, so the effect is of bubbles popping up and appearing on the stage in random positions.

In the library movie clip symbols have a base popBubble.as class, who works at removeChild (this).

However, using RandomPosBubble.as in the class of document of the flash file, I get a script error-

D:... RandomPosBubble.as, line 171084: syntax error: expected rightparen before the colon.

See RandomPosBubble.as below

package

{

import flash.display.MovieClip;

import flash.events. *;

SerializableAttribute public class RandomPosBubble extends MovieClip

{

public void RandomPosBubble()

{

this.addEventListener (Event.ENTER_FRAME, onEnterFrame);

_spoboyle said - this will set up a listener for the enterFrame event.

Each image we check if the MovieClip is on frame 1 and if so recalculate its position

}

private void onEnterFrame(e:Event):void

{

var mc:MovieClip = e.target as MovieClip;

If (mc:currentFrame == 1)

{

MC.x = Math.random () * stage.stageWidth;

MC.y = Math.random () * stage.stageHeight;

}

}

}

}

Thank you.

the example that I have running does not produce the same model whenever they appear

Use this as a replacement for the previous Bubble.as file will make them appear at different times

package
{
    import flash.events.Event;

    public class Bubble extends BubbleMC
    {
        public function Bubble()
        {
            addEventListener(Event.ADDED_TO_STAGE, onAdded);
        }

        private function onAdded(e:Event):void
        {
            x = Math.random() * stage.stageWidth;
            y = Math.random() * stage.stageHeight;
            var startFrame:int = Math.random() * 85;
            trace(startFrame);
            gotoAndPlay(startFrame);
            addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
        }

        private function onEnterFrameHandler(e:Event):void
        {
            if (currentFrame == 1)
            {
                x = Math.random() * stage.stageWidth;
                y = Math.random() * stage.stageHeight;
            }
        }
    }
}

Tags: Adobe Animate

Similar Questions

  • Develop apps for Android & iOS with Flash Pro CS6?

    I just want to begin creating apps and games for Android.

    1 is able to build an app or a game with Flash Pro CS6 and publish it on Android phone? also even with iOS?

    2. What is different in the developing applications with Flash Pro and Flash Builder?

    Thank you

    1 Yes and Yes.

    2 flash pro is more suited to the animators (and so game designers), while flash builder is more appropriate for developers (coders): http://forums.adobe.com/thread/791165

  • How to call a function of my html code to js created by animate cc, I had used 'exportRoot.functionName' and said this function in my document of flash pro with html5 canvas, but now on cc animate this way doesn't work.

    My html code created by animate cc was changed to php for me, because I send and received variables via get and catch the cookies and much more. the function that I used to call function on my .fla of the document is passId() and it worked before when animate was Flash pro with html5 canvas.

    Captura de pantalla 2016-09-27 a las 12.19.59 p.m..png

    And function of .fla, I frame_0 only assign to the variable "id_usuario", this is the feature on fla:

    Captura de pantalla 2016-09-27 a las 12.20.12 p.m..png

    First of all, the title of your thread is horrible. Titles are supposed to be securities, not paragraphs.

    As for your problem, you are probably trying to call catchIdUser before it is defined. handleComplete() is raised when the content is ready to run. He did not actually yet. I guess you should have script code call the function of window parent, not the other way around.

  • How to build for armv6, not with Flash Pro 5.5 armv7? Help!

    I built an update for my application, first built with Flash 5 Pro and I've updated to Flash Pro 5.5, and now Apple tell me the app must be armv6, armv7 not

    I don't see any way to tell the publication settings for armv6?

    Thank you

    Robert

    A 3G iPhone is a device armv6 and apps packed with AIR 2.6/2.7 does not work on it.

  • Flash Media Playback - Compatible with Flash Pro?

    Hi all, I recently stumbled on the drive Flash Media Playback, (http://www.adobe.com/products/flash-media-playback.html) and this seems to be an excellent solution for streaming video on a Web site. However, I wonder if we can somehow use the streaming service Flash Media Playback in Flash Professional. The FMP outputs only html code, so I don't know how or if it could be used in Flash, but it is seems not something that should be possible.

    Any ideas? Thank you!

    The purpose of this product is to incorporate in HTML format. If you use AIR and use a StageWebView (which shows a native/HTML browser) then Yes you could. Otherwise, the aim is precisely NOT for Flash Professional. It is a backup player, which means he's trying to use HTML5/MP4 as a best practice. If it detects no mp4 support she descends to a flash/SWF player. The nature of all this is a copy and paste Media Player to use if you do not have Flash Pro.

    It is based on OSMF, who is a player that you can use inside Flash Pro:

    http://www.opensourcemediaframework.com/

    API:

    http://help.Adobe.com/en_US/FlashPlatform/reference/ActionScript/3/org/OSMF/media/package-detail.html

  • Different looks of the bookmarks when you merge documents with Acrobat Pro DC

    Hey guys

    When you merge several PDF Acrobat DC creates bookmarks for each original file but the bookmarks different as standard bookmarks, you can create by clicking on 'Add bookmark' in the navigation bar.

    When you add other documents that already merged, the look of the modification of bookmars for the newly merged to the standard pdf looks like.

    As shown in the picture below, the first 4 documents have been merged in a single step with the merge tool and one more has been added with the "Page management" tool

    .bookmarks.PNG

    Can someone explain the difference between the two types of bookmarks and how to homogenise them?

    Thanks for your help!

    Robin

    Not that I know of.

    Friday, October 23, 2015 21:03, robink27733514, [email protected]>

  • How to create the energy bar with flash pro?

    Hello

    How to create an energy bar as what you see in flash facebook games, which increases with time "as every minute add 1 energy point' and reduce playing a role or a battle or just do an action?

    You can simply use a rectangular moviweclip/sprite and use Actionscript to control the width (or height), where the energy is proportional to the value of the width (or height).  You can also pair with a textfield that allows you to display the actual value of energy as it changes.

  • Journal of crash on App Store with an API created by Flash Pro/AIR

    I have an application on App Store created with Flash Pro on a PC. The new version of the file API that I downloaded (to make it compatible with iOS9) was rejected and I'm covered in a cryptic crash log. The end of newspaper in a dsym file. Is it true that I can not get a dsym on a PC file? If so, how can I get the appropriate journal of crash or otherwise information? If I'm at the limit of what is possible and that he should abandon the PC or Flash Pro?

    first of all, make sure that you use the latest version of the sdk, 19.0.0.190 (at this time) - archived versions Adobe AIR SDK

    Second, make sure that no runtime error during the test.

    Thirdly, ask apple what action triggered the accident.

    Fourth, sometimes a beta sdk will fix the problem, Download Adobe AIR 19 Beta - Adobe Labs

  • Flash Pro CC 2014 Crashes When Publishing with Air

    While trying to publish my application with Flash Pro CC 2014, the program crashes. I use the current beta version of AIR 15 (previous version had the same results) on a Mac (OSX Yosemite 10.10 beta 5, not the public beta). When I publish just a SWF there no problem. If I publish it on Android, iOS, or Desktop, then Flash crashes. When comes the scene of accident Adobe I submit reports to Adobe. In the end, I get a message telling me that Adobe has found a solution to the recent crash and 'click here' for more details.  When I do it just go to the Adobe homepage without help. Y at - it solution or workaround? I used one of my other machines that has the Mavericks on it for publication at this time.  I would like to work on a machine and does not transfer does not back-and-forth. Any help will be great!

    Hello

    This problem has been fixed internally and will be available in the next update of Flashpromanager.new CC 2014.

    Rgds,

    Mukesh

  • Flash Pro CS6 with Air 14 SDK does not support iOS7 icons?

    I am trying to publish an application using the Air SDK 14.0.0.110 (and tried 14.0.0.137) and there is still no place to put the files of icons iOS 7, 120 x 120, 76 x 76 and 152 x 152, is this correct?

    Your only choice is to build from the command line, or replace with Flash Pro CC 2014.

    Read this long thread for how you publish from the command line without having to get the whole typed command perfectly (you can get the line from the Console):

    https://forums.Adobe.com/thread/1308215

  • Flash pro and flash builder: difference of resolution

    I have already developed with flash pro for Android (Actionscript 3 - android 2.3.3 - Air 2.6). I try to use Flash Builder (for more developer features).

    But with the same code (an example of Véronique Brossier book) I can not get the same result.

    With flash pro, my three sprites are 150, 350 and 550 pixels high.

    With flash builder, they run over 350, 550 and 750.

    I'have the same result on my device (Galaxy score) or imitated a.

    Flash pro I can specify the height and the width of the stage. I did find the same settings in flash builder.

    What could be wrong in my process?

    the main code is here:

    public void FirstApp() {}

    the constructor code

    var callButton:Sprite = createSprite (0xFF3300, 100, 100);

    callButton.addEventListener (MouseEvent.CLICK, callMe);

    addChild (callButton);

    var textButton:Sprite = createSprite (0x0099FF, 100, 200);

    textButton.addEventListener (MouseEvent.CLICK, textMe);

    addChild (textButton);

    var mailButton:Sprite = createSprite (0x00FF11, 100, 300);

    mailButton.addEventListener (MouseEvent.CLICK, mailMe);

    addChild (mailButton);

    }

    function createSprite(hue:int,_xPos:int,_yPos:int):Sprite {}

    var tmp:Sprite = new Sprite();

    tmp.graphics.beginFill (hue, 1);

    tmp.graphics.drawRect (PosX, Posy, 200, 100);

    tmp.graphics.endFill ();

    tmp.x = xPos;

    tmp.y = yPos;

    return tmp;

    }

    Yes, it is preferable to calculate the dimensions according to capabilies device to accommodate devices with different sizes and screen different portrait/landscape orientation.

    > I try to play with the StageScaleMode value without success. I would get the same result as in Flash pro. Flash pro, I specified the width and height of my internship and I asked an application "full screen" in the settings. Yes, wathever device I use, the application had the same look.

    Do you know if there is a way, in flash builder, in order to obtain this behavior?

    The value default StageScaleMode SHOW_ALL in this case if doesnot display of the device is the size of the scene that you specify in Flashpromanager.new, the content would be to evolve upwards or downwards in order to show all the content of the scene. This may show the borders if the proportions of the scene is not the same as the aspect ratio of the screen of the device.

    If you set it to StageScaleMode.NO_SCALE none of your content would be to evolve which explains why you see small Elves.

    To make it look like Flash Pro, in the SWF meta data tag, enter the height and identical width of Document Pro Flash width and height.

    together left-align at the top that you already do but let the StageScaleMode SHOW_ALL.

  • Flash Pro / animate

    Hello

    Dialog boxes like opening new files, importing video is incomplete and I can't click on 'ok' or whatever the corresponding command is since I am not able to resize the box. This was happening with Flash Pro, so I've updated to animate in the hope that this would not solve the problem but it didn't. The dialog box new file seems ok, but when you try to import video I can't see the whole box. I tried to change my settings to display without result.

    I use Windows 8.1 Pro with Setup dual monitor with a Cintiq 13HD screenshot. attached.

    How to solve the problem? Importing video is vital for the project I'm working on that.

    Thank you.

    Screenshot (52).png

    Hello

    After setting the text size and file at 100% please restart the computer and try again. If the problem persists then please make sure that you have the latest version of the Wacom driver installed. If that don't work then I recommend to contact our customer since the contact customer care link and select the option chat or call.

    You can also share your contact information with me by sending a private message and I can get back to you.

    Kind regards

    Vivek

  • Adding text to flash pro

    I use flash pro cc2014. I can add a text box, dynamic text, do a video and when I run a test, it won't let me change the text.

    any suggestions, what am I doing wrong, a newbie with flash pro

    Dynamic text is not editable. You want to input text.

  • Where is the new motion editor in Flash Pro CC (2014)?

    Motion Editor is back with Flash Pro CC 2014, so I installed the trial version but I don't find it anyware, they say.

    Hi all

    Flash Pro CC 2014 (v 14.0.0.110) is now available for download through the creative application of cloud.

    We have included a whole new motion editor and several other new features with this release of Flash Pro. The new query editor is completely redesigned, intuitive and easy to use while retaining the basic features and backward compatibility with Flash CS6

    To call the query editor, just double-click on your motion tweens on the timeline (or right click and select "Refine the Motion") and the motion Editor opens in the context of the scenario itself. Double click again to collapse once you have made your adjustments.

    Complete list of the new features of Flash Pro CC 2014 is available at these links:

    Overview: https://www.adobe.com/in/products/flash.html

    What's new: https://helpx.adobe.com/flash/using/whats-new.html

    Release notes: https://helpx.adobe.com/flash/release-note/flash-professional-cc-2014.html

    Videos: https://helpx.adobe.com/in/flash.html

    Thank you

    Sangeeta

  • BUG - in flash pro CC, "bold" and "italics" TextFormat properties have no effect on the rendered text

    Concise problem statement:

    If you compile with CC pro flash and use the method "setTextFormat' of a TextField, the 'fat' and 'italic' argument of TextFormat properties have no effect on the rendered text. If you compile with flash pro CS6, 'fat' and 'italic' properties work as expected.

    Apparently, the only way to make the text to display correctly with flash pro CC, is to change the name of the font (add the suffix "Bold", "Italic", or "Bold Italic".) This means code that dynamically changes the font styles only works in CS6 or CC, but not both. By example, if you use the "bold" text property makes daring in CS6 and regular CC, whereas if you change the name of the font to add the suffix "Bold", the text makes daring in CC and DOES NOT at all in CS6. It is therefore difficult for a team to CS6 in the CC of transition.

    Steps to reproduce the bug:

    1. create an xfl 2 TextFields on stage, as well with the font "Trebuchet MS" and "regular" style, a named boldTrueText that contains the string "" BOLD"= true", a named fontNameText that contains the string "fontName ="BOLD"Trebuchet MS". Create 2 more TextFields on the stage of Visual reference, both with a font "Trebuchet MS", one with the 'regular' style, one with ' bold '.

    2. Add the following code in the Actions Panel on frame 1:

    import flash.text.TextFormat;

    import flash.text.Font;

    var format: TextFormat = boldTrueText.getTextFormat ();

    format. Bold = true;

    boldTrueText.setTextFormat (format);

    format = fontNameText.getTextFormat ();

    format.font = "Trebuchet MS bold";

    fontNameText.setTextFormat (format);

    var fonts: Array = Font.enumerateFonts (), count: int = fonts.length;

    for (var i: int = 0; i < count; i ++) {}

    var make: police = fonts [i];

    trace ("fontName:" + font.fontName + ", fontStyle:" + font.fontStyle);

    }

    3. Save and compile with flash CS6 pro and flash pro CC.

    Results:

    With flash CS6 pro, "" BOLD"= true" makes "BOLD", and "fontName ="BOLD"Trebuchet MS" IS NOT RENDERED.

    With flash CS6 pro, what follows is drawn:

    fontName: Trebuchet MS, fontStyle: "BOLD"

    fontName: Trebuchet MS, fontStyle: regular

    With flash pro CC, '"BOLD" = true' makes regular, and "fontName ="BOLD"Trebuchet MS" makes "BOLD".

    With CC pro flash, what follows is drawn:

    fontName: Trebuchet MS, fontStyle: regular

    fontName: Trebuchet MS bold, fontStyle: "BOLD"

    Expected results:

    The same text is rendered in flash CS6 and CC pro. I don't know why this behavior has been changed in flash CC pro - it causes silent failures in the code that dynamically changes the font styles. I expected the CS6 flash pro behavior remain the same in the CC, as follows:

    With flash pro CC, "" BOLD"= true" makes "BOLD", and "fontName ="BOLD"Trebuchet MS" IS NOT RENDERED.

    With CC pro flash, what follows is drawn:

    fontName: Trebuchet MS, fontStyle: "BOLD"

    fontName: Trebuchet MS, fontStyle: regular

    If you do not break backward compatibility (to others), you can do both behaviors works in flash pro CC, as follows:

    With flash pro CC, "" BOLD"= true" makes "BOLD" (the police is always 'Trebuchet MS'), and "fontName ="BOLD"Trebuchet MS" also makes "BOLD".

    With CC pro flash, what follows is drawn:

    fontName: Trebuchet MS, fontStyle: "BOLD"

    fontName: Trebuchet MS, fontStyle: regular

    fontName: Trebuchet MS bold, fontStyle: "BOLD"

    I introduced this bug with the form of bug and also with adobe bugbase (in case it is not obsolete) - I'm just trying to maximize my chances of getting a fix.  Has anyone else encountered this bug?

    Thank you for reporting this issue. As a result of your efforts, it is reproducible and reported internally.

    Will update here once the fix is available.

    -Mabrouk

Maybe you are looking for