Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Preloading Child MC's



Does anyone know how I could preload a child movie clip? I have each of my links on my site as their own mc's and I want to be able to preload them. I have two scenes with a main preloader on the first scene and then the rest of the site on scene two. I then have mc's on the second scene that I want to preload as well. The child mc's on scene two are are obviously sinked with the main timeline so most of them don't have any content before around 85 frames or so. How can I preload these right before their content appears? Any ideas? Thanks a lot, Jesse



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 03-03-2005, 04:11 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Preloading Child MC's
Does anyone know how I could preload a child movie clip? I have each of my links on my site as their own mc's and I want to be able to preload them. I have two scenes with a main preloader on the first scene and then the rest of the site on scene two. I then have mc's on the second scene that I want to preload as well. The child mc's on scene two are are obviously sinked with the main timeline so most of them don't have any content before around 85 frames or so. How can I preload these right before their content appears? Any ideas? Thanks a lot,

Jesse

Preloading Child From Parent
okay here is my set up
I have a parent .swf called "demo.swf"
and a child caled jukebox.swf

within "jukebox" I have 4 movie clips
each with it's own instance name
In each movie the first frame is empty with the stop(); action
then in frame two a song starts to stream

within the demo.swf I have 4 buttons
each with this script (instance names change of course)


Code:
on (release) {
stopAllSounds();
_root.jukebox.song1.gotoAndPlay(2);
}
now my issue..
Is it possible for me to preload the jukebox.swf, with a progress bar sitting in the demo.swf?

Cause as it stands when you first open the site, and go to the audio section, only one of the four songs will play.. (ie: not done loading yet)
if you refresh the page they then all play

Preloading Child Movies Into Parent Movie
hey everyone,
I have a parent movie which contains a preloader movie that i want to activate when child movies are loaded into the parent movie, similar to http://www.muppets.com
my preloader is 3 frames the first frames as is:

bytestotal = loader2.getBytesTotal();
bytesloaded = loader2.getBytesLoaded();
percentloaded = Math.round((bytesloaded/bytestotal)*100);
if (bytestotal == bytesloaded){
gotoAndPlay(3);
}
if(percentloaded !=100){
setProperty(_root.loadingmove.loaderbar.sliderbar, _xscale,percentloaded*2);
}

where loader2 is the load window
the second frame sends it back to one and the third frame just has stop();

when a button is clicked inside the first child movie, it loads another child movie in the loader2 window. It also calls for the preloader to gotoAndPlay(1);as to reactivate the preloader. And it calls set the text of the preloader to Loading (scene name) as follows:
_root.loadingmove.loadingtext.text = "Loading Entertainment";
The movies load fine but the preloader doesn't work and the text in the preloader doesn't show up. Does anyone have any idea why this won't work??
Thanks for your help.
Mat

Preloading A Large Child Mc That Is Contained In 1 Frame Of Timeline
Hi,

I am wondering if anyone can help me, I have the following code for my preloader mc in flash mx,

onClipEvent (enterFrame) {
framesLoaded = (Math.ceil (( _parent._framesloaded / _parent._totalframes) * 100));
gotoAndStop (framesLoaded);
info.text = framesLoaded + "% completed";
if (framesLoaded >= 231) {
_root.gotoAndPlay (2);
}
}
This does not seem to work. I have in my second scene a mc clip named firefly which has 15 layers and 231 frames long , however it occupies only 1 frame of the timeline in scene 2 (a child mc?).

Is this where my problem lies? if so, how do I transfer the frames/layers of my firefly mc into the second scenes timeline so the loader will work.

any help would be appreciated.

Preloading Child Movie Clips Before Functions Can Be Called
okay, so I have a timeline with 2 frames, frame one loads the XML data into the app and advances to frame 2 when done.

Frame 2 has a movie clip on it which displays an image dynamically and resizes it, with preloader.

On the actions layer of frame 2 I have the following:

stop();
if(XMLfeed.image != null) {
imageClip.setImage(XMLfeed.image);
}

this doesn't work because the actionscript in imageClip hasn't loaded yet, so the function isn't available.

if I put in a 3rd frame and move the actionscript on frame 2 to frame 3, it works because imageClip is loaded on frame 2, but this is a kludge.

Any ideas on how to solve this?

thanks
Jacob

Preloading Child Movieclips Individually And Playing Them AFTER They're Fully Loaded
i just want each of my child movieclips to play AFTER they're fully loaded individually. Could somebody please help me out? where did i go wrong here? what did i miss? Please help me out. thank you.

this is what i have right now:

loader_mc._visible = false;
picLoader._visibility = false;

var mcLoader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
mcLoader.addListener(myListener);

myListener.onLoadProgress = function(target_mc,bytesLoaded,bytesTotal) {
loader_mc._visible = true;
picLoader._visible = true;
var pctLoaded = Math.round(bytesLoaded/bytesTotal*100);
loader_mc.bar_mc._xscale = pctLoaded;
if (bytesLoaded >= bytesTotal) {
loader_mc._visible = false;
}
}


btn_1.onRelease = function () {
mcLoader.loadClip("child_mc_01.swf",picLoader);
}
btn_2.onRelease = function () {
mcLoader.loadClip("child_mc_02.swf",picLoader);
}
btn_3.onRelease = function () {
mcLoader.loadClip("child_mc_03.swf",picLoader);
}

Page 2 - Preloading Child Movie Clips Before Functions Can Be Called
Okay, I think I found the "Best practices" solution, and it seems to work...

I export the clip for action script on the first frame from the library...

Then in the first frame of artist_image I have:

ArtistImage.init = function() {
var x = y;
etc. etc.
}

Object.registerObject("artist_image",ArtistImage);
ArtistImage.prototype = new MovieClip();

ArtistImage.prototype.setImage = function(imagename) {
//do it all here
}

This seems to work, and loads before the function call is made.

What do you think of this?

Oop Question: A Simple Way To Access Methods In Child Classes From Other Child Class
hi All, I have another oop question.

I'd like to call a method in a child class from another child class.
I'd like to do it without instantiating the other child class...
an example will be easier to see what I mean

document class

ActionScript Code:
package
{
    import flash.display.*
    public class Tester extends MovieClip
    {
        var ch1:Child1;
        var ch2:Child2;
       
        function Tester()
        {
            ch1 = new Child1();
            ch2 = new Child2();
        }
    }
}
child 1

ActionScript Code:
package
{
    class Child1 extends MovieClip
    {
        function Child1()
        {
            trace("Child1 is working");
        }
       
        public function hello()
        {
            trace("Child1 Hello function")
        }
    }
}
child 2

ActionScript Code:
package
{   import flash.display.*
    class Child2 extends MovieClip
    {
        function Child2()
        {
            trace("Child2 is working");
           
            //Tester.ch1.hello();
        }
    }
}

the commented line in Child2 is what I'm asking about. is there any way to do this without defining the Tester class in Child2?

... I mean, without saying : var tstr:Tester = new Tester(); in Child2... and then calling the function via tstr.hello();

thank in advance guys..

Stop FLV Playback In Child When Removing Child (or At Least Silence Audio)
I'm working on a flash site with a number of different "states" (home, features, demo, etc.) each of which is a movie clip with its own actionscript, added as a child when requested, removed when the user chooses a new state.

One of the states plays short FLV videos. The problem is, when switching away from that state to a different state, even though the child is removed, the current video apparently keeps playing as I can hear the audio continuing on.

To demonstrate, the site is here. Click on "Demo", then play one of the videos and switch to a different state (home, features, whatever) while the video plays.

I'm trying to call a function in the child to stop video playback (first checking whether the function exists before trying to call it). The checking part works, but the function call is giving me a "call to possibly undefined method" error when publishing. Probably because I'm calling it the wrong way.

Here's the "remove child" code used after switching to a new state:


Code:
var child:DisplayObject;

while(stateContainer.numChildren > 1)
{
child = stateContainer.getChildAt(0);
if ('stopPlayback' in child)
{
trace('exists');
child.stopPlayback();
}
else
{
trace('does not exist');
}

stateContainer.removeChildAt(0);
}
Can you tell me a better way to do this? I find it strange that it traces "exists" when the function exists, but still complains that child.stopPlayback() (might not) exist.

Variables Of A Child Not Visible To A Function In The Child Called From Its Parent ?
sorry, this is a repeat thread, but couldn't change the title on the old one, someone must know the solution to this problem, I just dont think i worded it correctly enough for someone who knew what i was talking about to notice last time.

Ive got a movieclip that creates and adds a child mc then calls a function in the new mc. the function runs, but the local vars for the new mc aren't visible to the function. Is there a special way to call a function so that its scope is in the child, not in the parent ? ( i assume thats where it is, even though a trace of this returns the correct object type )

ie:

[Parent Clip]
--[child clip: movGraph]
--variable ( var thegraph:MovieClip = this; )
--[function loadMe]
--(trace (theGraph); )

calling movGraph.loadMe spits out undefined or null object error, as opposed to
[object movGraph]

obviously i want to do a whole lot more than trace out the object type, and trace(this) in the function returns [object movGraph]. the variable "theGraph" declared in the child isn't available or its null somehow.

Can anyone tell me where I'm going wrong ? - any help would be appreciated. at the moment I'm having to add all the code in the function instead of the "root" of the child. which really defeats the point.

RemoveChild? I Want To Remove The Previous Child Before Adding A New Child
I tinkered with AS3 a few months back, but don't have ANY of the old scripts and can't remember much.

I'm calling a method to add a new MovieClip to the Stage from the library, I've got that setup and working but each new instance overlay's the old one and doesn't replace.

I clearly need to removeMovieClip() but that is an AS2 function not AS3?

removeChild returns an error:

**
TypeError: Error #2007: Parameter child must be non-null.
at flash.display:isplayObjectContainer/removeChild()
at LukeSturgeon/loadPage()
at LukeSturgeon/navButtonHandler()
**

my two key functions are:

**
/**
* loadPage method
*/
public function loadPage(page_str:String):void {
removeChild(page)
var page:MovieClip = getPage(page_str);
///
page.x = padding_left;
page.y = padding_top;
this.addChild(page);
}
/**
* getPage method
*/
private function getPage(page_str):MovieClip {
var new_page:MovieClip;
///
switch (page_str) {
case "Profile" :
new_page = new Profile();
break;
case "Contact" :
new_page = new Contact();
break;
default :
new_page = new Work();
}
return new_page;
}

this version (minus the removeChild line) is viewable at http://www.lukesturgeon.co.uk/as3

any thoughts? it's probably so simple!!!

Code Problem: Getting A Child Of A Child Using GetChildAt()
Hi Guys,

Need a bit of help here! I'll explain what my set up is first:

In my game, I have a number of level icons set up on the stage (movieclips), each with a padlock symbol on it (a child movieclip). All level icons are placed in a container movieclip call 'container'.

Here's what I'm trying to do:

hide the padlocks on selected level icons from within my code.

To do this, I'm cycling through the children of the container movieclip to get at each level icon as follows:


Code:
for (var n=0; n<container.numChildren; n++) {
var displayItem:DisplayObject = container.getChildAt(n);
//etc.
}


That bit works nicely - I can get at each of the level icons which is now called 'displayItem'.

But now, I want to get at the child of 'displayItem' (ie the padlock, so I can hide it. I was thinking:


Code:
var child:DisplayObject = displayItem.getchildAt(0);


would do it, but I get a 'call to undefined method getChildAt through a reference with static type' error.

This seems to be telling me that 'displayItem' doesn't have that particular method associated with it.

With that attempt failed, I tried instead adding the padlocks to the level icons from within the code:


Code:
for (var n=0; n<container.numChildren; n++) {
var displayItem:DisplayObject = container.getChildAt(n);

var padlock:padlock_mc = new padlock_mc();
container.displayItem.addChild(padlock);
}


.... but that gives the same error. There's something about the display item retrieved from getChildAt that won't let me get at it's methods/properties.

I then tried converting the type from DisplayObejct to MovieClip:


Code:
container.(displayItem as MovieClip).addChild(padlock);


but that threw a 'filter operator not supported' error.


Any ideas how I should be going about this?

Cheers.

Remove Child After Adding Child Issue
OK so here goes. I was helped extremely before on my problem but while testing and checking output window I get the following error:

TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at final2fla_fla::MainTimeline/reportDownCdRomClick()

This only happens when I click on the reportDownCdRomClick button (button2) not on the other. This is what I am working with:












Attach Code

//variables for buttons
var myLeftRequest:URLRequest;
var myRightRequest:URLRequest;
var myLeftLoader:Loader;
var myRightLoader:Loader;
var myCdRomRequest:URLRequest;
var myCdRomLoader:Loader;


//Web Button Listeners
webwork_mc.addEventListener(MouseEvent.CLICK,reportDownWebClick);
cdrom_mc.addEventListener(MouseEvent.CLICK, reportDownCdRomClick);
//photo_mc.addEventListener(MouseEvent.MOUSE_DOWN, reportDownPhotoClick);
//design_mc.addEventListener(MouseEvent.MOUSE_DOWN, reportDownDesignClick);

//Function for web button

//button one
function reportDownWebClick(myevent:MouseEvent):void {
myLeftRequest = new URLRequest("left-content.swf");
myRightRequest = new URLRequest("right-content.swf");
myLeftLoader= new Loader();
myRightLoader = new Loader();
myLeftLoader.x=70;
myLeftLoader.y=168;
myRightLoader.x=460;
myRightLoader.y=168;
myLeftLoader.load(myLeftRequest);
myRightLoader.load(myRightRequest);
addChild(myLeftLoader);
addChild(myRightLoader);
removeChild(myCdRomLoader);
webwork_mc.removeEventListener(MouseEvent.CLICK, reportDownWebClick);
cdrom_mc.addEventListener(MouseEvent.CLICK,reportDownCdRomClick);
}

//button two

function reportDownCdRomClick(myevent:MouseEvent):void {
myCdRomRequest = new URLRequest("XML2.swf");
myCdRomLoader = new Loader();
myCdRomLoader.load(myCdRomRequest);
myCdRomLoader.y = 140;
addChild(myCdRomLoader);
removeChild(myLeftLoader);
removeChild(myRightLoader);
webwork_mc.addEventListener(MouseEvent.CLICK,reportDownWebClick);
cdrom_mc.removeEventListener(MouseEvent.CLICK, reportDownCdRomClick);
}

Child Swf Load New Child Swf Inot Parent Swf
ok you're all going to think i'm super dense

but i'm also super stressed and fast approaching a deadline

can someone please tell me the simplest way to load a child swf into a parent swf from another child swf

eg. what code do i apply to the button?

i am loading into a container.mc (blank) in the parent swf

Child Swf Load New Child Swf Inot Parent Swf
ok you're all going to think i'm super dense

but i'm also super stressed and fast approaching a deadline

can someone please tell me the simplest way to load a child swf into a parent swf from another child swf

eg. what code do i apply to the button?

i am loading into a container.mc (blank) in the parent swf

Event Triggered From Child's Child
I've searched and search and apparently I'm missing something. I have a function in the main timeline but I want it to trigger from a grandchild event.

Basically I have a loader in the main timeline loading in external SWFs but I can't get them to trigger an event on the main timeline.

Main Timeline

ActionScript Code:
movieClip_mc.addEventListener(Event.COMPLETE, bounceM);
   
function bounceM(event:Event):void
{
    movieClip_mc.y -= 1;
}

Code in child of child


ActionScript Code:
this.parent.parent.movieClip_mc.play();

I only have like 10 good days of AS3 experience and thought I was good but can't get simple paths correct because nothing is happening. I've done tried traces in the child SWF and those don't work, either.

Removing A Child Inside A Child
I have a main swf file that loads and external swf file which loads an additional external swf file. I am using the addChild method to load these swf files. I am able to get the first child to unload using

function goMain(event:MouseEvent):void
{
this.parent.parent.removeChild(this.parent);
}

but I am having trouble getting the child swf inside of the first child swf to unload. Does any one know how to solve this problem. I tried

function goMain(event:MouseEvent):void
{
this.parent.parent.parent.parent.removeChild(this. parent);
}

but it does not work.

Reaching Property Of A Child From Another Child
I am banging my head with this problem. I am fairly new at this and this is my first code that is Object Oriented with ActionScript.

My documentclass Main calls two functions which instantiates two customclasses:


Code:
function addMenuBar():void {
var menuBar:customMenuBar = new customMenuBar();
addChild(menuBar);
menuBar.setYpos(80);
}

public function addContentArea():void {
var ContentArea:contentArea = new contentArea();
addChild(ContentArea);
ContentArea.SetPos((stage.stageWidth / 2),(stage.stageHeight / 1.5));
ContentArea.SetColor(0xFF0000, 0.5);
}
Offcourse these are a menubar with 4 buttons and a sprite marking the content area.


the menuBar code:

Code:
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import fl.motion.Color;
import flash.geom.ColorTransform;
import flash.filters.*;
/*import contentArea.**/

public class customMenuBar extends MovieClip {

public var menuBarY:Number;

public function customMenuBar() {
init();
}
public function init():void {



//Instansiate the menu buttons
var zlapshot:BarBtnLL = new BarBtnLL();
addChild(zlapshot);
zlapshot.name = "zlapshot";
zlapshot.x = (167.4-7.4);
zlapshot.y = menuBarY;
trace(zlapshot);
trace(zlapshot.name);



var busPart:BarBtnL = new BarBtnL ();
addChild(busPart);
busPart.name = "busPart";
busPart.x = (327.5-7.4);
busPart.y = menuBarY;

var news:BarBtnR = new BarBtnR ();
addChild(news);
news.name = "news";
news.x = (487.8-7.4);
news.y = menuBarY;

var contact:BarBtnRR = new BarBtnRR ();
addChild(contact);
contact.name = "contact";
contact.x = (647.6-7.4);
contact.y = menuBarY;

//Instansiate the menu border
var menuBarBorder:MenuBarBorder = new MenuBarBorder();
addChild(menuBarBorder);
menuBarBorder.x = (407.4-7.4);
menuBarBorder.y = menuBarY;

// create the array to hold all the names of the buttons
var myButtonsArray:Array = new Array(["zlapshot"],["busPart"],["news"], ["contact"]);

//Eventlisteners for the buttons
for (var i:Number = 0; i< myButtonsArray.length; i++) {
getChildByName(myButtonsArray[i]).addEventListener(MouseEvent.CLICK, clickMenu);
getChildByName(myButtonsArray[i]).addEventListener(MouseEvent.MOUSE_OVER, onOver);
getChildByName(myButtonsArray[i]).addEventListener(MouseEvent.MOUSE_OUT, onOut);
getChildByName(myButtonsArray[i]).addEventListener(MouseEvent.MOUSE_UP, onUp);
}
//Set button modes
zlapshot.buttonMode = true;
busPart.buttonMode = true;
news.buttonMode = true;
contact.buttonMode = true;

//Declare the variable that will hold the name of the last button clicked
var buttonClicked:String;

// Function for dimming the menubuttons upp and down
function alphaDown(arg:MovieClip):void {
arg.alpha = 0.5;
trace("Alpha down arg: " + arg);
}

var count:Number = myButtonsArray.length;
function alphaUp(exc:MovieClip):void {
for (var i:Number = 0; i<count; i++) {
if (exc !== getChildByName(myButtonsArray[i])) {
getChildByName(myButtonsArray[i]).alpha = 1.0;
}
}
}
function clickMenu(event:MouseEvent):void {
buttonClicked = event.target.name;
alphaDown(event.target);
//trace (ContentArea.x);



}
function onOver(event:MouseEvent):void {
if (buttonClicked != event.target.name) {
event.target.alpha = .7;
trace(event.target + " + " + event.target.name);
}
}
function onOut(event:MouseEvent):void {
if (buttonClicked == event.target.name) {
event.target.alpha = 0.5;
} else {
event.target.alpha = 1.0;
}
}
function onUp(event:MouseEvent):void {
alphaUp(event.target);
}
}
public function setYpos(valueY):void {
this.y = valueY;

}
}
}
The problem I have is to reach the contentAre instance ContentArea from within the clickMenu function. I want to change the color of the content area on the first click on one of the menubuttons.

If I "uncomment" the line ://trace (ContentArea.x); in the clickMenu function i get the "1046: Type was not found or was not a compile-time constant: DisplayObject." error.

Can someone help me in the right direction, I would be very thankfull.

/Christian

I Am Adding A Child To The Stage, Adding An Event Listener To The Child. I Then Want
I'm trying to do something that seems like it should be really simple to do.

I am adding a child to the stage, adding an event listener to the child. I then want to remove the child from within the event listener.


ActionScript Code:
var newClip:NewClip = new NewClip();

addChild(newClip);

newClip.addEventListener(Event.ENTER_FRAME, newClipListener);

public function newClipListener(event:Event) {
    trace("test");
}


I've tried quite a few things and nothing seems to work. The only method I know that works looks like this, but it's stupid and cumbersome and i'm sure there is a better way


ActionScript Code:
var newClip:NewClip = new NewClip();

addChild(newClip);

newClipArray.push(newClip);

newClip.myID = newClipArray.length-1;


newClip.addEventListener(Event.ENTER_FRAME, newClipListener);


public function newClipListener(event:Event) {

    removeChild(newClipArray[event.target.myID]);
   
}

A Child Swf Telling Another Child Swf To Do Something
Is this possible and if so how?

I have a child swf with a button. When I click on a button, it tells the parent swf to do 2 things:

Code:
on (release) {
with (_root) {
gotoAndStop("Act2");
}
with (_root.navigation) {
gotoAndStop("DHK");
}
}
Now this works. By the way this child swf is on the MC, “content2”. And when you click on this button, “content2” replaces this child swf with another child swf.

Can the first child swf tell the second swf to “gotoAndStop(3)”? Is this possible while keeping the above code working?

(hope this makes sense)

Main Swf Loading Child Swf Loading Child Swf
Hello

Need a little AS advice please!

I have a main swf movie that is a website. This has a blank movie within it that loads external swf files. Within one of those swf files there is another blank movie that loads another external swf file. That make any sense?

I have movie outros in each file. My problem is that when the second nested movie is loaded within the first nested movie it does not play the movie outro.

I'm basiclly using the same script that is in the 'Transitions Between External SWFs' tutorial on this site.

What is the action script I need to attach to the buttons for this to work?

Really hope someone can help!

Many thanks!

Poul

Preloading .swf Before Preloading Main Movie
Ummm

Things are getting complicated lol

I have my main movie going ..AND I actually managed to get a pre-loader working ...

and it's all ok as long as you have adsl or cable connection - otherwise it is REALLY messy.

The main .swf uploads onto the web .. but the secondary swf have not yet loaded .. and so it is all out of synch .. if you wait a while and refresh you get it ... but argh it is horrible .....

so .. is it possible to block the preload of the main movie until it has preloaded its secondary swf's ??

I should imagine it's recoding the actions AGAIN .. can any one get me started please ..

Is this often a problem if you add swf to a main movie ???

tyyyy all

julia

Help Required Progress Indicator Bars. NOT PRELOADING BARS AND NOT A PRELOADING QUE
Help required ! progress indicator bars. NOT PRELOADING BARS AND NOT A PRELOADING QUESTION!

OK I have a swf called audio.swf which just contains a 15 minute streaming audio file that it just dragged along the time line.

I want to have some visual indicators in the swf, so that the user has some info of what is going on:

What I require within the swf are the following:

1.Progress Bar: How much of the movie has been played. This will obviously go up as the timeline for the swf progresses.
2.Streaming bar: Giving the user an indication of the amount of swf that has currently been downloaded.
3.Time (minutes and seconds) that the movie clip has been playing for
4.Elaped time (time remaining)

As you can see I have attached no fla, as I am sure that these 4 visual indicators are all fairly simple to code of any of you action script daddies out there.

Any help on one or all the 4 things I require would be brilliant.

If anyone could help me this would be more than appreciated.
Cheers

PRELOADING (dynamic Preloading?)
dear all

i hope someone could give me tips how to do this:

i have one main scene and 7 navigation-points. each of the 7 scenes are external movies which should be loaded.

but can they load in the background too, even if the user didnt select a point yet? and when he does, the progress bar would automaticly fill up as much as the movie is loaded already. and it should continue loading all the scenes in the background, while he is in one section.

i hope you know what i mean, excuse my english.

looking forward for a help asap. thanks a lot in advance!

PreLoading Scenes (PRELOADING)
Hi everyone. Ive had my website running for a while now www.coriolis-effect.co.uk Its nearly done all but preloading really. I want visitors to be shown that something is happening rather then just waiting. This has caused a fair percent of people to leave the site straight away especially those with crap connections. Anyway Ive had a look around on the forum a bit for help and I can't see anything about Scenes and preloading them. Maybe there is a way to just preload so many frames? Any help appreciated Lewis

http://www.purgeme.co.uk/lewis/Corio...lis-Effect.fla

Child X & Y
Is there a way to find a child clip's x and y positions relative to the stage, rather than relative to the parent clip?

I have a clip on my stage which I would like to follow a rotating clip's stationary child, but

Code:
follower_mc._x = parent_mc.child_mc._x;

only sends the follower_mc to the child's mathematical equivalent to its position inside the parent. (I hope that's clear)

Thoughts?
~gyz

An Mc's Child
the problem:

main.mc.onRollOver = function(){

//blah blah

}

the "mc" in main.mc is mc45, mc33, mc44, so on..

the goal is to either prototype a _child, and extend the movieclip class - or a function, but I'm having NO LUCK.

thnx!

- jT

How To Get To This Child?
How do I get to <image> tag?:


Code:
<pictures><picture>
<title_text>this is my first project</title_text>
<description>fdsfdsfdsfdsjhdfshjdfghjdfghgkjdfghgjkdfgshgkjgdfhkgjfgdhjkfgdhjkfgdhjfghjfhjfdghjkfdghjkfgd</description>
<images>
<image>how1.jpg</image>
<image>how2.jpg</image>
<image>how3.jpg</image>
</images>
</picture></pictures>
currently I have: (on a for loop (i))

Code:
childNodes[i].childNodes[2].childNodes[i];
This only returns:
<image>how1.jpg</image>??

Child Of Mc
This code works:

ActionScript Code:
var yes:Yes = new Yes()
yes.x = 200
yes.y = 200
yes.addEventListener(MouseEvent.CLICK, yesClicked)
addChild(yes)

function yesClicked(event:MouseEvent) {

trace("yes clicked")
yes.removeEventListener(MouseEvent.CLICK, yesClicked)
}




This code gives me the Error:


TypeError: Error #1010: A term is undefined and has no properties.
at Untitled_fla::MainTimeline/yesClicked()



ActionScript Code:
var yes:Yes = new Yes()
yes.x = 200
yes.y = 200
yes.addEventListener(MouseEvent.CLICK, yesClicked)
scroller.addChild(yes)

function yesClicked(event:MouseEvent) {

trace("yes clicked")
scroller.yes.removeEventListener(MouseEvent.CLICK, yesClicked)

   
}


scroller is a MovieClip(instance name scroller)

?So why do I get an error, what term has undefined properties?

Add Child
I'm trying to create and add childs with script but I don't know what I'm doing wrong can someone please help

[code]
var track:MovieClip = new MovieClip();
//a shape is drawn with script
var thumb:MovieClip = new MovieClip();
//a shape is drawn with script

var sb:MovieClip = new MovieClip();
this.sb.addChild(track);
this.sb.addChild(thumb);

var scrollbox:MovieClip = new MovieClip();
this.scrollbox.addChild(sb);
this.addChild(scrollbox);
[/code]


I also tried this with no luck
[code]
var track:MovieClip = new MovieClip();
//a shape is drawn with script
var thumb:MovieClip = new MovieClip();
//a shape is drawn with script

var sb:MovieClip = new MovieClip();
var sb0 = new track();
this.scrollbox.addChild(sb0);
var sb1 = new thumb();
this.scrollbox.addChild(sb1);

var scrollbox:MovieClip = new MovieClip();
var sb2 = new sb();
this.scrollbox.addChild(sb2);
this.addChild(scrollbox);
[/code]






























Edited: 12/10/2008 at 05:12:13 PM by newwaveboats

Next Child...mp3
hey all,
I was wondering if anyone knew of a way i could make my xml based mp3 player goto the next child node as soon as the file had finished playing, instead of having to push a next button. I would assume i would have to use a getTimer function or something of that nature and include a TIME variable in my xml to do that. Is there an easier way??
Thanks,
Mat

Child _x And _y
I have a MC on the stage with another MC inside it. I am attaching a MC to the stage and I want its _x and _y to be the same as the MC that is inside the MC but this doesnt work since its _x and _y go from the parent MC's registration point.

Is there anyway to work around this?

Thanks.

How Do I Get To This Child In My Xml?
My xml file looks like this:

PHP Code:



<?xml version="1.0" encoding="UTF-8"?><gallery>    <album id="liveshots" title="liveshots" lgPath="photos/livelg" tnPath="photos/livetn" tn="galleryThumb.jpg" description="liveshots">        <img src="live1.jpg" caption="This where your photo caption would be" />        <img src="live2.jpg" caption="This where your photo caption would be" />        <img src="live3.jpg" caption="This where your photo caption would be" />    </album>    <album id="studioshots" title="studioshots" lgPath="photos/studiolg" tnPath="photos/studiotn" tn="galleryThumb.jpg" description="liveshots">        <img src="stu1.jpg" caption="This where your photo caption would be" />        <img src="stu2.jpg" caption="This where your photo caption would be" />        <img src="stu3.jpg" caption="This where your photo caption would be" />        <img src="stu4.jpg" caption="This where your photo caption would be" />    </album></gallery>



I can get into the 'liveshots' area no problem. My issue is getting to the 'studioshots' area. My code looks like this:
ActionScript Code:
_root.imagesxml = new XML();
_root.imagesxml.ignoreWhite = true;
_root.imagesxml.onLoad = function() {
livelength = imagesxml.firstChild.firstChild.childNodes.length;
studiolength = imagesxml...
trace(livelength);
trace(studiolength);
}
_root.imagesxml.load("images.xml");




as you can see studiolength hasnt been defined yet since I dont know how to navigate to it. I know its something simple. Any hints? Thanks a lot!
-Ronnie

Can't Get My Child
well, I've got an xml file that loads photos/thumbnails. This is contained in an external.as file, and is working well. The problem is that my fla contains menus with movieclip buttons that used to animate on rollover.

I took all of the code out of the fla, because I read that it will cause conflicts. SO, how do I access those animated buttons, tell them when to stop or play from the external file without a hundred error messages? Am I missing something obvious?

menu buttons are: itemTwo, itemThree are placed in a MC titled: bioClip

DocumentOne is the .as file

I was using hitTestPoint to check to see it they should play or not. anyway, here is the code:

package {
import flash.display.DisplayObjectContainer;
import flash.display.SimpleButton;
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import fl.transitions.easing.*;
import fl.transitions.Tween;
import fl.controls.ProgressBar;
public class DocumentOne extends Sprite {
private var _xml:XML;
private var _currentImage:int=0,_currentThumb:int=0,_numThumbs :int;
private var _loader:Loader = new Loader();
private var _progressBar=new ProgressBar();
private var _thumbArray:Array=new Array();
private var _tweenY:Tween;
private var _oldTweenY:Number, _thumbHeight:Number;
private var _thumbContainer:Sprite=new Sprite(),_thumbContainerMask:Sprite=new Sprite();
public function DocumentOne() {
this._tweenY=new Tween(_thumbContainer,"y",Back.easeOut,0,0,0,true) ;
this._tweenY.stop();
_thumbHeight=getChildByName("bar").height; // / 4;
_thumbHeight=47;
_loader.contentLoaderInfo.addEventListener(Event.C OMPLETE, onLoaderCompleteEvent);
//_loader.contentLoaderInfo.addEventListener(IOError Event.IO_ERROR, ioErrorHandler);
_progressBar.source=_loader.contentLoaderInfo;
_progressBar.setSize(200,10);
_progressBar.setStyle("barPadding",2);
_progressBar.x=(stage.stageWidth - _progressBar.width)/2 + 17;
_progressBar.y=(stage.stageHeight - _progressBar.height) * 9 / 10;
addChild(_progressBar);
bar.buttonMode = true;
_thumbContainerMask.graphics.beginFill(0);
_thumbContainerMask.graphics.lineTo(getChildByName ("bar").width,0);
_thumbContainerMask.graphics.lineTo(getChildByName ("bar").width,getChildByName("bar").height);
_thumbContainerMask.graphics.lineTo(0,getChildByNa me("bar").height);
_thumbContainerMask.graphics.endFill();
_thumbContainer.mask=_thumbContainerMask;
getChildByName("bar").addEventListener(MouseEvent. MOUSE_MOVE,scroll) ;
(getChildByName("bar") as DisplayObjectContainer).addChild(_thumbContainer);
(getChildByName("bar") as DisplayObjectContainer).addChild(_thumbContainerMa sk);
(getChildByName("box") as DisplayObjectContainer).addChild(_loader);
getChildByName("prev_btn").addEventListener(MouseE vent.CLICK, onPrevButtonClickEvent);
getChildByName("next_btn").addEventListener(MouseE vent.CLICK, onNextButtonClickEvent);
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onImagesXMLLoadComplete);
xmlLoader.load(new URLRequest("images4.xml"));
portClip.stop();
portClip.buttonMode = false;
portClip.addEventListener(Event.ENTER_FRAME, everyFrame);
portClip.addEventListener(Event.ENTER_FRAME, menuStop);
bioClip.stop();
bioClip.buttonMode = false;
bioClip.addEventListener(Event.ENTER_FRAME, everyFrame1);
bioClip.addEventListener(Event.ENTER_FRAME, menuStop1);
//var itemTwo:MovieClip = new MovieClip(); --------------NONE OF THIS WORKED, SO I COMMENTED IT-----------
//(getChildByName("stage.bioClip") as DisplayObjectContainer).addChild(itemTwo);

//itemTwo.gotoAndStop(1);
//stage.bioClip.itemTwo.buttonMode = true;
//itemTwo.addEventListener(Event.ENTER_FRAME, everyFrameBio2);
//itemTwo.addEventListener(Event.ENTER_FRAME, menuStopBio2);
//itemTwo.addEventListener(Event.ENTER_FRAME, resetBio2);

// portClip CODE TO MOVE ON MOUSEOVER------------------------
function everyFrame(event:Event):void
{
if (portClip.hitTestPoint(mouseX, mouseY, true))
{
portClip.play();
}
else
{
portClip.prevFrame();
}
}

// portClip CODE TO STOP MENU AT 20 FRAMES------------------
function menuStop(event:Event):void
{
if (portClip.currentFrame == 20)
{
portClip.gotoAndStop(20);
}
}
// bioClip CODE TO MOVE ON MOUSEOVER------------------------
function everyFrame1(event:Event):void
{
if (bioClip.hitTestPoint(mouseX, mouseY, true))
{
bioClip.play();
}
else
{
bioClip.prevFrame();
}
}

// bioClip CODE TO STOP MENU AT 20 FRAMES------------------
function menuStop1(event:Event):void
{
if (bioClip.currentFrame == 20)
{
bioClip.gotoAndStop(20);
}
}



// itemTwo CODE TO MOVE ON MOUSEOVER------------------------
function everyFrameBio2(event:Event):void
{
if (itemTwo.hitTestPoint(mouseX, mouseY, true))
{
itemTwo.play();
}
else
{
itemTwo.prevFrame();
}
}

// itemTwo CODE TO STOP MENU AT 20 FRAMES------------------
function menuStopBio2(event:Event):void
{
if (itemTwo.currentFrame == 20)
{
itemTwo.gotoAndPlay(1);
}
}

// itemTwo CODE TO MOVE ON MOUSEOVER------------------------
function resetBio2(event:Event):void
{
if (bioClip.currentFrame == 1)
{
itemTwo.gotoAndStop(1);
}

}



//---------------------------NOW THE PRIVATE FUNCTIONS FOR LOADING XML IMAGES------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
private function get currentImage():int {
return _currentImage;
}
private function set currentImage(number:int):void {
_currentImage=number<0?_xml.photos.length()-1:number>_xml.photos.length()-1?0:number;
}
private function onImagesXMLLoadComplete(event:Event):void {
try {
_xml = new XML(event.target.data);
_loader.load(new URLRequest(_xml.photos[currentImage].large.toString()));
_numThumbs=_xml.photos.length();
for (var i:uint=0;i<_numThumbs;i++) {
_thumbArray[i]=new Loader();
_thumbArray[i].y=i * _thumbHeight;
_thumbArray[i].addEventListener(MouseEvent.CLICK,loadImage);
_thumbArray[i].name=i;
_thumbContainer.addChild(_thumbArray[i]);
}
loadNextThumb();
} catch (error:TypeError) {
trace(error.message);
}
}
private function loadImage(event:MouseEvent):void {
currentImage=event.target.name;
_loader.load(new URLRequest(_xml.photos[currentImage].large.toString()));
new Tween(_progressBar,"alpha",Bounce.easeOut,_progres sBar.alpha,1,2,true);
}
private function loadNextThumb():void {
_thumbArray[_currentThumb].contentLoaderInfo.addEventListener(Event.COMPLETE , onThumbCompleteEvent);
//_thumbArray[_currentThumb].contentLoaderInfo.addEventListener(IOErrorEvent.I O_ERROR, ioErrorHandler);
_thumbArray[_currentThumb].load(new URLRequest(_xml.photos[_currentThumb].small.toString()));
}
private function onThumbCompleteEvent(event:Event):void {
event.target.removeEventListener(Event.COMPLETE, onThumbCompleteEvent);
//event.target.removeEventListener(IOErrorEvent.IO_E RROR, ioErrorHandler);
//event.target.content.width=getChildByName("bar").w idth;
event.target.content.width=57;
event.target.content.height=_thumbHeight - 10;
if (++_currentThumb<_numThumbs) loadNextThumb();
}
private function onLoaderCompleteEvent(event:Event):void {
event.target.content.width=getChildByName("box").w idth;
event.target.content.height=getChildByName("box"). height;
new Tween(_progressBar,"alpha",Bounce.easeOut,_progres sBar.alpha,0,2,true);
}
private function onPrevButtonClickEvent(event:Event):void {
--currentImage;
_loader.load(new URLRequest(_xml.photos[currentImage].large.toString()));
new Tween(_progressBar,"alpha",Bounce.easeOut,_progres sBar.alpha,1,2,true);
}
private function onNextButtonClickEvent(event:Event):void {
++currentImage;
_loader.load(new URLRequest(_xml.photos[currentImage].large.toString()));
new Tween(_progressBar,"alpha",Bounce.easeOut,_progres sBar.alpha,1,2,true);
}
private function scroll(event:MouseEvent) {
var newTweenY:Number=(_thumbContainer.height - _thumbContainerMask.height) * Math.floor(-getChildByName("bar").mouseY / _thumbContainerMask.height * _numThumbs / 1.5 + 1)/(_numThumbs / 1.5 - 1);
if (this._oldTweenY!=newTweenY) {
this._oldTweenY=newTweenY;
this._tweenY.continueTo(newTweenY,Math.abs(this._t weenY.position - newTweenY) / (_numThumbs * 9));
}
}
}
}

Sorry about the huge mess. Any ideas?

Using For...in Mc To Detect All The Child
Hi:

any one know the code to detect all the childs and the childs-childs of the movie ,as I rememberd it's somthing like
for x in mc
...


thank u
firas

Target MC Child
On the main timeline I have an MC parent and inside it, MC child (planets) which are moving along the path (guide layer)... there is a button (on the main timeline) which when pressed sets the Alpha Property of the MC child to 50% ... the planets are still moving with their Alpha set to 50%...

here is the completed .SWF file - please take a look at:

http://www.geocities.com/decschultz/ispit.html


thanks
[Edited by Dario uveljak on 02-22-2002 at 04:21 AM]

Child Instances
hi,

if, you have a clip, which is already on the stage, inside of which is a child clip, which itself is made up of 2 keyframes. The parent clip also has export to actionscript set.

and then you attach another or the parent clips to the main stage.

my question is, if you set the _currentframe (say to frame 2) of the child clip, of one of the parent clips, will that also set the child clip to frame 2, in the other parent clip? and does the child clips having instance names effect anything??

thanks

phil

Child Of Mine
I want to play specific sections of a movieclip that is nested inside my movie.
I have made a test .fla with a movieclip containing a red circle and a yellow circle as clips.
I have a movie clip called mask_mc which is used as a mask to reveal the contents of the yellow clip.
I have the following code in the main_mc to send the playhead inside my mask_mc to the "WIPE" keyframe.
It isn't playing ball.

Code:
box_mc.yellow_mc.mask_mc.gotoAndPlay("WIPE");

Can you see what is wrong with this line of command code.

I think this is quite a simple thing, but I dont know where my error is.

Many Thanks,

Tim.

Calling Up Mc's From Child .swf
I have two swf files.
demo.swf
and jukebox.swf
in the demo.swf i'd like buttons that can call up song's (streaming in movie clips from the child.swf

i can easily do it all from one .swf
give a movie clip an instance name (song1)
then on the button put this action script


Code:
on (release) {
stopAllSounds();
tellTarget ("song1") {
gotoAndPlay(2);
}
}
can someone give me a working equivilant for my child/parent .swf's?

How To Delete XML Child ?
Hi, I created a XML file to be read by my flash program. But what shall i add in my actioscript if I want to delete a specific child/element in the XML file.
Example, if i want to delete all data between <h2>...</h2>:

<h2>
..
..
..
</h2>


Thanks alot.. really urgent..

GotoAndPlay To Child MC?
I'm reorganizing my game but having trouble:

Before this worked:

h.gotoAndPlay("enemy7");

but since then I put all the various enemies in a MC in h called "enemy" and tried this

h.enemy.gotoAndPlay("enemy7");

but it's doesn't work... What am I missing? THANKS!

RemoveChild() From The Child Itself ?
Okay - it's not often I post on forums at all for help - let alone three times recently - but I really appreciate the help here!

As the title says - I've added a child (which is class called "Target" and is an extended Sprite) straight to the main object (entry point). I've also made it somewhat of a Singleton object (the main object, that is) by making a static reference and a GetReference() function to call the main object.

1 - The singleton appears to be working fine - a call to Main.GetInstance().StatusMessage("Test"); works absolutely fine, and outputs to the screen as it should
2 - I've tried, from the child, using this.parent.removeChild(this); - it failed
3 - I've tried:
var d:flash.display.DisplayObject = Main.GetInstance().getChildByName(this.name);
trace(d);
Main.GetInstance().removeChild(d);

d traces as NULL, and of course removeChild fails.

So - how is a child supposed to kill themselves without external involvement? Surely this is something that is required incredible frequently?!

Thanks again!
Mark

If Statement For Child Swf
Flash 8, as2 - What kind of if statement can I use to determine if a child is being loaded into a parent swf, or being loaded directly. If the child swf is not inside the parent swf, it will go one place, and if inside the parent swf, will go another place. I tried this without success(am I close?):

parent swf:

var myGame:String = "foo";
loadMovieNum ("rainbow.swf", 0)
stop();

rainbow.swf:

if (myGame == "foo") {
play();
} else {
gotoAndStop (5);
}

Adding A Child
Help!
I'm not understanding how to add a child to a MovieClip. When I put in

Oregon.addChild(Baker);


where Oregon is a MovieClip converted to a symbol and
Baker is also a MovieClip converted to a symbol and on the
flash timeline, I get the following error:

1017: The definition of base class MovieClip was not found.�

Any ideas for this clueless newbie?

Remove Child
and my problems continues...

now i have my buttons working... and when i click each other.. a can get the correspondent data into the xml file..

so... as the menu items are created by xml data... their are child dinamically created... and as i click each one... a function mostrahorario runs.... creating other mc childs...

what i need now... is eliminate all the previously mc child created, as i click each button item..

my code is that.. and it works until i click the third time in any menu button.
any one nows why?

(...)

//Here i tell to run mostraHorario() when click
cursos[c].addEventListener(MouseEvent.CLICK, mostraHorario(cursosTeatroXML.CURSO[c]));

//Array where i'll save the childs created
var horarioItemFix:Array = new Array();

// function that runs when i click a menu item
function mostraHorario(arg) {

return function () {

// delete eventually every child previuosly created
for (var z:int = 0; z < horarioItemFix.length; z++) {
trace('horarioItemFix: '+horarioItemFix.length);
MovieClip(parent).removeChild(horarioItemFix[z]);
};
// starts to create the new childs that i want to delete later
for (var i:int = 0; i<arg.DIAS.*.length(); i++) {

var horarioItem:MovieClip = new MovieClip();
var childCount = 1;
horarioItem.graphics.beginFill(0x00FF00);
var dur:int = arg.DURACAO/4+2
horarioItem.graphics.drawRect(0, 0, 50, dur);
horarioItem.alpha = 0.5;
horarioItem.graphics.endFill();
horarioItem.x = arg.DIAS.DIA[i]*50-50+25;
var ycoord:int =arg.HORAINICIO;
horarioItem.y = (ycoord/3.75)+16;

MovieClip(parent).addChildAt(horarioItem,0);
horarioItemFix.push(horarioItem);

trace(arg.HORAINICIO);

};
}
}

thanks again...

Can't Remove Child ?
I don't know why it doesn't work and I'm going crazy with my problem.

Here comes the fakts:3 SWF moviesFirst movie starts with addChild. This contains a loader to open the second movie. The second movie also addChild with a loader inside to open the last one. So when I remove the child wich I opend in the first movie the child of the second movie doesn't remove... What are my fault?
Here are the code:

Fist Movie Contains a Button and the function to remove the child

Code:
stop();
var loader:Loader = new Loader();
var url:URLRequest = new URLRequest();
var newPageToLoad:MovieClip = new MovieClip();
addChild(newPageToLoad);
url.url = "startStage.swf";
loader.load(url);
newPageToLoad.addChild(laden);

function PageRemove(e.MouseEvent):void {
newPageToLoad.removeChildAt(0);
//newPageToLoad.removeChild(loader); // ALSO TESTED
}


Second Movie opens another

Code:
stop();
var loader:Loader = new Loader();
var url:URLRequest = new URLRequest();
var secondPageToLoad:MovieClip = new MovieClip();
addChild(secondPageToLoad);
url.url = "secondMovie.swf";
loader.load(url);
secondPageToLoad.addChild(loader);


Third Movie contains something

Accessing Child MC
Hi everyone,
Simple question...I think!
I'm creating a platform game, I want the ball to stay in the middle of the page while the background moves when the user presses the arrow keys, it looks like the ball is moving, but it's not.

To do this I have the ball in one movieclip and everything else (ground mc, enemies mcs, items mcs etc) in a container mc. So all I need to do is move the container left and right when the arrow keys are pressed, I can do that, no problem.

The problem occurs when I try to access the movieclips inside the container movieclip, for doing hit tests and such. The instance names come back as undefined.

If my container movieclip is named 'container_mc' and the ground movieclip is inside this named 'ground_mc' how would I change the below code to run the hittest?

stage.addEventListener(Event.ENTER_FRAME, hitCheck);
function hitCheck(event:Event):void
{
if (ball_mc.hitTestObject(ground_mc))
{
ball_mc.y = ground_mc.y;
}
}

Thanks a lot,

Ryan

[as3]adding Child
I'm failing to add 2 dynamic created movie clips "sb and contents" to dynamic created movie clip "scrollbox" any assistance would be greatly apreciated thanks sincerly sybershot

var scrollbox:MovieClip = new MovieClip();
this.scrollbox.x = 50;
this.scrollbox.y =50;
this.scrollbox.width = 340;
this.scrollbox.height =520;
this.scrollbox.addChild(sb);
this.scrollbox.addChild(contents);
this.addChild(scrollbox);

How To Know _y And _x Child On To The Root
Hey I'm working on something then suddenly I needed to know a child _y to the root
I tried
this._y which gave me its y reffered to parent.
I tried this._parnet._y which gave me the parent y o.O
please I need to know the answer -_-

Copyright 2005-08 www.BigResource.com, All rights reserved