com.flagstone.transform
Class Import2

java.lang.Object
  extended by com.flagstone.transform.Import2
All Implemented Interfaces:
Copyable<MovieTag>, SWFEncodeable, MovieTag

public final class Import2
extends Object
implements MovieTag

Import2 is used to import shapes and other objects from another Flash file referenced by a URL.

To provide a degree of security the Flash Player will only import files that originate from the same domain as the file that it is currently playing. For example if the Flash file being shown was loaded from www.mydomain.com/flash.swf then the file contains the exported objects must reside somewhere at www.mydomain.com. This prevents a malicious Flash file from loading files from an unknown third party.

Since the identifier for an object is only unique within a given Flash file, imported objects are referenced by a name assigned when the object is exported.

Import2 was added in Flash 8. It currently has the same functionality as Import.

See Also:
Export, Import

Constructor Summary
Import2()
          Creates a Import2 object with an empty table.
Import2(Import2 object)
          Creates and initialises an Import2 object using the values copied from another Import2 object.
Import2(String aUrl, Map<Integer,String> map)
          Creates an Import2 object that imports an object from the specified file.
Import2(SWFDecoder coder)
          Creates and initialises an Import2 object using values encoded in the Flash binary format.
 
Method Summary
 Import2 add(int uid, String aString)
          Adds the identifier and name to the list of objects to be imported.
 Import2 copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 Map<Integer,String> getObjects()
          Get the table of objects to be imported.
 String getUrl()
          Get the URL of the file containing the object to be imported.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setObjects(Map<Integer,String> aTable)
          Sets the table of objects to be imported.
 void setUrl(String aString)
          Sets the URL of the file containing the imported objects.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Import2

public Import2(SWFDecoder coder)
        throws IOException
Creates and initialises an Import2 object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

Import2

public Import2()
Creates a Import2 object with an empty table.


Import2

public Import2(String aUrl,
               Map<Integer,String> map)
Creates an Import2 object that imports an object from the specified file.

Parameters:
aUrl - the URL referencing the file to be imported.
map - the table to add the identifier-name pairs of the objects that will be imported.

Import2

public Import2(Import2 object)
Creates and initialises an Import2 object using the values copied from another Import2 object.

Parameters:
object - an Import2 object from which the values will be copied.
Method Detail

add

public Import2 add(int uid,
                   String aString)
Adds the identifier and name to the list of objects to be imported.

Parameters:
uid - the identifier of the object to be imported. Must be in the range 1..65535.
aString - the name of the imported object to allow it to be referenced. Must not be null or an empty string.
Returns:
this object.

getUrl

public String getUrl()
Get the URL of the file containing the object to be imported. Limited security is provided by requiring that the URL must be in the same domain or sub-domain as the URL of the movie which contains this object.

Returns:
the URL used to import the objects.

setUrl

public void setUrl(String aString)
Sets the URL of the file containing the imported objects. The URL must be in the same sub-domain and relative to the URL of the file containing the Import object.

Parameters:
aString - a URL relative to the URL of the file containing the Import object. Must not be null or an empty string.

getObjects

public Map<Integer,String> getObjects()
Get the table of objects to be imported.

Returns:
the mapping of the names of the imported objects to unique identifiers in this movie.

setObjects

public void setObjects(Map<Integer,String> aTable)
Sets the table of objects to be imported.

Parameters:
aTable - the table of objects being imported. Must not be null.

copy

public Import2 copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<MovieTag>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()

Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.