Solved

Forcing the swf to have focus

Posted on 2003-11-24
5
340 Views
Last Modified: 2010-04-03
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
Comment
Question by:blue-genie
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
OBCT earned 60 total points
ID: 9816364
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
 
LVL 23

Expert Comment

by:Zeffer
ID: 9816530
so the answer is..

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

Selection.setFocus("_root");

z

0
 
LVL 39

Author Comment

by:blue-genie
ID: 9816738
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
 
LVL 39

Author Comment

by:blue-genie
ID: 9816782
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
 
LVL 23

Expert Comment

by:Zeffer
ID: 9820312
try
Selection.setFocus("_parent");

z
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now