VARs in CS3?

I can't edit Vars in ActionScript 3 in Flash CS3, it is said to have published setting for AS 2.0 or 1. So, how can I do this in AS 3.0?

Yes, do publication for AS2 settings, remove the name of the variable and return to AS3

and Yes, you can not use these variables more. Use the text property of the object.

Tags: Adobe Animate

Similar Questions

  • Help with the Flash CS3 Tutorial Code effect particle

    I did the tutorial from http://www.schoolofflash.com/2008/03/Flash-CS3-particle-effect/ . I used a star to replace the circle. Here is my code:

    var starsArray:Array = new Array();

    var maxStarss:Number = 8;

    function addStars(e:Event)

    {

    Stars: var = new stars Stars();

    Stars.x = stage.stageWidth/2;

    Stars.y = stage.stageHeight/2;

    Stars.Alpha = Math.Random () *.8 +. 2;

    stars.scaleX = stars.scaleY = Math.Random () *.8 +. 2;

    stars.xMovement = Math.Random () * 10 - 5;

    stars.yMovement = Math.Random () * 10 - 5;

    starsArray.push (stars);

    addChild (stars);

    stars.cacheAsBitmap = true;

    If (starsArray.length > = maxStarss)

    {

    removeChild (starsArray.shift ());

    }

    stars.addEventListener (Event.ENTER_FRAME, moveStars);

    }

    function moveStars(e:Event)

    {

    e.currentTarget.x += e.currentTarget.xMovement;

    e.currentTarget.y += e.currentTarget.yMovement;

    }

    var myTimer:Timer = new Timer (50);

    myTimer.addEventListener (TimerEvent.TIMER, addStars);

    myTimer.start ();

    This time, I'm trying to make the stars shrink and transparent that move away from the point. So I coded like this:

    import flash.events.Event;

    var starsArray:Array = new Array();

    var maxStarss:Number = 8;

    function addStars(e:Event)

    {

    Stars: var = new stars Stars();

    Stars.x = stage.stageWidth/2;

    Stars.y = stage.stageHeight/2;

    Stars.Alpha = Math.Random () *.8 +. 2;

    stars.scaleX = stars.scaleY = Math.Random () *.8 +. 2;

    stars.xMovement = Math.Random () * 10 - 5;

    stars.yMovement = Math.Random () * 10 - 5;

    starsArray.push (stars);

    addChild (stars);

    stars.cacheAsBitmap = true;

    If (starsArray.length > = maxStarss)

    {

    removeChild (starsArray.shift ());

    }

    stars.addEventListener (Event.ENTER_FRAME, moveStars);

    stars.addEventListener (Event.ENTER_FRAME, animeStars);

    }

    function animeStars(e:Event)

    {

    trace (this.starsArray);

    this.scaleX = 0.01;

    this.scaleY-= 0.01;

    This.Alpha-= 0.01;

    If (this.alpha < = 0) / / remove this object from scene

    }

    function moveStars(e:Event)

    {

    e.currentTarget.x += e.currentTarget.xMovement;

    e.currentTarget.y += e.currentTarget.yMovement;

    }

    var myTimer:Timer = new Timer (50);

    myTimer.addEventListener (TimerEvent.TIMER, addStars, animeStars);

    myTimer.start ();

    I couldn't make it work. "I got was an error message saying"


    1084: syntax error: expecting identifier before rightbrace.

    Help?

    Try this:

    var starsArray:Array = new Array();
    
    var myTimer:Timer = new Timer(50);
    myTimer.addEventListener(TimerEvent.TIMER, addStars);
    myTimer.start();
    
    addEventListener(Event.ENTER_FRAME, moveStars);
    
    function addStars(e:TimerEvent):void
    {
              var star:Stars = new Stars();
              star.x = stage.stageWidth / 2;
              star.y = stage.stageHeight / 2;
              star.alpha = Math.random() * .8 + .2;
              star.scaleX = star.scaleY = Math.random() * .8 + .2;
              star.xMovement = Math.random() * 10 - 5;
              star.yMovement = Math.random() * 10 - 5;
              starsArray.push(star);
              addChild(star);
              star.cacheAsBitmap = true;
    }
    
    function moveStars(e:Event):void
    {
              for each (var star:MovieClip in starsArray)
              {
                        star.x += star.xMovement;
                        star.y += star.yMovement;
                        star.alpha -= .01;
                        star.scaleX = star.scaleY -= .01;
                        if (star.scaleX <= 0)
                                  kill(star);
              }
    }
    
    function kill(star:MovieClip):void
    {
              starsArray.splice(starsArray.indexOf(star), 1);
              removeChild(star);
    }
    

    Post edited by: Andrei1

  • CS6 breeze ActionScript 2.0 projects. No property var TextInput or label.

    I've been programming for years, but I am brand new to Flash. For various reasons, I need to learn ActionScript 2.0 instead of 3.0. All I could get from Adobe's Web site is piloted CS6.

    When I look at tutorials for AS2, such as TextInput and label controls are supposed to have a variable associated with them. In code, you can simply get/set this variable to read/change the contents of the control. For example: http://youtu.be/H_TEa6i2Bhk?t=2m57s

    However, controls CS6, TextInput and Label have no property 'var' that I can find. After hours without success, I decided to download some examples of projects in AS2 and open them to see what they look like. Here's that I tried: http://www.freeactionscript.com/2009/07/endless-parallax-scrolling/

    Notice at the bottom of the flash window are labels for x and accelerate this change dynamically when you use arrow keys. The zip contains the .fla and .swf files. When I run the .swf file, it works fine. When I open the FLA file in Flash Pro CS6 and press Ctrl + Enter (which overrites the .swf file), everything works EXCEPT the labels is no longer up-to-date. The crushed .swf file no longer works correctly, as expected.

    I tried this on several other examples and in any case all the Label and TextInput controls functioned properly. When I go to file-> ActionScript settings, it says ActionScript 2.0. What I am doing wrong?

    You might be correct to the extent of the CS6 break use the AS2 files of the textfields.  If I use an earlier version (CS3) the documents in the file and the textfields are updated.  As soon as I open it with CS6 the textfields fail.  So the short answer is, you do not have something wrong.

    The tutorial that you pointed out might be good for you to learn a few things you should do as far as bad design practices go.  I don't know why but a lot of tutorials learn bad practices.  If you work with designs of others, then you will probably need to know the good and bad practices, otherwise, you might not find things.

    (1) using the property of textfields "var" is not a recommended practice.  What you need to do, is to assign an instance of the textfield name and assign the text through the 'text' of the textfield property.

    textFieldNameX.text = String (speedX); convert numeric values to strings

    (2) code of investment 'on' objects - avoid it.  Yet once, assign instance names to the object and assign features using these names in the scenario, rather than 'on' objects.  It allows to find the code easier and constitutes a reference point more clear, hence the code is targeting.

    On (Release) {...}  place on the object

    becomes

    objectName.onRelease = function() {...}

    on the timeline that contains the object

  • solution using parent instruction in CS3

    Dear forum!

    I found wrong in using the term 'parent' in the ESP script in CS3. wherelse in CS5.5 it works like a honey.

    And honestly to say, from the discussion of Mr. Jump_over ...

    app.findTextPreferences.findWhat = "text";

    app.changeTextPreferences.changeTo = "hardware";

    myFound = myFrame.findText ();

    var k = myFound.length;

    While (k)-

    If (myFound [k].parent.constructor.name! == 'Cell')

    myFound [k] .changeText ();

    It does not work in CS3. (ESTK says If (myFound [k].parent.constructor.name! == 'Cell') and said ""undefined is not an object ";")

    I guess that the problem may due to the Parent phrase. In CS5.5, this error has not been met.

    Thank you

    @Chand...

    Hello

    I think is not a "parent" but "constructor.name.

    I'm not experienced with CS3 but you can try to use this:

    while(k--) {
         try {
              myFound[k].parent.parentStory;     // error if parent == "Cel" so omited
              myFound[k].changeText();
              }
         catch (e) { continue }
         }
    

    Jarek

  • flashplayer in AE CS3

    Hello

    I try to add a flashplayer to my window in AE CS3, but it does not work, Flash Player is not recognized.

    Is this normal?

    Thanks in advance,

    Fred

    You can find the answer here: http://www.kahrel.plus.com/indesign/scriptui.html (PDF, 1-10, page 57)

    var l is new window ('dialog', 'Butterfly');.

    Flash var = w.add ("flashplayer", undefined, file ("' / d/scriptui/wave.swf" "));

    w.Show ();

  • This script works under the cs5? display and if adapt to screen imported from cs3

    Hello

    I used to run this script every time that I open a photo in photoshop cs3 on xp

    now I use cs5 and windows 7

    I use this script to load the photo under the eyes and fit the image of the screen

    Image on screen adjustment

    Attach to the event Open Document in Photoshop CS 2

    // =======================================================

    var id57 = charIDToTypeID ("TPCV");

    var desc15 = new ActionDescriptor();

    var id58 = charIDToTypeID ("null");

    ref6 var = new ActionReference();

    var id59 = charIDToTypeID ("min");

    var id60 = charIDToTypeID ("MnIt");

    var id61 = charIDToTypeID ("FtOn");

    Ref6.putEnumerated (id59, id60, id61);

    desc15.putReference (id58, ref6);

    executeAction (id57, desc15, DialogModes.NO);

    //=======================================================

    id20 var = charIDToTypeID ("TPCV");

    var desc7 = new ActionDescriptor();

    id21 var = charIDToTypeID ("null");

    Ref3 var = new ActionReference();

    id22 var = charIDToTypeID ("min");

    var id23 = charIDToTypeID ("MnIt");

    var id24 = stringIDToTypeID ("screenModeFullScreenWithMenubar");

    Ref3.putEnumerated (id22, id23, id24);

    desc7.putReference (id21, ref3);

    executeAction (id20, desc7, DialogModes.NO);

    but I did notice the photo in photoshop is not very strong , I have the zoom with the mouse wheel it to be sharper

    What's wrong?

    the script is not compatible with cs5?

    is there something wrong in my setup?

    Thank you

    see you soon

    either by the way, I use another script to start photoshop

    selectTool ('handTool');

    selectTool ('handTool');

    function selectTool (tool) {}

    var desc9 = new ActionDescriptor();

    ref7 var = new ActionReference();

    Ref7.putClass (app.stringIDToTypeID (tool));

    desc9.putReference (app.charIDToTypeID ('null'), ref7);

    executeAction (app.charIDToTypeID ('slct'), desc9, DialogModes.NO);

    };

    Good Yes it works a bit strange in cs5.

    It seems to work better if the mode full screen with the menu bar is run first, then to adapt to the screen.

    Like this:

    Image on screen adjustment

    Attach to the event Open Document in Photoshop CS 2

    //=======================================================

    id20 var = charIDToTypeID ("TPCV");

    var desc7 = new ActionDescriptor();

    id21 var = charIDToTypeID ("null");

    Ref3 var = new ActionReference();

    id22 var = charIDToTypeID ("min");

    var id23 = charIDToTypeID ("MnIt");

    var id24 = stringIDToTypeID ("screenModeFullScreenWithMenubar");

    Ref3.putEnumerated (id22, id23, id24);

    desc7.putReference (id21, ref3);

    executeAction (id20, desc7, DialogModes.NO);

    // =======================================================

    var id57 = charIDToTypeID ("TPCV");

    var desc15 = new ActionDescriptor();

    var id58 = charIDToTypeID ("null");

    ref6 var = new ActionReference();

    var id59 = charIDToTypeID ("min");

    var id60 = charIDToTypeID ("MnIt");

    var id61 = charIDToTypeID ("FtOn");

    Ref6.putEnumerated (id59, id60, id61);

    desc15.putReference (id58, ref6);

    executeAction (id57, desc15, DialogModes.NO);

  • Problem of passage from CS3 to CS4 - adding files to book

    I had a script which worked beautifully in CS3. Now, we moved to CS4 and he refuses to cooperate with me. I tried a solution on the forum, but it does not work for me.

    Creating book

    var myBookFileName = monchemin + custom "Modules/PW.indd";
    myBookFile = new file (myBookFileName);
    myBook = app.open (myBookFile);
    myBook = app.books.add (myBookFile);

    Add the cover page
    myFilename = monchemin + custom "Modules/PW_Cover.indd";
    myFile = File (myFilename);
    myBook.bookContents.add (myFile);

    Add the rest of the personal folders

    ...

    For some reason, when it comes to the bookContents.add statement, it opens a save as dialog box. I wonder if there is a setting in InDesign CS4, rather than a script problem.

    I would really have no idea.

    B

    Looks like you are trying to add a document in CS3 in a new book of CS4. InDesign wants to save the CS3 CS4 document and therefore gives you the Save as dialogue box. You can go through all the existing CS3 documents you want to add and save out them of CS4, or add a few lines of the script that will do it. (Change the name of the variable I used if it is used elsewhere in your script.)

    // Creating book
    
    var myBookFileName = myPath+"Personalized Modules/PW.indd";
    myBookFile = new File( myBookFileName );
    myBook = app.open( myBookFile );
    myBook = app.books.add( myBookFile );
    
    // Add the front cover
    myFilename = myPath+"Personalized Modules/PW_Cover.indd";
    myFile = File(myFilename);
    
    // Save cover document in current version
    myDoc = app.open(myFile,false);
    myDoc.save(myFile)); // will overwrite CS3 file with CS4 file
    myDoc.close();
    
    myBook.bookContents.add(myFile);
    
    // Add the rest of the individual files
    

    I didn't test this code. Let me know if you have any problems.

    Jeff

  • Can you put mosaic windows from Javascript in CS3?

    I have a javascript that opens 2 images in Photoshop in different directories, based on a unique file name, so that users can view them side by side. They need this to be able to compare the color correction of a process automated against the original image.

    The problem is that even if I can open the pictures, I can't invoke the "window/arrange/tile vertically' menu item, I can with InDesign.

    Does anyone know a trick to work around the tile missing command vertically in Javascript for Photoshop CS3.

    (I searched the web and found that most of the responses are for windows 4 or more, where the images are pasted into a doc.) "But here, I need to keep the separate windows).

    One way to do this in CS3 is an action. A new action, and then stop recording. There should be no steps in the action. Choose the Insert menu in the Panel popup menu action. Then choose the "window/arrange/tile vertically' menu item. You now have an action that you can call from a scipt to place the two images.

    Another way is to use the doMenuItem Xbytor

    // adatped from Xbytor's xtools stdlib.jx
    doMenuItem = function(item, interactive) {
       var ref = new ActionReference();
       ref.putEnumerated(charIDToTypeID("Mn  "), charIDToTypeID("MnIt"), item);
       var desc = new ActionDescriptor();
       desc.putReference(charIDToTypeID("null"), ref);
       try {
         var mode = (interactive != true ? DialogModes.NO : DialogModes.ALL);
         executeAction(stringIDToTypeID("select"), desc, mode);
       } catch (e) {
         if (!e.message.match("User cancelled")) {
           throw e;
         } else {
           return false;
         }
       }
       return true;
    };
    doMenuItem(stringIDToTypeID('tileVertically'));
    

    Note more recent version of Photoshop have a method of application named runMenuItem that can be used instead of a custom function.

  • Fill the var using XML

    Hello

    I just started to use Flash (im using Flash CS3) and I'm trying to get this collaborative project. I have a gallery of thumbnails scroll, and I want to be able to adjust how many thumbnails are initially loaded based on a value in my XML file (so that the Gallery can later be changed without having to actually enter the .fla)

    When I do this I get

    var myXML:XML;
    var myLoader:URLLoader = new URLLoader();

    myLoader.load(new URLRequest("galaxy.xml"));
    myLoader.addEventListener(Event.COMPLETE, processXML);

    function processXML(e:Event):void {
         myXML = new XML(e.target.data);
         trace(myXML.thumbnails.thumbnail); // output is 9, which is correct
    }

    But if I suggest that trace here...

    var myXML:XML;
    var myLoader:URLLoader = new URLLoader();

    myLoader.load (new URLRequest ("galaxy.xml"));
    myLoader.addEventListener (Event.COMPLETE, processXML);

    function processXML(e:Event):void {}
    myXML = new XML (e.target.data);
    }
    trace (myXML.thumbnails.Thumbnail); output is TypeError: Error #1009: cannot access a property or method of a null object reference.

    I tried to figure this out for a few days. I understand that this does not work because I'm tracing the 'thumbnail' in my XML until it is loaded, but I could not find a solution that works for me. Basiclly I want to be able to define variables of 3 or 4 in my XML and use later in my AS3.

    Important variables that I want to set are:

    thumbsize var

    var n: Number

    var stageVar:Number

    Here's the complete code.

    this.scaleMode = StageScaleMode.NO_SCALE;
    this.align = StageAlign.TOP;

    var myXML:XML;
    var myLoader:URLLoader = new URLLoader();

    myLoader.load(new URLRequest("galaxy.xml"));
    myLoader.addEventListener(Event.COMPLETE, processXML);

    function processXML(e:Event):void {
         myXML = new XML(e.target.data);
         trace(myXML.thumbnails.thumbnail);
    }
    //trace(myXML.thumbnails.thumbnail)

    var thumbsize = 100;//(myXML.thumbnails.thumbsize);// spaceing, 100 is tight together, 101 has 1 pix space
    var n:Number = 8;//(myXML.thumbnails.thumbnail);//number of thumbnails to create
    var stageVar:Number =  800;// (myXML.stage.stadgewidth)
    Stage.width = 800;//(myXML.stagesize.stadgewidth); //800
    var id:Number;
    var a:Number = 0;
    var basename:String = "universe";
    var speed:Number = 10;
    var touchingBar:Boolean = false;

    maskShape.width = 800;//800 or n * thumbsize
    maskShape.x = holder.x;
    maskShape.y = holder.y;
    maskShape.height = thumbsize * 2;// multiplied by 2 to cover the reflection

    var blank:Sprite = new Sprite();//populates and is deleted to prevent error when trying to remove old image when a new one is clicked
    loadArea.addChildAt(blank, 1);

    holder.mask = maskShape;


    while ( a < n ) {

         with (holder) {

              var thumb_holder:MovieClip = new thumb();
              thumb_holder.x = a * thumbsize;
              thumb_holder.id = a;
              addChild(thumb_holder);

              var thumb_holder2:MovieClip = new thumb();
              thumb_holder2.x = (a + n) * thumbsize;
              thumb_holder2.id = a;
              addChild(thumb_holder2);

              var thumb_holder3:MovieClip = new thumb();
              thumb_holder3.x = (a - n) * thumbsize;
              thumb_holder3.id = a;
              addChild(thumb_holder3);

         }
         a = a + 1;
    }



    this.addEventListener(Event.ENTER_FRAME, movingCode);

    function movingCode(event:Event):void {

         holder.x = holder.x + speed;


         //repeating thumbnails
         if (holder.x >= thumbsize * n && speed > 0) {
              holder.x = 0;
         }
         if (holder.x < thumbsize * -n && speed < 0) {
              holder.x = 0;
         }
         //change the speed of the thumbnails

         if (touchingBar == false) {

              if (root.mouseX < stageVar * .23) {
                   speed = 10;
              }
              if (root.mouseX < stageVar * .15) {
                   speed = 20;
              }
              if (root.mouseX > stageVar * .85) {
                   speed = -10;
              }
              if (root.mouseX > stageVar * .94) {
                   speed = -20;
              }
              //stop the thumbnail scroll
              if (root.mouseX > stageVar * .4 && root.mouseX < stageVar * .8) {
                   speed = 0;
              }
         }
         if (touchingBar == true) {
              speed = 0;
         }

    }

    I'm sure it's something totally noob and asked a hundred times in front of me, but any help at all will be fantastic.

    Thank you!

    Code is not expected to run, then the code after this function executes while the file is already loaded.  It as the first trace has worked for you, you need to assign values to variables that are assigned from the xml inside the function that is executed when the loading is complete.  Everything is based on the xml data must be held remote execution from within this function.

  • JS CS3 app.notifiersEnabled at startup.

    I know that I can use the Script event handler to enable or disable scripts, but cannot so any user.  I want to do is have a startup script to ensure myScript.jsx is always activated and assigned to the event to open the file.

    using the:

    #target photoshop
    app.notifiersEnabled = true;
    var eventFile = new File(app.path +"/Presets/Scripts/Event Scripts Only/myScript.jsx");
    app.notifiers.add("Opn ", eventFile);

    and put in the folder C:\Program Files\Common Files\Adobe\Startup CS3\Adobe of Scripts Photoshop all right. If I go into Photoshop, disable the "enable events to run Scripts/Actions:" option and close, and then reopen the option is enabled by default in Photoshop.

    The problem is that if I start In Design (or any other application CS3) I get the following error:

    err.jpg

    Why the other application acceding the folder C:\Program Files\Common Files\Adobe\Startup CS3\Adobe Scripts Photoshop ?

    CS3\Adobe Photoshop startup script doesn't mean me that Photoshop will have access to this folder.

    Is there a way to app.notifiersEnabled = true when you start Photoshop?

    Cheers, John.

    Yes you are right. It should be is

  • [JS CS5] difference between CS3 and 5 with paragraph.contents?

    It drives me crazy. I'm updating of scripts which ran well in CS3 so that they work in CS5. I ran into a strange (for me) behavior.

    After running the following in CS4:

    var myParagraph = myStory.paragraphs.item (myParagraphCounter);

    myParagraph.contents = "< LI >" + myParagraph.contents

    myParagraph.contents returns 'paragraph < LI > the text of the original.

    But after running the same lines in CS5:

    myParagraph.contents returns only "the text of the original paragraph.

    What happens here? This seems to be a real thing base... According to me, only missing me something obvious.

    I don't know, but as it's the replacement content is dangerous.

    I would do something like this:

    "myParagraph.insertionPoints [0] = .silence"

  • ";

    It works as expected?

    Substances

  • CS3 and Delphi: Place pdf in indesign

    Hello

    I'm developing a script with Deplhi that automates the creation of documents.

    I would like to be able to place pdf documents in an InDesign document. I adapted a script I found in this thread: http://forums.adobe.com/message/3013174

    I didn't define the types appropriate for variables, because Delphi does not not typed variables. There was a line in particular that I had to change completely:

    myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];

    The nervous parameter must be an array of double, and missing parameters should be defined. Finally, the following worked:

    var
      APoint:      array of double;

    begin
      ...
      SetLength(APoint, 2);
      APoint[0] := 0;
      APoint[1] := 0;
      myPage.place(Filename, APoint, ActiveDocument.Layers[1], false, false);
      ...

    Original, the result of the function of the place is assigned to the myPDFPagevariable in the script, and I have problems to get this assignment work. Often uses TypeLib by as olevariants and we must understand ourselves what types are permitted and must be used, and what kind of actors.

    In the original script follows this code:

    myFirstPage = myPDFPage.pdfAttributes.pageNumber;

    Only interfaces in the type library that have a property called pdfAttributes are PDF and ImportedPage. But none of these types of work if I set pdfAttributes of this type. I'm not sure if that place seems to return a table only adds additional problems. Most of the time, TypeLib tables are based at index 1, not zero.

    But I tried

    var
      APoint:      array of double;
      myPDFPage:   PDF;
    begin
      ...
     
    myPDFPage := PDF(myPage.place(Filename, APoint, ActiveDocument.Layers[1], false, false)[0]);
      ...

    and

    var
      APoint:      array of double;
      myPDFPage:   ImportedPage;
    begin
      ...
     
    myPDFPage := ImportedPage(myPage.place(Filename, APoint, ActiveDocument.Layers[1], false, false)[0]);
      ...

    and even with the array index to 1 instead of 0 and without a clue. But none of this should be compiled without error.

    Justifications know how this command line must be or what type of myPDFPage ?

    And more generally: how could determine the types possibla of a parameter, variable, or return type which is an OleVariant in the type library?

    I found a few InDesign CS3 scripts specific documents PDF here: http://www.adobe.com/products/indesign/scripting/, but no reference full of functions and types.

    Best regards

    Christian Kirchhoff

    Hi Christian

    I don't know if anyone else uses Delphi on this forum.

    But here is what I get JS - we will perform a simple test:

    var doc = app.activeDocument;
    var myPDFFile = new File("~/Desktop/Sample.pdf");
    var page = doc.pages[0];
    app.pdfPlacePreferences.pageNumber = 1;
    var a1 = page.place(myPDFFile, [0,0]);
    var a2 = a1[0];
    

    A1 returns an array of objects PDF, but declare you it as doubles. AFAIK, it is always an array of single item since you cannot place more than one page pdf at a time.
    A2.constructor.name;
    Result: array

    A2 returns the class PDF object
    A2.constructor.name;
    Result: PDF

    Kasyan

  • ID JS CS2 - CS3: copy items inline/anchored in a new layer...

    Hello:

    I was wondering if someone has a script to copy an object inline/embedded and place a copy of it in the same position on a new layer without him being anchored to what anyone on the new layer? I don't want to remove the embedded/inline object from the first layer. I want to just copy the size and position on a new layer.

    I would be very grateful for your help.

    Thank you!

    Theresa

    Hey!

    Try this: (this has been tested in CS5 and CS4, but it should work in CS3 as well)

    var myDoc = app.activeDocument;
    
    // use to process entire document
    var myItems = myDoc.allPageItems;
    
    // use to process just current page
    // var myItems = app.activeWindow.activePage.allPageItems;
    
    var foundObjects = Array();
    
    for(var i = 0; i < myItems.length; i++){
      if(myItems[i].parent instanceof Character){foundObjects.push(myItems[i]);}
    }
    
    if(foundObjects.length > 0){
      var myDestLayer = myDoc.layers.add({name:"Anchor/Inline Duplicates"});
      for(var i = 0; i < foundObjects.length; i++){
        var newDuplicate = foundObjects[i].duplicate(myDestLayer);
        newDuplicate.geometricBounds = foundObjects[i].geometricBounds;
        try{newDuplicate.graphics[0].geometricBounds = foundObjects[i].graphics[0].geometricBounds;}catch(_){}
      }
    }
    

    I hope that helps!

    --

    tomaxxi

    http://indisnip.WordPress.com/

  • RTF export does not work in CS3

    Dear Guys,

    I am new in this field.

    With the reference of the InDesign CS3 scripting guides, I exported out of a Document InDesing TXT.

    But I can't export RTF output.

    Can someone help me on this?

    Thank you

    SaRaVaNaN.N

    I redid a little the ExportAllText.jsx script (from InDesign CS3 guide scripts package).

    Now it exports all stories in a single rtf file: C:\Exported 1.rtf

    All by running the script creates and deletes a temporary file: C:\Temporary file.txt

    if(app.documents.length != 0){
         if(app.documents.item(0).stories.length != 0){
              myExportAllText(app.documents.item(0).name);
         }
    }
    function myExportAllText(myDocumentName){
         var myStory;
         //File name for the exported text. Fill in a valid file path on your system.
         var myTempFile = new File("/c/Temporary File.txt");
         //If you want to add a separator line between stories, set myAddSeparator to true.
         var myAddSeparator = true;
         var myNewDocument = app.documents.add();
         var myDocument = app.documents.item(myDocumentName);
         var myTextFrame = myNewDocument.pages.item(0).textFrames.add({geometricBounds:myGetBounds(myNewDocument, myNewDocument.pages.item(0))});
         var myNewStory = myTextFrame.parentStory;
         for(myCounter = 0; myCounter < myDocument.stories.length; myCounter++){
              myStory = myDocument.stories.item(myCounter);
              //Export the story as tagged text.
              myStory.exportFile(ExportFormat.taggedText, myTempFile);
              //Import (place) the file at the end of the temporary story.
              myNewStory.insertionPoints.item(-1).place(myTempFile);
              //If the imported text did not end with a return, enter a return
              //to keep the stories from running together.
              if(myCounter != myDocument.stories.length -1){
                   if(myNewStory.characters.item(-1).contents != "\r"){
                        myNewStory.insertionPoints.item(-1).contents = "\r";
                   }
                   if(myAddSeparator == true){
                        myNewStory.insertionPoints.item(-1).contents = "----------------------------------------\r";
                   }
              }
         }
         myNewStory.exportFile(ExportFormat.RTF, File("/c/Exported Text.rtf"));
         myNewDocument.close(SaveOptions.no);
    
         try {
              myTempFile.remove();
         }
         catch(e){}
    
         alert("Done.");
    }
    
    function myGetBounds(myDocument, myPage){
         var myPageWidth = myDocument.documentPreferences.pageWidth;
         var myPageHeight = myDocument.documentPreferences.pageHeight
         if(myPage.side == PageSideOptions.leftHand){
              var myX2 = myPage.marginPreferences.left;
              var myX1 = myPage.marginPreferences.right;
         }
         else{
              var myX1 = myPage.marginPreferences.left;
              var myX2 = myPage.marginPreferences.right;
         }
         var myY1 = myPage.marginPreferences.top;
         var myX2 = myPageWidth - myX2;
         var myY2 = myPageHeight - myPage.marginPreferences.bottom;
         return [myY1, myX1, myY2, myX2];
    }
    
  • What is the variable of links selected for myLinks = var

    Hi, I need to run a script only for the selected links in the

    the links Panel, but I don't know the variable, for example the myLinks var = myDoc.links is for all document´s links

    Here's a version that rebuilt all the links - missing not only those.

    #target indesign
    
    if (Number(String(app.version).split(".")[0]) < 5) ErrorExit("This script requires InDesign CS3 or higher.");
    if (app.documents.length == 0) ErrorExit("Please open a document and try again.");
    
    var gDoc = app.activeDocument;
    var gLinks = gDoc.links;
    
    if (gLinks.length == 0) ErrorExit("This document doesn't contain any links.");
    //~ if (GetMissingLinks().length == 0) ErrorExit("This document doesn't contain any missing links.");
    
    if (app.extractLabel("Kas_RepairMissingLinksInSelectedFolders_ver3.0") != "") {
         var gSet = eval(app.extractLabel("Kas_RepairMissingLinksInSelectedFolders_ver3.0"));
    }
    else {
         var gSet = {}
         gSet.folders = [];
    }
    
    var gCounter = 0;
    var gSelectedFolders = [];
    
    CrearLabels();
    
    CreateDialog();
    
    //-------------------------------------- FUNCTIONS ---------------------------------------------
    function CreateDialog() {
         var dlg = new Window("dialog", "Repair missing links");
         dlg.orientation = "column";
         dlg.alignChildren = "top";
         dlg.btnPnl = dlg.add("panel", undefined, "Folders");
         dlg.btnPnl.orientation = "column";
         dlg.btnPnl.helpTip = "The script will search missing images in these folders";
         dlg.btnPnl.listBox = dlg.btnPnl.add("listbox", undefined, gSet.folders, {multiselect:true});
         var myListBoxBounds = [0, 0, 467, 160];
         dlg.btnPnl.listBox.bounds = myListBoxBounds;
    
         // Buttons
         dlg.btnPnl.grp = dlg.btnPnl.add("group");
         dlg.btnPnl.grp.orientation = "row";
         dlg.btnPnl.grp.addBtn = dlg.btnPnl.grp.add("button", undefined, "Add");
         dlg.btnPnl.grp.addBtn.helpTip = "Add a  folder to the list";
         dlg.btnPnl.grp.removeBtn = dlg.btnPnl.grp.add("button", undefined, "Remove");
         dlg.btnPnl.grp.removeBtn.helpTip = "Remove the selected  folders from the list";
         dlg.btnPnl.grp.remAllBtn = dlg.btnPnl.grp.add("button", undefined, "Remove All");
         dlg.btnPnl.grp.remAllBtn.helpTip = "Remove all  folders from the list";
    
         // Ok & Cancel
         dlg.grp = dlg.add("group");
         dlg.grp.orientation = "row";
         dlg.grp.alignment = "center";
         dlg.grp.okBtn = dlg.grp.add("button", undefined, "OK");
         dlg.grp.cancelBtn = dlg.grp.add("button", undefined, "Cancel");
         // ---------------------------------------------------------------
         dlg.btnPnl.grp.addBtn.onClick = function() {
              var myFolder = Folder.selectDialog ("Select a folder");
              if (myFolder != null) {
                   if (!IsInArray(myFolder.fsName, gSet.folders)) {
                        gSet.folders.push(myFolder.fsName);
                        var myBounds = dlg.btnPnl.listBox.bounds;
                        dlg.btnPnl.remove(dlg.btnPnl.listBox);
                        dlg.btnPnl.listBox = dlg.btnPnl.add("listbox", myBounds, gSet.folders, {multiselect:true});
                        dlg.btnPnl.listBox.bounds = myListBoxBounds;
                   }
                   else {
                        alert("This folder has been already added.");
                   }
              }
         }
         // ---------------------------------------------------------------
         dlg.btnPnl.grp.removeBtn.onClick = function() {
              if (dlg.btnPnl.listBox.selection != null) {
                   for (var i = dlg.btnPnl.listBox.selection.length - 1; i  >= 0; i --) {
                        gSet.folders.splice(dlg.btnPnl.listBox.selection[i].index, 1);
                        dlg.btnPnl.listBox.remove(dlg.btnPnl.listBox.selection[i]);
                   }
              }
         }
         // ---------------------------------------------------------------
         dlg.btnPnl.grp.remAllBtn.onClick = function() {
              dlg.btnPnl.listBox.removeAll();
              gSet.folders = [];
         }
         // ---------------------------------------------------------------
         dlg.grp.okBtn.onClick = function() {
              gSet.folders = [];
              for (j = 0; j < dlg.btnPnl.listBox.items.length; j++) {
                   gSet.folders.push(dlg.btnPnl.listBox.items[j].text);
              }
              dlg.close(1);
         }
         // ---------------------------------------------------------------
         dlg.grp.cancelBtn.onClick = function() {
              dlg.close(0);
         }
         // ---------------------------------------------------------------
         var myDialogResult = dlg.show();
         if (myDialogResult) {
              app.insertLabel("Kas_RepairMissingLinksInSelectedFolders_ver3.0", gSet.toSource());
              Main();
         }
    }
    //--------------------------------------------------------------------------------------------------
    function Main() {
         if (gSet.folders.length == 0) ErrorExit("No folders have been selected in the dialog box.", true);
         var missingFolders = [];
    
         for (var f = 0; f < gSet.folders.length; f++) {
              var theFolder = new Folder(gSet.folders[f]);
              if (theFolder.exists) {
                   gSelectedFolders.push(theFolder);
                   AddSubFolders(theFolder);
              }
              else {
                   missingFolders.push(theFolder);
              }
         }
    
         if (gSelectedFolders.length == 0) ErrorExit("All selected folders don't exist.", true);
         if (missingFolders.length > 0) {
              var missingFoldersList = [];
              for (var m = 0; m < missingFolders.length; m++) {
                   missingFoldersList.push(missingFolders[m].displayName);
              }
              if (!confirm("These folders are missing:\r" + missingFoldersList.join("\r") + "\r\rDo you want to continue?", false, "Warning")) exit();
         }
    
         var w = new Window ("window", "Starting relinking files");
         var pb = w.add ("progressbar", [12, 12, 350, 24], undefined, undefined);
         var txt = w.add("statictext");
         txt.bounds = [0, 0, 340, 20];
         txt.alignment = "left";
         w.show();
         var pbCounter;
    
         for (var s = 0; s < gSelectedFolders.length; s++) {
              var currentFolder = gSelectedFolders[s];
              w.text = "Current folder - \"" + currentFolder.displayName + "\"";
    
              pb.minvalue = 0;
              pbCounter = 0;
              pb.maxvalue = gLinks.length;
    
              for (var i = gLinks.length-1; i >= 0 ; i--) {
                   pbCounter++;
                   pb.value = pbCounter;
                   var theLink = gLinks[i];
                   txt.text = String("Relinking file - " + theLink.name + " (" + (gCounter +1) + ")");
    
                   if (theLink.extractLabel("relinked") != "yes") {
                        var oldImageFile = new File(theLink.filePath);
                        var oldPath = oldImageFile.toString();
                        var newPath = currentFolder.absoluteURI + "/" + theLink.name.replace(" ", "%20");
                        if (oldPath != newPath) {
                             if ( // If the link is not a text file
                                  theLink.linkType != "InCopyInterchange" &&
                                  theLink.linkType != "InCopyStory" &&
                                  theLink.linkType != "InCopyMarkup" &&
                                  theLink.linkType != "Microsoft Excel Import Filter" &&
                                  theLink.linkType != "Microsoft Word Import Filter" &&
                                  theLink.linkType != "RTF Import Filter" &&
                                  theLink.linkType != "Text"
                                  ) {
    
                                  Relink(newPath, theLink);
    
                             }
                        }
                   }
              }
    
         } // end for
    
         w.close();
    
         if (gCounter == 1) {
              alert("One file has been relinked.", "Finished");
         }
         else if  (gCounter > 1) {
              alert(gCounter + " files have been relinked.", "Finished");
         }
         else {
              alert("Nothing has been relinked.", "Finished");
         }
    }
    //--------------------------------------------------------------------------------------------------
    function Relink(myNewPath, myLink) {
         var myNewLink =  new File(myNewPath);
         if (myNewLink.exists) {
              myLink.relink(myNewLink);
    
              try {
                   var myCurrentLink = myLink.update();
              } catch(e){}
    
              if ( app.version.substr(0, 3) == "6.0" && (parseInt(app.version.substr(4, 1)) >= 4) ) {
                   myLink.insertLabel("relinked", "yes");
              }
              else {
                   myCurrentLink.insertLabel("relinked", "yes");
              }
              gCounter++;
         }
         else {
         }
    }
    //--------------------------------------------------------------------------------------------------
    // Clear labels in case this script has been already run on the current document
    function CrearLabels() {
         for (var f =  0; f < gDoc.links.length; f++) {
              if (gDoc.links[f].extractLabel("relinked") != "") {
                   gDoc.links[f].insertLabel("relinked", "");
              }
         }
    }
    //--------------------------------------------------------------------------------------------------
    function ErrorExit(myMessage, myIcon) {
         alert(myMessage, "Repair missing links", myIcon);
         exit();
    }
    //--------------------------------------------------------------------------------------------------
    function IsInArray(myString, myArray) {
         for (x in myArray) {
              if (myString == myArray[x]) {
                   return true;
              }
         }
         return false;
    }
    //--------------------------------------------------------------------------------------------------
    function AddSubFolders(theFolder) {
         var fileList = theFolder.getFiles();
         for (var i = 0; i < fileList.length; i++) {
              var theFile = fileList[i];
              if (theFile instanceof Folder) {
                   gSelectedFolders.push(theFile);
                   AddSubFolders(theFile);
              }
         }
    }
    //--------------------------------------------------------------------------------------------------
    

Maybe you are looking for