[SWFObject] ExternalInterface and Levels

ReDrUm redrumnz at gmail.com
Sun Sep 3 00:19:24 PDT 2006


Hi Everyone,

This isnt a swfObject specific question so i apologise for that fact but...

I'm trying to build an a flash container swf to perform 2 functions.

The First:
To have an image loader using the Loader Component in the hopes of changing
the contentPath via ExternalInterface

The Second:
To have a flash video player using the FLVPlayBack Component. Again changing
the contentPath via ExternalInterface

My Problem:
I've added the two components to my library, and created two movie clips,
LoaderIMG, and LoaderFLV. Inside each of these MCs is the appropriate
component with a set instance name. I only want one component on the screen
at once. What i want to achieve is the ability to change the content path of
each component externally using the ExternalInterface in Flash 8. Ignoring
the fact that my end goal is to use external interface, in the meantime I am
currently having trouble figuring out how to change the contentPath of the
two loaders. They each only load their origional contentPath values set in
the component instances in the Loader MC's I created. I've been
experimenting with _root, _parent, and _levels but I'm still not having much
luck. If any of you could suggest a fix or an alternative method I would
much appreciate it.

Thanks alot.

Actionscript below:

// This is a gateway to JavaScript via the ExternalInterface (Do i need two
- one for each function to be called externally?)
var ei1 = flash.external.ExternalInterface.addCallback("loadImages", null,
loadImages);
var ei2 = flash.external.ExternalInterface.addCallback("loadVideos", null,
loadVideos);

// Temp for development (Its not loading these paths currently which is what
i want to fix)
imgPath = "pics/red.gif";
vdoPath = "media/test2.flv";
trace(imgPath);
trace(vdoPath);

// Function to add the FLVplayer MC to the stage when called upon
function createLoaderFLV ()
{
 // Call our component from the library
 attachMovie("loaderFLV", "loaderFLV", 1);
 // Set its X and Y co-ordinates
 loaderFLV._x = 0;
 loaderFLV._y = 0;
}

// Function to add our imgLoader MC to the stage when called upon
function createLoaderIMG ()
{
 // Call our component from the library
 attachMovie("loaderIMG", "loaderIMG", 2);
 // Set its X and Y co-ordinates
 loaderIMG._x = 0;
 loaderIMG._y = 0;
}

// Function to set the contentPath of the images and call createLoaderIMG
function to the stage
function loadImages (imgPath)
{
 // Remove the loaders from the stage
 loaderFLV.removeMovieClip();
 loaderIMG.removeMovieClip();
 // Creates instances of the loaders on the stage
 createLoaderIMG();
 // Sets the contentPath to that specified externally via php
 imgContainer.contentPath = imgPath;
}

// Function to set the contentPath of the videos and call createLoaderFLV
function to the stage
function loadVideos (vdoPath)
{
 // Remove the loaders from the stage
 loaderIMG.removeMovieClip();
 loaderFLV.removeMovieClip();
 // Creates instances of the loaders on the stage
 createLoaderFLV();
 // Sets the contentPath to that specified externally via php
 vdoContainer.contentPath = vdoPath;
 // Plays the file once loaded
 vdoContainer.play();
}

// Loads the Images or Videos inside their loaders on the stage, start with
Images
loadImages(imgPath);
//loadVideos(vdoPath);

Thanks again to anyone who can help,

Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.deconcept.com/pipermail/swfobject-deconcept.com/attachments/20060903/7ce2bb49/attachment-0004.htm>


More information about the Swfobject mailing list