Where to add new script in an ActionScript file

Hi,
moved to AS3 forum
I am a newbie using Flash Pro CS5 and have beginner skills in AS3.
I am working on an eLearning lesson and already, with a lot of earlier help of others, and have an Action Script file to use for a white noise  animation in a learning lesson.
I need to make a couple of additions but am very unfamiliar with adding  script to an Action Script file "package." Specifically, I want to add a  URL checking to the Action Script file so that students do not view the  Flash movie animation outside of the lesson which contains learning  materials and instructions for using the animation.
I would like to add the following script but so far, I have been getting error messages:
if ((this.loaderInfo.url).indexOf("mywebsite. com") == -1)
            navigateToURL (new URLRequest ("http://mywebsite.com/default.html"));
            else
//run the animation
The current AS3 in the .as file is:
package
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.utils.getTimer;
    import flash.utils.Timer;
    public class Main extends Sprite
        private var viewbmd:BitmapData;
        private var workbmd:BitmapData;
        private var scaleUp:Matrix;
        private var px:Vector.<uint>;
        private var timer:Timer;
        private var itsNoisy:Boolean;
        public function Main():void
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        private function init(e:Event = null):void
            removeEventListener(Event.ADDED_TO_STAGE, init);
            viewbmd = new BitmapData(stage.stageWidth, stage.stageHeight, false);
            var view:Bitmap = new Bitmap(viewbmd);
            addChild(view);
            workbmd = new BitmapData(viewbmd.width / 8, viewbmd.height / 8, false);
            scaleUp = new Matrix();
            scaleUp.scale(8, 8);
            itsNoisy = true;
            stage.addEventListener(MouseEvent.CLICK, manageNoise);
            initNoise();
            timer = new Timer(50);
            timer.addEventListener(TimerEvent.TIMER, onTick);
            timer.start();
        private function initNoise():void {
            var array:Array = [];
            for (var i:uint = 0; i < 255; i++) {
                array[i] = 0xffffff * (i % 2);
            workbmd.noise(getTimer(), 0, 255, 7, true);
            workbmd.paletteMap(workbmd, workbmd.rect, new Point(0, 0), array, array, array);
            px = workbmd.getVector(workbmd.rect);
        private function onTick(e:Event):void {
            flipSomePixels(160);
            viewbmd.draw(workbmd, scaleUp);
        private function flipSomePixels(howMany:int):void {
            for (var i:int = 0; i < howMany; i++){
            var pxidx:int = Math.floor(Math.random()*px.length);
                px[pxidx] = ~px[pxidx]; //bitwise NOT to flip all bits
            workbmd.setVector(workbmd.rect, px);
        private function manageNoise(e:MouseEvent):void {
            itsNoisy ? timer.removeEventListener(TimerEvent.TIMER, onTick) : timer.addEventListener(TimerEvent.TIMER, onTick);
            itsNoisy = !itsNoisy;
If anyone can take a look and please let me know how to add the  additional script to check for the URL (please be specific since I am a beginner in  scripting):
I have tried everything that I can think of and am stuck.
Thanks in advance for your help.
Kind Regards,
saratogacoach

in your constructor:
if (this.loaderInfo.url.indexOf("mywebsite.com") == -1) {
    navigateToURL(new URLRequest ("http://mywebsite.com/default.html"));
} else {
    addEventListener(Event.ADDED_TO_STAGE, init);

Similar Messages

  • How to add new fields to the DME file in F110

    Hi,
    We have a requirement add new fields to the file that is used in  F110.
    .I did go in to DMEE transaction but I hae no idea how to add new fileds to the existing file.
    Can anybody please help me in resolving the issue.
    Thanks
    Venkat
    Edited by: Venkat R on Jun 8, 2009 8:45 AM

    Hi,
    There is no function module for that, We have created our own function module and attached to that field.
    Refer the below code. This will fetch the document number.
    DATA: lwa_item   TYPE dmee_paym_if_type,
            l_fpayp   TYPE fpayp,
            l_fpayhx TYPE fpayhx,
            first_flag TYPE c,
            lv_lifnr   TYPE lifnr,
            voucher_id TYPE string,
            voucher TYPE string,
            invoice_id TYPE belnr_d,
            voucher_len1 TYPE i,
            voucher_len TYPE i.
      TYPES:
      BEGIN OF lt_regup,
            xblnr TYPE xblnr1,
            belnr TYPE belnr_d,
      END OF lt_regup.
      DATA: lt_regup TYPE STANDARD TABLE OF regup,
            lv_regup TYPE regup.
    Hope this helps.
    Raja.A
    Edited by: Raja.A on Feb 16, 2011 7:17 PM

  • Add new line in the Flat file based on the field value

    Hi,
    Following is my Flat File -
    Customer   X      Y
    1001          1       2
    1002          0       1
    Based on the X and Y value I need to add new lines in the Flat file. If X>0 then add a new line with repeating row and Y>0 add again a new line with repeating row. If X or Y=0 then no need to add any repeating new line. 
    So, here for the above example I need output as-
    Customer    X    Y
    1001          1      2
    1001         1       2
    1001         1       2
    1002          0       1
    1002          0        1
    Suggest how we can achieve this?
    Regards,
    Tridib Konwar 

    Hi Tridib,
        I tried your scenario and You will have to use the custom xslt to get the expected result.
        Please find bellow the xslt code which you can use in your map.
    <?xml version="1.0" encoding="utf-16" ?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var" version="1.0" xmlns:ns0="http://PracticeAtul.XYFlatFileSchema">
    <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
    <xsl:template match="/">
    <xsl:apply-templates select="/ns0:XYComp" />
    </xsl:template>
    <xsl:template match="/ns0:XYComp">
    <ns0:XYComp>
    <XYComp_Child1>
    <XYComp_Child1_Child1>
    <xsl:value-of select="XYComp_Child1/XYComp_Child1_Child1/text()" />
    </XYComp_Child1_Child1>
    <XYComp_Child1_Child2>
    <xsl:value-of select="XYComp_Child1/XYComp_Child1_Child2/text()" />
    </XYComp_Child1_Child2>
    <XYComp_Child1_Child3>
    <xsl:value-of select="XYComp_Child1/XYComp_Child1_Child3/text()" />
    </XYComp_Child1_Child3>
    <xsl:value-of select="XYComp_Child1/text()" />
    </XYComp_Child1>
    <xsl:for-each select="XYComp_Child2">
    <XYComp_Child2>
    <XYComp_Child2_Child1>
    <xsl:value-of select="XYComp_Child2_Child1/text()" />
    </XYComp_Child2_Child1>
    <XYComp_Child2_Child2>
    <xsl:value-of select="XYComp_Child2_Child2/text()" />
    </XYComp_Child2_Child2>
    <XYComp_Child2_Child3>
    <xsl:value-of select="XYComp_Child2_Child3/text()" />
    </XYComp_Child2_Child3>
    </XYComp_Child2>
    <xsl:if test="XYComp_Child2_Child2/text()!=0">
    <XYComp_Child2>
    <XYComp_Child2_Child1>
    <xsl:value-of select="XYComp_Child2_Child1/text()" />
    </XYComp_Child2_Child1>
    <XYComp_Child2_Child2>
    <xsl:value-of select="XYComp_Child2_Child2/text()" />
    </XYComp_Child2_Child2>
    <XYComp_Child2_Child3>
    <xsl:value-of select="XYComp_Child2_Child3/text()" />
    </XYComp_Child2_Child3>
    </XYComp_Child2>
    </xsl:if>
    <xsl:if test="XYComp_Child2_Child3/text()!=0">
    <XYComp_Child2>
    <XYComp_Child2_Child1>
    <xsl:value-of select="XYComp_Child2_Child1/text()" />
    </XYComp_Child2_Child1>
    <XYComp_Child2_Child2>
    <xsl:value-of select="XYComp_Child2_Child2/text()" />
    </XYComp_Child2_Child2>
    <XYComp_Child2_Child3>
    <xsl:value-of select="XYComp_Child2_Child3/text()" />
    </XYComp_Child2_Child3>
    </XYComp_Child2>
    </xsl:if>
    </xsl:for-each>
    </ns0:XYComp>
    </xsl:template>
    </xsl:stylesheet>
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.
    Atul Toke

  • How do I add new data to the same file in a State Machine?

    Hello,
    I have a State Machine, with a State where 3 samples of data are collected in a For Loop. I would like to save this data in a file and keep adding new data to the same file each time I get to this state. The problem I'm running into is that each time I reach this State, my old data in the Excel file gets replaced with the new data instead of being continuously added in the same file.
    Ive tried Shift Registers but I may not be using them correctly since my file keeps displaying only 3 new data points.
    Any ideas will be appreciated!
    Thank you, so much.
    -Peter

    Where should I place these shift registers? Where should I place my File I/O VIs? Is it possible to use the Write to Spreadsheet File VI in this situation?
    Ive attached a very simple example of the problem. Thank you.
    Attachments:
    StandardStateMachine 2.vi ‏16 KB

  • How can we add new entry to a XML file?

    Hi All,
    I'm having problem to add new entry (elements &
    attributes) to an existing XML file. I have created an XML file.
    Few entries are there which I'm showing in a datagrid. Now, in run
    time I have provision for new entry. I'm gathering the whole
    entered information & preparing a string in the same format
    what I have in XML file. But when I'm trying to add that entry to
    my existing XML it won't work. How can I will be able to do
    so?

    Are you using appendChild()?
    Tracy
    BTW, this forum is for Flex Builder questions. Language
    questions should go in General Discussion.

  • In the Organizer where the add new folders button?

    I want to create some new folders under the My folders section. In the Help section I see "click on the create new folder button." I can't find this button.

    Tommyvincent
    In the Elements Organizer 11, have you opened the Folder area to the location where you want to add the new folder, then right clicked and selected New Folder.
    Please refer to the screenshot representing the addition of a new folder to Documents in my Elements Organizer 11.
    I have still not found a specific New Folder button in Elements Organizer 11? New Album, yes. New Folder, no.
    ATR

  • Where to add new jsp reports directory location in path

    hi all,
    where can i add a another location to the path of jsp reports.
    currently jsp reports i have to copy at one location only i.e.
    OH/j2ee/OC4J_BI_Forms/applications/reports/web/examples/Tools
    like REPORTS_PATH env variable in OH/bin/reports.sh, can i add one more location to it.
    regd

    REPORTS_PATH cannot be used for locating jsp reports (when you are running web layout). You have to keep jsp files under document root that is OH/j2ee/OC4J_BI_Forms/applications/reports/web directory. You can create sufbolders under this directory and keep jsp files.
    For example if you keep jsps in a folder named 'myjsps' under web folder, URL to access the jsp will be
    http://host:port/reports/myjsps/test.jsp? .....

  • Where to add new drives for best speed

    I've got a G4 here, and I want to add a 300GB drive for video scratch data - obviously I'd like everything to be as fast as possible.
    My question is, the front drive bay has ATA buses labeled ATA33 and ATA66, which I'm assuming mean it uses the lower speed ATA. On the other hand, the higher speed bus (ATA100) already has the main system drive plugged into it. Which location for my new drive will get me the best performance, on the same cable with the other drive, (ATA100) or on a second cable (ATA66)?

    Not everyone realizes that the MDD has native large (48-bit) support on both the ATA-4 and ATA-6 buses.
    What you may want, though, is an ATA or SATA controller if you want to create a scratch RAID.
    the ATA-4 (ATA/66) bus is about 4% slower than ATA/100. I'm not sure if you will see the 65MB/sec that your new drive is capable of. But that has nothing to do with being ATA/100/133 or ATA-6 or ATA-7.
    You could use the 300GB drive as boot + scratch drive, using the ATA/100 bus, and keep /Users/account on ATA/66 drive bus. Otherwise, if you already keep OS/Apps only on startup drive, and have data and media files on another drive/bus, you might want to look into (S)ATA controller.
    There is an article (sticky) on MacNN Forum, under PowerMac, that lists what Macs have native support for 48-bit etc., very useful. The QS/2002 was the first PMac to support >137GB drives too.

  • How to add new fields to a data extract

    The following data extract program generates an output file which is displayed using a publisher template as a check format report.
    Oracle Payments Funds Disbursement Payment Instruction Extract 1.0
    How would I add new fields to the generated file? In other words what is the procedure to add new fields to the data extract?
    Thanks

    Do anyone pls advise how to customize the payment extraction program? We also have the similar requirement to extract extra fields to format a payment file.

  • How to add new tag in MT103 file format

    Hi All,
    We want to add new Tag 72, in MT103 file format.
    Shall i have to enhance with event module?
    or
    through DMEE tree
    Regards,
    MS

    Hi,
    You need to enhance the event module and have to add your tag in that function module programming.
    Regards,
    Gaurav

  • HOW CAN I ADD NEW WORKSHEET(TAB) TO EXCEL USING ABAP pROGRAM?

    i want to add new tabs to my excel file using abap.... can someone help me on this?

    hi,
    PERFORM add_worksheet USING 'Test 1'.
    *& Form ADD_WORKSHEET
    FORM add_worksheet USING i_name.
    Add new worksheet
      IF g_first_ws <> 'N'.
        g_first_ws = 'N'.
        GET PROPERTY OF g_excel 'ACTIVESHEET' = g_worksheet.
      ELSE.
        CALL METHOD OF g_worksheets 'Add' = g_worksheet.
      ENDIF.
      SET PROPERTY OF g_worksheet 'NAME' = i_name.
      g_row = 1.
      g_col = 1.
    ENDFORM. " ADD_WORKSHEET

  • Add new fileds

    Hi All,
    How to add new fields to BI7 flat file data sources.Its urgent.I am new to BI7.Pls give steps.
    Philip

    Hi Philip,
        select the flatfile datasource u can see general info,fields etc tabs,click on fields tabs.at the bottom u can see insert row.add the row which ever u want to add .at the same time change .CSV file format also on work station and once again select the path in the extraction tab and activate the datasource.
    Hope this will help.
    ************Assign the points if its helpful****************
    Regards,
    vid

  • Have older files from prior thunderbird use and want to add them to current t-bird files.

    I had a break in usage of tbird. I want to add the old files to the new ones so I can refer back to them. I do not need to integrate the files, like folder to like folder, just add new folders with the old files.
    Thank in advance for any help.
    Sherm

    ''Have older files''
    What exactly does this mean?

  • How & where to use Java script to create new button in object detail page

    Hi All,
    I want to create "New/Add button" in object detail page. If i am not wrong i need to use java script for that but could you please let me know how & where to use Java script to create new button in object detail page in CRMOD.
    Thanks in advance.
    Regards,
    Manish

    Any related object on the detail page should have an "Add" or "New" or both buttons by default - This is vanilla functionality and will do the required action.
    If you want to modify this behaviour and do something tricky you will potentially have to go for javascript. You should add the javascript on a custom web tab on that Object.
    Admin --> Application Customization --> Contact -->Contact Web Applet
    Now, add your javascript in the code area, after you select the type = HTML for this web applet, expose this web applet on the Contact detail layout and your javascript will be invoked whenever this page is loaded.
    Check this online document to see how javascript can be embedded in CRM on Demand http://helponmyproject.com/TTOCOD/
    Cheers!
    Royston

  • How to add new fields in sap scripts using itcsy structure

    hi guys,
               could u provide the screen-shots for adding field in scripts. copied standard forms .
    thanks& regards
    eswar.

    Hi,
    you cannot add new fields using ITCSY. It is the interface structure between a SAPscript an a value-changing form-routine.
    Need example anyway?
    Good luck!
    Jo

Maybe you are looking for

  • Two-sided printing with HP deskjet 1050A?

    Hi, How to complete two-sided printing with HP deskjet 1050A? I looked through the properties / options menu at print preview but no options were available for this function. Please advise. Thanks, Patrick

  • Receiver File adapter Append Mode

    Hi I have scenario where i am sending multiple idocs to file ...when i putting the file construction mode to append i can put multiple idoc in to file but i wanna do it on daily basis Means i wanna send the newly crated or changed Idoc on a daily bas

  • T61 won't sleep on AC Power

    I have a T61 with Windows Ultimate, 3GB memory, 100GB disk I cannot get this computer to sleep on A/C power.  I have tried every power setting and advaced power setting I can find.  It sleeps on battery but it won't sleep when plugged in. Does anyone

  • Toolbar button

    Hello! I added button to application toolbar in selection screen with SELECTION-SCREEN FUNCTION KEY 1. I want when push tish button to get a list with the content of table-which is result from RFC. Can you help me somebody? Thanks.

  • Exchange not recognizing user name or password

    I can not get pass this...it will not recognize the username or password.... I have tried all the suggested ways to put my username in but nothing seems to work... Any suggestions that I might have overlooked. The imap switch is turned on. There is n