• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

Forcing the swf to have focus

Hi all.

I have a swf that has a print button, when clicked, it brings up the standard windows print dialogue box, once you've clicked ok or cancel there, is there a way I can force the swf to receive focus - because, what happens now, is the user first has to click anywhere in the swf, before the buttons become active, or click the button twice.

Thanks.
blu
0
blue-genie
Asked:
blue-genie
  • 2
  • 2
1 Solution
 
OBCTCommented:
Blu,

I found this in the actionscript dictionary on Flash MX 2004. I'm not sure if it will set your swf as the main focus but it's worth a try.

Selection.setFocus()
Availability
Flash Player 5. Instance names for buttons and movie clips work only in Flash Player 6 and later.

Usage
Selection.setFocus("instanceName")

Parameters
instanceName A string specifying the path to the instance name of a button, movie clip, or text field.

Returns
An event.

Description
Method; gives focus to the selectable (editable) text field, button, or movie clip specified by instanceName. The instanceName parameter must be a string literal of the path to the instance. You can use dot or slash notation to specify the path. You can also use a relative or absolute path. If you are using ActionScript 2.0, you must use dot notation.

If null is passed, the current focus is removed.

Example
The following example gives focus to a text field associated with myVar, on the main Timeline. Because the instanceName parameter is an absolute path, you can call the action from any Timeline.

Selection.setFocus("_root.myVar");

In the following example, the text field associated with myVar is in a movie clip called myClip on the main Timeline. You can use either of the following two paths to set focus; the first is relative and the second is absolute.

Selection.setFocus("myClip.myVar");
Selection.setFocus("_root.myClip.myVar");

The only other way I am aware of is by using a third part tool. I personally use SWF Studio but there are alot of others around. The only problem is they aren't cheap so I'm not sure if your project is big enough to need such a tool.
I hope this helps.

Cheers

-OBCT
0
 
ZefferCommented:
so the answer is..

on the tail-end of your print-button code..

Selection.setFocus("_root");

z

0
 
blue-genieAuthor Commented:
nope, sorry Zeffer, that was the first thing i tried, it doesn't work.

OBCT, how do you do it in SWF studio, i'm packaging the final product in swf studio.
0
 
blue-genieAuthor Commented:
OBCT, nevermind, i just has a look at the previous version that's been put into swf studio, and the problem doesn't seem to exist.

I'm going to leave this open for a bit, see if anyone knows how to do it without a 3rd party tool.

ta.

blu
0
 
ZefferCommented:
try
Selection.setFocus("_parent");

z
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now