Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Create button with AC3 that triggers snapshot function

Posted on 2011-03-01
7
441 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:James_Avery
  • 4
  • 2
7 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 35016226
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
}

0
 

Author Comment

by:James_Avery
ID: 35017980
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
0
 

Author Comment

by:James_Avery
ID: 35018028
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.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:James_Avery
ID: 35018357
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.
0
 

Author Comment

by:James_Avery
ID: 35018385
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
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 35020379
can you upload your project, i.e all the files, will make it much easier to trouble shoot.
0
 
LVL 2

Accepted Solution

by:
nycynik earned 500 total points
ID: 35142694
You have not yet created the movie clip for PrintBtn

You have two choices:

1) create the movieclip PrintBtn
2) use a standard button in flash

1) Using movie clip
- Create a graphic in flash, on the stage (fla file) of the button you want the user to click on.  
- click the graphic, and convert it to a symbol (Menu, Modify->Convert to Symbol, or F8).
- right click on the symbol you just created, and select properties (assuming cs5), turn down the advanced triangle
- click export for actionscript, and name the instance "PrintBtn"
-Click save
- save the project, and try it.

2) using standard button
- add the button to the flash by dragging it from the components to the fla  (its under user interface->button)
type "PrintBtn" in to the insttance name for the button in the properties dialog
- save the project, and try it.



-
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question