001 
002 /*
003  *  JScripter Standard 1.0 - To Script In Java
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package js.user;
021 
022 import js.*;
023 import js.core.*;
024 
025 /**
026  * <p>An <b>opaque</b> class representing JavaScript client-side objects of the global 
027  * {@link JsClient#FlashPlayer} class.</p>
028  * <p>An object of this class represents a Flash movie embedded in a web page and the 
029  * instance of the Flash plug-in that is playing that movie. You can obtain an object 
030  * of this class using {@link JsDocument#getElementById(String)} to get the 
031  * <tt>&lt;embed&gt;</tt> or <tt>&lt;object&gt;</tt> tag that embeds the movie in the 
032  * web page.</p>
033  * <p>Once you have obtained an object of this class, you can use the various methods it 
034  * defines to control playback of the movie and to interact with it by setting and 
035  * querying variables. Note that {@link JsFlashPlayer} methods all begin with a capital 
036  * letter, which is not a common naming convention in Java and JavaScript.</p>
037  *
038  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
039  *
040  * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be
041  * generated into the target codes. Re-compilers must exit with error on the operations of
042  * accessing that kind of class objects.
043  * The <tt>checkcast</tt> operation to the class literal of this interface must be ignored
044  * and <tt>instanceof</tt> to it always <tt>true</tt>.
045  */
046 public class JsFlashPlayer extends JsClient.FlashPlayer.Prototype
047 {
048     /**
049      * <p>An <b>opaque</b> class representing members of its enclosing <b>opaque</b> type.</p>
050      * <p>Note that, this class is <b>opaque</b> but its constructors are all <b>internal</b>. 
051      * This class and the subclasses of this class are used to declare either <b>opaque</b> 
052      * <tt>public</tt> instance fields of the opaque type {@link js.Var.Member} or the 
053      * <b>opaque</b> <tt>public</tt> static fields of other <b>opaque</b> types while their 
054      * constructors are used to define the fields inside <b>opaque</b> classes. Under 
055      * either circumstance, the field names must be exactly same as the member names, as 
056      * the <b>opaque</b> fields of <b>opaque</b> types are resolved by re-compilers directly 
057      * based on the field names.</p>
058      *
059      * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
060      * 
061      * @javascript <b>Opaque</b> types can be resolved but no class objects for them can be created
062      * in the target codes. Re-compilers must exit with error on operations accessing that kind 
063      * of class objects.
064      * Re-compilers must resolve an <b>opaque</b> instance field declared by this class in
065      * {@link js.Var.Member} or its subclasses to the JavaScript identifier: 
066      * <pre>q.m</pre>
067      * where <tt>m</tt> is the identifier of the field name and <tt>q</tt> is the identifier
068      * resolved from the instance of the enclosing member. Re-compilers must resolve an 
069      * <b>opaque</b> static field declared by this class in <b>opaque</b> types other than 
070      * {@link js.Var.Member} and its subclasses to the JavaScript identifier: 
071      * <pre>m</pre>
072      * where <tt>m</tt> is the identifier of the field name. And re-compilers must report
073      * error on the access to <b>opaque</b> fields declared by this class under any other 
074      * circumstances.
075      */
076     public static class Member extends JsClient.FlashPlayer.Prototype.Member
077     {
078         /**
079          * <p>Internally constructs a member based on a qualifying member.</p>
080          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
081          * or <b>internal</b> classes or class members.</p>
082          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
083          * <b>opaque</b>. This constructor is used to define <b>opaque</b> instance fields 
084          * declared in the declaring class of this constructor itself or its subclasses. 
085          * Under this circumstance, the field names must be exactly same as the member 
086          * names, as the <b>opaque</b> instance fields of the <b>opaque</b> type 
087          * {@link js.Var.Member} or its subclasses are resolved by re-compilers directly
088          * to their names appending to the name resolved from the specified qualifying 
089          * member with a dot in between.</p>
090          * @param q A qualifying member
091          * @param mid The ID of the member to construct
092          * @since 1.0
093          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
094          */
095         public Member(JsObject.Member q, Mid mid) {
096             super(q, mid);
097         }
098         /**
099          * <p>Internally constructs a member without a qualifying member.</p>
100          * <p>This constructor is <b>internal</b> and only called inside of <b>opaque</b>
101          * or <b>internal</b> classes or class members.</p>
102          * <p>Note that, this constructor is <b>internal</b> but its declaring class is
103          * <b>opaque</b>. This constructor is used to define <b>opaque</b> static fields, 
104          * declared in <b>opaque</b> types other than the declaring class of this constructor 
105          * itself and its subclasses. Under this circumstance, the field names must be
106          * exactly same as the member names, as the <b>opaque</b> static fields of <b>opaque</b>
107          * types are generally resolved by re-compilers directly to identifiers of their names.</p>
108          * @param mid The ID of the member to construct
109          * @since 1.0
110          * @javascript Re-compilers must report error on the invocation to an <b>internal</b> constructor.
111          */
112         public Member(Mid mid) {
113             super(mid);
114         }
115         @Override
116         /**
117          * <p>Evaluates the property, represented by the current member instance, of the
118          * argument object.</p>
119          * @param o The argument object
120          * @return The value of the current member based on the object argument.
121          * @since 1.0
122          * @javascript Re-compilers must convert the instance invocation of this method into
123          * the JavaScript expression: 
124          * <pre>o.m</pre>
125          * where <tt>m</tt> is the identifier name resolved from the current member
126          * instance of the invocation.
127          */
128         public JsFlashPlayer with(ObjectLike o) {
129             return new JsFlashPlayer(super.with(o));
130         }
131     }
132 
133     /**
134      * <p>Casts an <b>opaque</b> object to the current <b>opaque</b> type by wrapping it
135      * with the wrapping constructor.</p>
136      * @param var The argument of an <b>opaque</b> object.
137      * @since 1.0
138      * @javascript Re-compilers must ignore the construction operation of this constructor,
139      * that is, replacing it with its only argument.
140      */
141     public JsFlashPlayer(JsObject var) {
142         super(var);
143     }
144 
145     @Override
146     /**
147      * <p>Returns the primitive value associated with the current instance, if there is one.
148      * This invocation simply returns the instance itself for the current instance is an 
149      * object and there is no primitive value for it.</p>
150      * @return The current object itself.
151      * @since 1.0
152      * @javascript Re-compilers must convert the instance invocation of this method directly
153      * into a JavaScript invocation on its current object instance without changing the 
154      * method name, but expanding variable arguments, if any, into comma-separated values. 
155      */
156     public final JsFlashPlayer valueOf() {
157         return new JsFlashPlayer((JsObject)var().valueOf());
158     }
159 
160     /**
161      * <p>Returns the value of a variable defined by a Flash movie.</p>
162      * @param variableName The name of the variable defined in the Flash movie.
163      * @return The value of the named variable as a string, or <tt>null</tt> if no such 
164      * variable exists.
165      * @since 1.0
166      * @javascript Re-compilers must convert the instance invocation of this method directly
167      * into a JavaScript invocation on its current object instance without changing the 
168      * method name, but expanding variable arguments, if any, into comma-separated values. 
169      */
170     public final String GetVariable(String variableName) {
171         return call(GetVariable, variableName);
172     }
173     /**
174      * <p>Returns the value of a variable defined by a Flash movie.</p>
175      * @param variableName The name of the variable defined in the Flash movie.
176      * @return The value of the named variable as a string, or <tt>null</tt> if no such 
177      * variable exists.
178      * @since 1.0
179      * @javascript Re-compilers must convert the instance invocation of this method directly
180      * into a JavaScript invocation on its current object instance without changing the 
181      * method name, but expanding variable arguments, if any, into comma-separated values. 
182      */
183     public final String GetVariable(StringLike variableName) {
184         return GetVariable(Js.valueOf(variableName));
185     }
186     /**
187      * <p>Jumps to the specified frame number in the movie.</p>
188      * <p>This method skips to the specified frame of the movie, or skips to the last 
189      * available frame, if the specified frame has not been loaded yet. To avoid this 
190      * indeterminate behavior, use {@link #PercentLoaded()} to determine how much of the 
191      * movie is available.</p>
192      * @param frameNumber The frame number to skip to.
193      * @since 1.0
194      * @javascript Re-compilers must convert the instance invocation of this method directly
195      * into a JavaScript invocation on its current object instance without changing the 
196      * method name, but expanding variable arguments, if any, into comma-separated values. 
197      */
198     public final void GotoFrame(Number frameNumber) {
199         call(GotoFrame, frameNumber);
200     }
201     /**
202      * <p>Jumps to the specified frame number in the movie.</p>
203      * <p>This method skips to the specified frame of the movie, or skips to the last 
204      * available frame, if the specified frame has not been loaded yet. To avoid this 
205      * indeterminate behavior, use {@link #PercentLoaded()} to determine how much of the 
206      * movie is available.</p>
207      * @param frameNumber The frame number to skip to.
208      * @since 1.0
209      * @javascript Re-compilers must convert the instance invocation of this method directly
210      * into a JavaScript invocation on its current object instance without changing the 
211      * method name, but expanding variable arguments, if any, into comma-separated values. 
212      */
213     public final void GotoFrame(NumberLike<?> frameNumber) {
214         GotoFrame(Js.valueOf(frameNumber));
215     }
216     /**
217      * <p>Checks whether the movie is playing.</p>
218      * @return <tt>true</tt> if the movie is playing; <tt>false</tt> otherwise.
219      * @since 1.0
220      * @javascript Re-compilers must convert the instance invocation of this method directly
221      * into a JavaScript invocation on its current object instance without changing the 
222      * method name, but expanding variable arguments, if any, into comma-separated values. 
223      */
224     public final Boolean IsPlaying() {
225         return call(IsPlaying);
226     }
227     /**
228      * <p>Loads an auxiliary Flash movie and displays it at a specified layer or level 
229      * of the current movie.</p>
230      * <p>This method loads an auxiliary movie from the specified <tt>url</tt> and 
231      * displays it at the specified <tt>layer</tt> within the current movie.</p>
232      * @param layer The level or layer within the current movie on which the newly 
233      * loaded movie is to be displayed.
234      * @param url The URL of the movie to load.
235      * @since 1.0
236      * @javascript Re-compilers must convert the instance invocation of this method directly
237      * into a JavaScript invocation on its current object instance without changing the 
238      * method name, but expanding variable arguments, if any, into comma-separated values. 
239      */
240     public final void LoadMovie(Number layer, String url) {
241         call(LoadMovie, new Vars<Object>().add(layer).add(url));
242     }
243     /**
244      * <p>Moves the viewport of the movie.</p>
245      * <p>The Flash player defines a viewport through which Flash movies are visible. 
246      * Typically, the size of the viewport and the size of the movie are the same, but 
247      * this may not be not the case when {@link #SetZoomRect(Number, Number, Number, Number)} or 
248      * {@link #Zoom(Number)} have been called: those methods can alter the viewport so that 
249      * only a portion of the movie shows through.</p>
250      * <p>When the viewport is showing only a portion of the movie, this method moves 
251      * (or "pans") the viewport so that a different portion of the movie shows. This 
252      * method doesn't allow you to pan beyond the edges of a movie, however.</p>
253      * @param dx The horizontal amounts to pan.
254      * @param dy The vertical amounts to pan.
255      * @param mode Specifies how to interpret the <tt>dx</tt> and <tt>dy</tt> values. 
256      * If this argument is 0, the other arguments are taken as pixels. If this argument 
257      * is 1, the others are percentages.
258      * @since 1.0
259      * @javascript Re-compilers must convert the instance invocation of this method directly
260      * into a JavaScript invocation on its current object instance without changing the 
261      * method name, but expanding variable arguments, if any, into comma-separated values. 
262      */
263     public final void Pan(Number dx, Number dy, Number mode) {
264         call(Pan, new Vars<Object>().add(dx).add(dy).add(mode));
265     }
266     /**
267      * <p>Determines how much of the movie has loaded.</p>
268      * @return An integer between 0 and 100 representing the approximate percentage of 
269      * the movie that has been loaded into the player.
270      * @since 1.0
271      * @javascript Re-compilers must convert the instance invocation of this method directly
272      * into a JavaScript invocation on its current object instance without changing the 
273      * method name, but expanding variable arguments, if any, into comma-separated values. 
274      */
275     public final Number PercentLoaded() {
276         return call(PercentLoaded);
277     }
278     /**
279      * <p>Begins playing the movie.</p>
280      * @since 1.0
281      * @javascript Re-compilers must convert the instance invocation of this method directly
282      * into a JavaScript invocation on its current object instance without changing the 
283      * method name, but expanding variable arguments, if any, into comma-separated values. 
284      */
285     public final void Play() {
286         call(Play);
287     }
288     /**
289      * <p>Rewinds the movie to its first frame.</p>
290      * @since 1.0
291      * @javascript Re-compilers must convert the instance invocation of this method directly
292      * into a JavaScript invocation on its current object instance without changing the 
293      * method name, but expanding variable arguments, if any, into comma-separated values. 
294      */
295     public final void Rewind() {
296         call(Rewind);
297     }
298     /**
299      * <p>Sets a variable defined by a Flash movie.</p>
300      * @param name The name of the variable to set.
301      * @param value The new value for the named variable. This value must be a string.
302      * @since 1.0
303      * @javascript Re-compilers must convert the instance invocation of this method directly
304      * into a JavaScript invocation on its current object instance without changing the 
305      * method name, but expanding variable arguments, if any, into comma-separated values. 
306      */
307     public final void SetVariable(String name, String value) {
308         call(SetVariable, new Vars<Object>().add(name).add(value));
309     }
310     /**
311      * <p>Sets the area of the movie displayed by the Flash player.</p>
312      * <p>This method defines the movie's viewport, that is, it specifies a sub-rectangle 
313      * of the movie to appear in the Flash player. Flash movies are measured in a unit 
314      * known as the twip. There are 20 twips to a point and 1,440 twips to an inch.</p>
315      * @param left   The X-coordinate, in twips, of the upper-left  corner of the viewport.
316      * @param top    The Y-coordinate, in twips, of the upper-left  corner of the viewport.
317      * @param right  The X-coordinate, in twips, of the lower-right corner of the viewport.
318      * @param bottom The Y-coordinate, in twips, of the lower-right corner of the viewport.
319      * @since 1.0
320      * @javascript Re-compilers must convert the instance invocation of this method directly
321      * into a JavaScript invocation on its current object instance without changing the 
322      * method name, but expanding variable arguments, if any, into comma-separated values. 
323      */
324     public final void SetZoomRect(Number left, Number top, Number right, Number bottom) {
325         call(SetZoomRect, new Vars<Object>().add(left).add(top).add(right).add(bottom));
326     }
327     /**
328      * <p>Stops the movie.</p>
329      * @since 1.0
330      * @javascript Re-compilers must convert the instance invocation of this method directly
331      * into a JavaScript invocation on its current object instance without changing the 
332      * method name, but expanding variable arguments, if any, into comma-separated values. 
333      */
334     public final void StopPlay() {
335         call(StopPlay);
336     }
337     /**
338      * <p>Returns the length of the movie, as a number of frames.</p>
339      * @return The length of the movie in frames.
340      * @since 1.0
341      * @javascript Re-compilers must convert the instance invocation of this method directly
342      * into a JavaScript invocation on its current object instance without changing the 
343      * method name, but expanding variable arguments, if any, into comma-separated values. 
344      */
345     public final Number TotalFrames() {
346         return call(TotalFrames);
347     }
348     /**
349      * <p>Changes the size of the movie's viewport.</p>
350      * <p>This method scales the viewport by a specified percentage. Arguments between 
351      * 1 and 99 reduce the size of the viewport, which makes objects in the movie 
352      * appear larger. Arguments greater than 100 enlarge the viewport (but never beyond 
353      * the size of the movie) and make objects in the movie appear smaller. As a special 
354      * case, the argument 0 restores the viewport to full size, so that the entire movie 
355      * is visible.</p>
356      * @param percentage The percentage by which to scale the viewport, or 0 to restore 
357      * the viewport to its full size.
358      * @since 1.0
359      * @javascript Re-compilers must convert the instance invocation of this method directly
360      * into a JavaScript invocation on its current object instance without changing the 
361      * method name, but expanding variable arguments, if any, into comma-separated values. 
362      */
363     public final void Zoom(Number percentage) {
364         call(Zoom, percentage);
365     }
366     /**
367      * <p>Changes the size of the movie's viewport.</p>
368      * <p>This method scales the viewport by a specified percentage. Arguments between 
369      * 1 and 99 reduce the size of the viewport, which makes objects in the movie 
370      * appear larger. Arguments greater than 100 enlarge the viewport (but never beyond 
371      * the size of the movie) and make objects in the movie appear smaller. As a special 
372      * case, the argument 0 restores the viewport to full size, so that the entire movie 
373      * is visible.</p>
374      * @param percentage The percentage by which to scale the viewport, or 0 to restore 
375      * the viewport to its full size.
376      * @since 1.0
377      * @javascript Re-compilers must convert the instance invocation of this method directly
378      * into a JavaScript invocation on its current object instance without changing the 
379      * method name, but expanding variable arguments, if any, into comma-separated values. 
380      */
381     public final void Zoom(NumberLike<?> percentage) {
382         Zoom(Js.valueOf(percentage));
383     }
384 }