Playing a sound when clicking a text on a page

Wtite here if you are not sure in which category to create your topic
Post Reply
aalba
Posts: 4
Joined: Fri Jan 11, 2008 11:40 pm

Playing a sound when clicking a text on a page

Post by aalba » Fri Jan 11, 2008 11:55 pm

Hi, there
Can we Play a sound when clicking a text on a page of Print2Flash documents? It is very important in making a tutorial that need a sound (like giving an example of pronouncing a word or sentence in an e-book for learning forign language.

Thanks for your attention

staff
Posts: 282
Joined: Sat Dec 15, 2007 4:48 pm

Re: Playing a sound when clicking a text on a page

Post by staff » Sat Jan 12, 2008 6:04 am

Print2Flash Document APi broadcasts onSelection event whenever the user changes text selection. You may get the selected text in this event handler by calling getSelectedText function which may be used to determine the text to pronounce. More information on this event is available at http://print2flash.com/help/DocumentAPIEvents.php

aalba
Posts: 4
Joined: Fri Jan 11, 2008 11:40 pm

Re: Playing a sound when clicking a text on a page

Post by aalba » Fri Jan 25, 2008 5:34 am

thanks for your information, but what I mean is how to Play a sound (like *.wav or *.mp3) when clicking a text or an object on a page of Print2Flash documents?

staff
Posts: 282
Joined: Sat Dec 15, 2007 4:48 pm

Re: Playing a sound when clicking a text on a page

Post by staff » Tue Jan 29, 2008 8:27 am

The problem is how you would want to detect what is clicked on a page. For example, when user clicks on a text, do you want to know the text around the cursor or just the word clicked or something else? And what would you want to know if user clicks an image?

Our suggested solution with text selection allows a user to select a specific text with mouse which you may determine in the onSelection event handler and play an appropriate MP3 file as a reaction on text selection. To play MP3 files we think you may use the standard technique as described by Adobe at http://livedocs.macromedia.com/flash/8/ ... 01565.html

aalba
Posts: 4
Joined: Fri Jan 11, 2008 11:40 pm

Re: Playing a sound when clicking a text on a page

Post by aalba » Thu Jan 31, 2008 5:28 am

Suppose I just want to click an object (including texts or image, not select a text) and the object will response by giving command to .... (including ...to play an audio file or run other commands such as go to other pages).

staff
Posts: 282
Joined: Sat Dec 15, 2007 4:48 pm

Re: Playing a sound when clicking a text on a page

Post by staff » Fri Feb 01, 2008 5:15 am

Each document page is a MovieClip object composed of text, images, lines and other graphic primitives. The problem is MovieClip seems not to provide a way to enumerate its constituent objects and track clicks on them.

You may obtain a reference to the page movie instance using this undocumented method:

Code: Select all

var page1=doc.Pages[0].movie
Here the 0 index refers to the first page, the 1 would refer to the second page and so on. Then in principle you can attach an event listener to this object and track clicks on it. But as constituent objects cannot be determined, this seems to allow you to track only the coordinates of the click or the text near the click point.

aalba
Posts: 4
Joined: Fri Jan 11, 2008 11:40 pm

Re: Playing a sound when clicking a text on a page

Post by aalba » Fri Feb 01, 2008 8:19 pm

the samples, please!

staff
Posts: 282
Joined: Sat Dec 15, 2007 4:48 pm

Re: Playing a sound when clicking a text on a page

Post by staff » Sat Feb 02, 2008 3:58 am

See attached an adaptation of our Print2Flash SDK Flash sample. When you click within any area of the first page, It should write to the Flash Professional output window the coordinates of the click point and the position of the text symbol near the click point (if any).
Attachments
sample.ZIP
(205.12 KiB) Downloaded 720 times

Post Reply