Link to home
Start Free TrialLog in
Avatar of James_Avery
James_Avery

asked on

Create button with AC3 that triggers snapshot function

I have an AC3 project. I have a print function 'printCertificate()' that sends a specific movieclip instance to the printer (a certificate of completion for a quiz after the user has passed),

I also have code in place that saves a screenshot in jpeg format, and attempts to save it to the harddrive after the user selects the desired download location.

MY PROBLEM:

My problem is that I am not requesting the user to trigger the save function, and because of security limitations, the save window won't appear unless a button is displayed and clicked on.

I need to modify my script (starts on line 191 of the attached code) so that a button will appear that when clicked, will open a save dialogue, followed by a print dialogue. I have all of the other code in place, I just need to add a button within actionscript in the center of the screen for the user to trigger the save and print.

Any ideas? Attached is my script that I need modified. Your help is greatly appreciated!
EOSInteractiveService.as
Avatar of blue-genie
blue-genie
Flag of South Africa image

Hi James, i didn't look through all your code, as it probably won't make sense out of context.
if i understand you correctly, create the movieclip to serve as your button give it a linkage name

ie. PrintBtn

so now when you need the button there

var printBtn:PrintBtn = new PrintBtn();
addChild(printBtn)
printBtn.x = //etc set x and y locations.

printBtn.addEventListener(MouseEvent.CLICK, yourfunctioname);

function yourfunctionname(e:MouseEvent):void
{
//your code here
}

Avatar of James_Avery
James_Avery

ASKER

I have added your code to my script but am now receiving the follow error:

/Users/jamesavery/Desktop/Eos Interactive 2.0/EosInteractive_src/classes/com/orcamedia/eos/EOSInteractiveService.as, Line 206      1046: Type was not found or was not a compile-time constant: CLICK.

I have attached my code. Any ideas as to why this is happening? Thanks again for your help!
EOSInteractiveService.as
My mistake. Below is the actual error I am recieving:

/Users/jamesavery/Desktop/Eos Interactive 2.0/EosInteractive_src/classes/com/orcamedia/eos/EOSInteractiveService.as, Line 206      1046: Type was not found or was not a compile-time constant: MouseEvent.
I added the lines:

      import flash.display.SimpleButton;
      import flash.events.MouseEvent;

Which solved that error, but now I am receiving these:

/Users/jamesavery/Desktop/Eos Interactive 2.0/EosInteractive_src/classes/com/orcamedia/eos/EOSInteractiveService.as, Line 213      1120: Access of undefined property snapshot_errorHandler.
/Users/jamesavery/Desktop/Eos Interactive 2.0/EosInteractive_src/classes/com/orcamedia/eos/EOSInteractiveService.as, Line 198      1180: Call to a possibly undefined method addChild.
/Users/jamesavery/Desktop/Eos Interactive 2.0/EosInteractive_src/classes/com/orcamedia/eos/EOSInteractiveService.as, Line 197      1180: Call to a possibly undefined method PrintBtn.
/Users/jamesavery/Desktop/Eos Interactive 2.0/EosInteractive_src/classes/com/orcamedia/eos/EOSInteractiveService.as, Line 197      1046: Type was not found or was not a compile-time constant: PrintBtn.
Here is my new script. Any ideas why I am getting these errors? I am a major AC rookie working on someone elses code.
EOSInteractiveService.as
can you upload your project, i.e all the files, will make it much easier to trouble shoot.
ASKER CERTIFIED SOLUTION
Avatar of nycynik
nycynik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial