PSEvents via ExternalInterface

Hello,
I'm trying to add in Photoshop Extended an Event listener for Count Tools items, so each time the user adds one, something should happen. Alas, it doesn't.
In Extension Builder I've added the CSHA lib.
PSEvents are not well documented in the reference, imho, compared to AI events for instance, where there's at least a line of explanation. Anyway, there's no mention of counters, nor in the Photoshop Event Codes table.
As CS SDK Help suggests (Photoshop Guide page, in the Product-specific Guide), I have to use ExternalInterface; ScriptingListener code for Count adding is as follows:
// =======================================================
var idcountAdd = stringIDToTypeID( "countAdd" );
    var desc4 = new ActionDescriptor();
    var idX = charIDToTypeID( "X   " );
    desc4.putDouble( idX, 1917.500000 );
    var idY = charIDToTypeID( "Y   " );
    desc4.putDouble( idY, 413.500000 );
executeAction( idcountAdd, desc4, DialogModes.NO );
// =======================================================
So in the mxml I've added:
private const COUNTER:int = Photoshop.app.stringIDToTypeID( "countAdd" );
private function onCreationComplete():void
     model = AppModel.getInstance();
     CSXSInterface.instance.evalScript("PhotoshopRegisterEvent", COUNTER);
     ExternalInterface.addCallback("PhotoshopCallback" + CSXSInterface.getInstance().getExtensionId(), myPhotoshopCallback)
private function myPhotoshopCallback(eventID:Number, descID:Number):void
     var desc:ActionDescriptor = new ActionDescriptor();
     desc.fromID(descID);
     switch (eventID)
          case COUNTER:
               trace("Counter added")
               break;
And it doesn't work at all. Moreover, I keep getting "PSHostAdapter not found in the Adobe Photoshop CS5 plugins. It may not be available for the Host Adapter libraries." error from Flash Builder.
What's wrong?!
Any help is really appreciated!
Thanks in advance
Davide Barranca

Listening for two events instead of only one make it work:
private const COUNTER:int = Photoshop.app.stringIDToTypeID( "countAdd" );
private const COPY_INT:int  = Photoshop.app.charIDToTypeID('copy');
private function onCreationComplete():void
     model = AppModel.getInstance();
     CSXSInterface.instance.evalScript("PhotoshopRegisterEvent", COPY_INT + "," + COUNTER);
     ExternalInterface.addCallback("PhotoshopCallback" + CSXSInterface.getInstance().getExtensionId(), myPhotoshopCallback)
private function myPhotoshopCallback(eventID:Number, descID:Number):void
     var desc:ActionDescriptor = new ActionDescriptor();    // these two lines are useless here
     desc.fromID(descID);                                   //
     switch (eventID)
          case COUNTER:
          trace("Counter fired")
          break;
       case COPY_INT:
          trace("Copy fired");
          break;    
After some extra research, I've understood that the second parameter for the addCallback should be a string, and adding the "," made it. So more properly I've added a .toString()
I still have to understand how to remove the listener. It's straightforward with PSHA with .removeEventListener(), but now with ExternalInterface?
I've also searched for documentation about "PhotoshopRegisterEvent", but I couldn't find anything useful. Where does it comes from, it's kind of a standard function? How can I find whether other similar (and possibly useful) functions exist - perhaps a "PhotoshopUnRegisterEvent" ? :-)
Too many questions...
Regards
Davide

Similar Messages

  • ExternalInterface

    Simply, it's not working.
    What happens is PHP and MySQL populate the list of all
    available songs to play. JavaScript creates the playlist when the
    user clicks the songs they want the when the user chooses to play a
    song, the url, artist, and song title are transferred to Flash via
    ExternalInterface.
    The AS works in flash, but not when it's integrated with
    JavaScript.
    Code for the .php file and .as file are provided.
    Thanks for anyone's help.

    OK...
    I want the web coder to be able to have something like this
    in their code
    (javascript)...
    newText = getTheText();
    in the flash file there is a text box with an instance name
    of 'myText'
    What I ultimately need is an easy way of getting 'newText =
    getTheText();'
    to set the variable 'newText' as the text box content.
    Tim
    "kglad" <[email protected]> wrote in message
    news:fb97d8$7b$[email protected]..
    > what's the problem? you can send parameters with the
    call method.

  • AIR to DLL via applet

    Hi,
    We are trying to build a Flex app which is supposed to work both in online and offline mode.
    Application reads images from scanner and processes it.
    Drivers are DLLs (written in C++), we wrap them in Java applet.
    We were able to connect SWF to applet via ExternalInterface.
    However, how can we connect AIR to applet ?
    I was told Merapi is the answer, however it is still in Alpha.  :-(
    They didn't even answer me when I applied to participate.
    Any help is very appreciated !
    Thank you in advance,
    Oleg.

    Michael,
    I am getting "Story Not Found" from that link,
    and the only Merapi stories on that site I could find where about Merapi volcano.
    Is that what you are referring to ?
    As for Merapi project, it's creator recently left,
    so the project seems to be dying or dead, no activity for a long time:
    http://www.merapiproject.net/index.php?option=com_fireboard&Itemid=58&func=view&id=253&cat id=8
    Any comments on that ?
    And it seems like Adobe has no alternative and doesn't care.
    So what am I to do with my problem ?
    Thank you,
    Oleg.

  • Opening a Word doc

    Hello all, I am new to Flex.  I have some experience with AS3 (still switching over from AS2).
    Anyway, I am making a Flex project where I have a text link in a datagrid.  This link needs to open a word document that is on our company network.  Currently I'm working on my own personal computer on my C drive (not sure if that affects anything - when i hit Run does it run the application from my C drive? It should still work from there i'd think?)  We have a bunch of other drives on our network, and the word doc I'm trying to open is on a "P:" drive.
    I'm not sure what I might be doing wrong, but I created a LinkButton and tried 2 different attempts at opening a Word doc.
    I tried creating a new URLRequest and navigateToURL to attempt to open the word doc - nothing happens when I click the link. The link button will launch google if i replace my word doc path with the google url.
    I tried sending the file path to javascript via ExternalInterface and having javascript open it up.  It doesn't work that way either.
    Is there something I should know about opening up a Word doc file with Flex? Or possibly is it not working because of where the file resides?  Any thoughts?
    Thanks
    -Michele

    Actually, no and yes. No you do not have to re-save all of your Word files. It depends on what you want to do with them.
    The file you have open is actually a Pages file which was created by converting the old Word file (which has not been altered at all). If you want to keep it and any changes you have made as a Pages file, you must "save as." The next time you open that file, it will open naturally in Pages. Every time you open the original Word file, since it has not been converted to native Pages, it will go through the same translating process as it did this time.

  • Embed Flash in DW Extension

    Anyone Help!?
    I'm trying to embed a Flash SWF in a DW extension. So far, so
    good ( I put it in my Command html page between form tags and it
    appears). Now I'd like it to communicate back with the JavaScript
    engine inside DW.
    Anyone know how? I know that Neil Clark made an extension a
    while back that somehow invoked another Command html page and even
    passed parameters. I downloaded it and took it apart but could not
    look inside the swf source. Did he use fscommand? Is AS3 supported
    via ExternalInterface? I've had no luck! Good 'ol fscommand seems
    to throw an obscure error: "document.embeds has no properties".

    Does anyone have any idea how this is done? The start page
    for Dreamweaver is also a Flash SWF file called welcome.swf, that
    in turn invokes various dw API calls. Trouble is, I have no idea
    what command they are using MMExecute, getURL, fscommand?

  • Is it possible to find the dimension of webpage size in flash as2.0 or 3.0

    hey
       I am working in a flash ad and i am going to upload it . when the ad gets loaded the flash should recognise the dimensional of the web page in which it gets loaded and it should takea snap of that particular web page.

    Just checked it out. Basically, what works is - you call JavaScript DOM properties via ExternalInterface and cast them to string:
    if (ExternalInterface.available) {
         var str:String = ExternalInterface.call("window.innerHeight.toString");

  • Flash downloading blocks page nav

    I know my actionscript better than I know the browser
    environment, although I'm getting to grips with javascript because
    of the similarity. But some things like this are uncharted
    territory...
    With a couple of flv players downloading some 3Mb and 7Mb
    flvs after the web page has rendered, the page nav in the
    containing page is blocked. So a click on a nav button (not flash)
    in the
    will
    result in a new page load, but it waits until what I assume is
    one of two simulaneous http connection slots are freed up. This can
    take a while depending on the user's connection speed and is
    unusual/unexpected/sub-standard behaviour for a web page. Having
    the two videos loading simultaneously is a requirement rather than
    sequencing the loads.
    I know that browsers are limited to the number of
    simultaneous connections to a single domain for many reasons and
    that standards come into play. The flvs here are hosted at the same
    domain.
    I've built optional delay flashvars for each player to
    permitting staggering them somewhat but that's a guess at best and
    won't solve the problem for everyone and could disadvantage some
    with very fast connections. I should mention that the target user
    is a business client so broadband users and the requirement is that
    the videos are ready to play asap.
    I understand that placing the media in another domain is an
    option because the browser connections limit applies per domain. I
    also know you can change the settings for browsers to increase the
    connections per domain, but that's not helpful here... and that
    some browsers are less restrictive.
    What I would like to know is:
    Is there any simple way in flash to allow the regular html
    page nav to work as normal when flash has a stranglehold on the two
    simultaneous connections. Am I missing something obvious? TIA,
    GWD

    @clbeech: thanks for your reply.
    I've thought of things like using javascript via
    ExternalInterface to tell the players to change the contentPaths of
    the flvplaybacks to nonexistent files (I know that works for
    NetStream, don't know if it works for FLVPlayback). But I was only
    asked to work on the flash content for the page and if possible
    preferred to avoid making a requirement to add in extra js for the
    website developer and have the nav behave differently for that
    page. If that's the only way apart from using a separate domain for
    the media then I guess that's what I'll have to do.
    What I don't understand is why a browser page request doesn't
    over-ride the grip that flash has on the http connections... and
    perhaps there's something simple that I'm missing in either being
    able to do this or understanding the fundamentals of why it doesn't
    make sense to permit it in terms of how browsers work.
    Anyhow I can identify so far four solutions
    - other domain hosting of the content(not desirable)
    - configurable loading delays for starting the downloads
    (already in place, but not really a solution)
    - force single load queueing (not desirable)
    - javascript/ExternalInterface to tell flash players to
    "stop" download to free up connections
    Thanks again.GWD

  • SEO and Flash, can they ever be friends

    Hi All,
    I have recently been questioning the SEO side of things; and
    am currently trying to better optimize my site. I use quite a lot
    of flash on my site, and it sorted dawned on me that Flash is doing
    me no favours when it comes down to SEO - I will need to get a good
    ranking, as this year I will be putting a lot of money and time
    into making our site a success story ;)
    Am I a little green on this or what?
    Anyone know any tips/tricks on how best to bring SEO and
    Flash together, to better work in page ranking?
    What do folks with totally 100% Flash sites do when it comes
    down to SEO? As there is only a few meta tags and title tag
    available?
    I love Flash, and would never let go! However, this SEO thing
    will always be a "Flash Avoidance" for new clients; how can one
    best assure them that Flash provides more than just a better brand
    image?
    A few weeks ago, a potential client stated "I would never
    have a flash menu".
    Kind Regards,
    Boxing Boom

    @kglad: swfaddress need not be timeline based, flash just has
    to respond by displaying the relevant content - which could be
    loaded content.
    My view is that the best way to achieve SEO is to use
    swfaddress in combination with a CMS. The CMS provides the same
    content in html for search spiders and to flash in a more 'flash
    friendly' format when flash is 'rendering' it. SWFaddress supports
    the deep-linking from search queries etc.
    The way you could think about this is that when flash
    requests the same content it gets (for example) xml defining what
    it needs to do, whereas if the browser requests it , it gets the
    basic html version. But the content is only ever defined once for
    both versions of the output from the CMS.
    Drupal (a CMS I am familiar with, but I'm sure other CMSes
    have similar modules) has a swfaddress module as well as
    services/amfphp modules that let flash request content.
    My own (somewhat neglected) site has flash requesting all the
    content via Drupal. I am not currently 'displaying' it using flash:
    flash is loading the content (using as2 LoadVars in json format)
    and 'rendering' it via the browser via ExternalInterface and
    javascript. This was a kind of experiment just to see if I could do
    it - it does store pages in flash memory so some things happen a
    little different when navigating to a previously viewed page. But
    it could also easily do its own alternate rendering of the same
    content, as more structured data and rendering them in its own way
    inside flash.
    My own example is not so great (it is due for an overhaul)
    but I know there are examples out there using this approach with
    flash.
    The beauty of this approach is that you get SEO via the
    traditional spidering approaches, deeplinking to the correct
    content from search query results, forward/back button support,
    non-flash based browser support, along with easy content
    maintenance. It does require learning a CMS and the approaches for
    integration with flash though.

  • HTML/javascript interaction with swf content - can I call swf functions from JS?

    Hi,
    I've created an AIR application where the
    intialWindow.content is a HTML page / JavaScript application. On
    this HTML page I want to include some SWF content as a plugin (a
    Flex 3 app), so I have an object tag.
    From my SWF I can call out to JavaScript using
    flash.external.ExternalInterface fine. I can also call methods
    within the AIR and Flex APIs via the window or runtime objects.
    However, if I try to call methods within my SWF from
    JavaScript, nothing happens. Further, I can pass a function
    reference from my SWF to JavaScript (via ExternalInterface), and
    while I can see a valid function reference in JavaScript, calling
    it doesn't call the function within the SWF.
    Is this not supported? Or is this something else, like an
    applicationDomain issue? My SWF object is loaded via the app:/ uri,
    so I didn't think it would be that.

    I hadn't tried that, and it does work. Thank you. Everyone
    should note though that the documentation here
    Flex
    3 - External Interface
    and
    Flash
    9 - ExternalInterface.html
    says:
    "Note: Adobe AIR currently does not support the
    ExternalInterface class."
    which by my reading means that none of this should work,
    although it clearly does.
    The page
    Example:
    Using the external API with a web page container was most
    helpful in finding the solution, since it mentions referencing the
    object id of the plugin (e.g.
    window['my-object-id'].functionToCall()) when referencing the
    callback function.
    This
    page has a more concise example.

  • Ebedded Flex app does not play automatically

    I have a flex app that is embedded in a web page.
    When the page loads for the first time the app does not run
    automatically but is in "loop" mode.
    In order to embed the application in the html page we have
    copied the html and javascript files that the Flex builder
    generates :
    AC_OETags.js, history.htm, history.js etc.
    This only happens the first time the page is loaded,
    subsequently it loads and plays automatically.
    I would be grateful is anyone has some insight here.

    Thanks for your answer, we found a similar workaround.
    We did the following:
    1) disable automatic starting of the SWF in the script that
    created the plugin by adding these parameters:
    "play", "false",
    "loop", "false",
    2) adding some own javascript to the template-html:
    var isMovieLoaded = false;
    function setIsMovieLoaded(){
    isMovieLoaded = true;
    function start(id) {
    var swf = document.getElementById(id);
    if (swf) {
    swf.Play();
    function playMovie(){
    if( !isMovieLoaded ){
    start( "${application}" );
    window.setTimeout("playMovie()", 3000);
    3) calling setIsMovieLoaded() via ExternalInterface from the
    loaded application when initializing:
    if (ExternalInterface.available)
    ExternalInterface.call("setIsMovieLoaded");
    This way when the application loads and plays correctly, the
    delayed call to playMovie in the html-template does nothing,
    because the flag isMovieLoaded was already set by the application.
    If that is not the case, the movie is explicitly startet via
    the start function.
    Thanky anyway :-)

  • Enter an equation into a textbox and it will automatically calculate an answer

    Hi All,
    I have created two textboxes.
    What I would like to do is after entering an equation, e.g.
    "(9-5)*30 + 1", into the textbox 1,
    textbox 2 will automatically gives me the answer "121".
    I have no idea which function can give me an int 121 from a
    string "(9-5)*30 + 1" or I have to build one by myself.
    Are there any build-in functions in AIR could help?
    If I have to build one by myself, are there any sample code
    for me to reference??
    Many Thanks!!

    Your choices are:
    * Parse the expression and calculate it yourself, which is
    probably hard.
    * Google for a library that aleady does it
    * Pass the expression string to the browser via
    ExternalInterface and evaluate it using javascript's eval()
    function.
    Tracy

  • [IDCS4] Space bar shortcut for hand doesn't work

    I am experiencing following problem:
    I have written a startup script that shows a floating panel (it is a window that uses 'palette' as a type description). I also added menu item and listeners to show/hide it (in menu window). Inside the panel there is a flex application that communicates with InDesign via ExternalInterface (no PatchPanel). Whenever I start InDesign with this script as startup script  suddenly spacebar stops working as a shrotcut that temporarily changes  used tool to Hand Tool. Even closing InDesign and removing startup script and restarting InDesgin doesn't help, I need to logout and login again to make spacebar work. I am experiencing this issue on MacOSX 10.4 on Intel Mac, InDesign 6.0.5 and script is written in ExtendScript.
    I also found that running the startup script from scripts panel seems to  solve the problem, but this is rather undesired, since the panel should  be available from InDesign startup...
    Has anybody of you experienced the same behaviour? Maybe there is some sort of programatic fix? It drives me mad, because I am used to spacebar as a temporary hand. Of course if there is no other fix, I'll need to find some sort of hack that performs initialization after startup, but this is rather undesired
    Thanks in advance for your help and expertise

    After some investigation I can tell that aforementioned bahaviour is most probably caused by opening the INDD file by using AIR API (file.openWithDefaultApplication()). When file is opened by user this behaviour is not observed, but when INDD is opened from AIR application, it results with disabling spacebar shortcut. What is even more strange, the shortcut is disabled not only in InDesign, but also in Illustrator. Photoshop works fine...
    Geez, Adobe, you're giving me so much headache...
    Corrected typos
    Message was edited by: Maciej Przepióra

  • Parsing strings with Unicode values 16 bits

    How can I get the Unicode value for a character in a String when the value is greater than 16 bits?
    I need to extract a supplemental plane Unicode value from a string. However,  String.charCodeAt(index) truncates the Unicode value to 16 bits,  returning what should be 0x02F91A  as  0xF91A.  I see discussions that show that earlier versions of Flex stores such char codes as the two code points of a surrogate pair, but  in Flex 4, the string length is just 1 when I put only this character in the string.

    Does it work in JavaScript?  Could send it over via externalInterface.

  • How to live stream vp6 from a browser/swf file.

    Hello,
    Currently we have a swf file application that runs in a browser and takes the live video stream from the camera on the computer and streams a live sorenson spark stream to the fms 3.5 server.
    Question is:
    How to live stream vp6 from the browser/swf file on the camera computer, instead of the sorenson spark. (We seem to be stuck only on sorenson spark).
    Thank you.

    Hi Vince,
    Jay has explained it about as best as can be done.  What you have now is a
    SWF that lives in a browser.  With Flix, you can eliminate the SWF
    altogether.  Or if there is logic that still will require the SWF, then both
    Flix and the SWF will live in the browser at the same time (and can talk via
    ExternalInterface).
    fyi .. When using Flix, if Flix does not eliminate the SWF altogether, you
    will remove from your SWF all logic for acquiring Camera and Microphone.  As
    Jay has reiterated, Flix Publisher will now be doing all that.
    If your SWF includes logic other than video/audio, e.g. maybe text chat,
    then you may need logic in your SSAS to associated the video from Flix with
    anything else from the SWF since each will have its own NetConnection to the
    FMIS application.
    In case it might help, following is On2's heavily commented JavaScript for
    invoking Flix Publisher:
    http://publisher.on2.com/fp_doc/3-1-5-5/samples/scripts/flixpub_conf.js
    And the full docs for the Flix SDK are here:
    http://publisher.on2.com/fp_doc/3-1-5-5/index.html
                    hth,
                    g

  • 30 sec idleTimeout (no AIR)

    Does anyone know of a workaround for the 30 sec idle timeout limit for a URLRequest (not using the AIR runtime)?

    I think the OP is refering to NetConnection.httpIdleTimeout, which is only available in AIR. There are suggestions to use JavaScript to retrieve data from the server via ExternalInterface, which could work to circumvent 30 seconds timeout imposed by Flash player.
    Kenneth Kawamoto
    http://www.materiaprima.co.uk/

Maybe you are looking for

  • PHP4 and national characters

    I have Oracle8 installed on Novell Small Business 5.1. On another machine is Linux Red Hat 7.0 with Appache 1.3.3 server and PHP4. Web user nobody opens script.php. This script connects to my Oracle database and for example selects rows from table te

  • What is considered to be a large production client?

    I'm about to perform a client transport and would like to know about how many gb in database size is considered to be a large production client? Thank you

  • SUNWasac as a service in SMF.

    I performed a full install of Solaris 10 and I find that the "Sun Java System Application Server v8.2" is included in the distribution. As I have a need to use this it is convenient (as opposed to bloaty which might be another's opinion of the inclus

  • Additional Installers List empty

    Hi there Best regards chris CL(A)Dly bending G-Force with LabVIEW famous last words: "oh my god, it is full of stars!" Solved! Go to Solution.

  • Uninstall of previous version 11.6.1.629 (Also Flash 10.0.1.152)

    Quick question: Why can't the option to uninstall previous versions be part of each new release instead of having a separate uninstall tool for both Shockwave & Flash. Now for the "problem" I'm encountering with uninstalls of previous versions. > I d