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




Problem With Sub/child Pages..



Hi,I created a subpage under the link read more.. e.g.Read more --->>> SubpageBut the problem I am having is that when I click the link I can see the text I typed ealier but the informations from the same page exists as well, I tried to delete it but I wont let me do that, the layers are not locked or hidden either:confused: how do I delete the existing info and enter new informations to my liking? I got the source files if you want to see. Here are some images:



KirupaForum > Flash > Flash 8 (and earlier)
Posted on: 08-29-2008, 11:13 PM


View Complete Forum Thread with Replies

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

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

Printing Mulitple Pages Without Knowing The Actual Number Of Pages Before Hand
Does anybody know how to print multiple pages without knowing how many pages there are going to be?

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)

How Do I Link Swf Pages To Other Swf Pages
I just designed my first complete website using only Swish. However the site is over 5meg and takes forever to load. I realize that i have to design only one scene in a movie for the main page and then have it link to another single scene movie. I'm not sure how to do it. any help will be appreciated.

Thanks
Dave

Loading Pages Within Pages
I have a flash menu I made. It's pretty big (741 x 426). I have several buttons on the menu with some animation. Each time you click on one of the buttons, the menu and the button does an animation.

My problem is my main menu, has many sub menu's. I dont want to go to a new page each time they click on a link.

I want the sub menu's to be able to load any of the pages on my site at the bottom of the page clicking on the buttons. So I want the page to be blank at first except the flash menu, when you click a button it loads a page at the bottom, without having to go to a new page...

I cant do frames because of the large size of the menu and I want the menu to dissapear when you scroll since it's so big.

So what's the easiest way to load a html page within a page and what action would I use to make it happen? I just recently got a flash mp3 player that loads files using xml, is that possible to laod html files onto a page with xml?

Pages With In A Page? Sub Pages
I need some help,
On my flash site i have a a section called "photoshop" and i am almost running out of space to put pop up buttons that you click and it brings up my artwork
(see image)


I know its possible and that if I put some buttons that say something like next and back for browsing through pages I can have more than one page on the "photoshop" section, sort of like a sub page

I know I can do it I just don't know how so if anyone could help that would be greatly appreciated and thanks

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

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 -_-

Accessing All Child MCs
hi all,

If I have a movieClip say 'main_mc' within which there are a number of separate movieClips with random instance names e.g. "house", "dog", "muesli". Is there any way I can get AS to go into the main_mc and find everyone its child movieClips and dump them in an array or similar? Without having to reference each exact child movieClip?

Doesn't sound too challenging but I am pretty baffled on this one!

Thanks

XML Child In Flash
Hi.
I have in my XML 4 children and I want to read information from my secoud child. how can I do that. I know only how to read from my firstChild and lastChild.
TY

Parent And Child Swf
Hi,
Can anyone help please, I basically just want to call my main (parent) swf from the current clip (child) am in.
I just don't know how to write it, having a blank right now, it must be in the code line below, where i need to somehow add the name of the swf to the name of the button:
_root.but._visible = true;

Here is it in a bit more detail if needed:
I have 2 swfs, one is the main one that has buttons in it, when this button is clicked it loads a new semi transparent swf on top of it into an empty clip in my parent swf. When doing that I make the button in the parent swf invisible.
I have one close button which sits in the semi transparent swf on top, when this button is pressed it unloads itself and reveals the parent swf underneath again.
Now I want to add a line into my function that makes the button I previously made invisible, visible again so I can use it again, preferably when pressing the unload button of my semi transparent swf on top.

This is the parent swf clip function:
but.onRelease = function() {
trace(this._name+"._visible = false");
this._visible = false;
empty.loadMovie("top.swf");
};


This is top swf clip:
close_btn.onRelease = function() {
unloadMovie("");
trace(this._name+"._visible = true");
_root.but._visible = true;
};

Help With My Unborn Child
Third attempt to understand why my child doesn't come alive. I simplified my code further, and still nogo. I must be doing something terrible. Any AS3 guru out there see what?

I just need to put out a text from another package. If I addChild the text in the "main" package, it works. If I addChild in the instanced package... nothing. Why?

HEEEELPPP!!!
Sil
-----------

package { // main package, instanced in fla
import fl.controls.Button;
import flash.events.MouseEvent;
import flash.text.*
import flash.display.*;

public class ButtText extends MovieClip {
var tagText:TextField = new TextField();
var myButton:Button = new Button();

public function ButtText() {
myButton.label = "click me"
myButton.addEventListener(MouseEvent.CLICK, buttonClick);
addChild(myButton);
}

private function buttonClick(e:MouseEvent) {
var t:TextOut = new TextOut("Why does this not work?");
}
}
}

package { // this is instanced by main package
import flash.display.*;
import flash.text.*

public class TextOut extends MovieClip {
var tag:TextField = new TextField();

public function TextOut (str:String) {
trace("TextOut called, but no child born");
addChild(tag);
tag.text = str;
}
}
}

How Do You Pinpoint A Child In XML?
<restraunt>
<hamburger:location city="Riverside" region="CA" country="US" />

<hotdog:style meat="leftover pigmeat" toppings="onions" temperature="80" />

<fatburgers>
<hamburger:ingredients patty="Ball Park" sauce="ketchup" bread="white" />
<hamburger:ingredients patty="Farmer John" sauce="ketchup" bread="white" />
</fatburgers>

</restraunt>



How do I go about pinpointing the 2nd hamburger, inside <fatburgers>, where patty="Farmer John" ?

itemData = XML;

I tried using:
itemData.fatburgers.elements("hamburger")[1].attribute("patty");
and thats not working out too well =


itemData.fatburgers.attribute("patty") will return "Ball ParkFarmer John", which isnt going to be useful either.

Any suggestions?

Child() Question
Have a question about childs, if this is possible to solve this way.

Ok, lets say your making a game where your player sprite (or what you now use) will be moving around.
You then move over an item, if the player then would be moving over or under the item depends on where you place the items and players addChild towards each other of course.

But what if you want half of the item to be over the player and other half to be under the player when you move across it?

You then make the item into two sprites, one top- and one bottompart.
Problem solved.

But what if you want to have those two item-sprites in the same container.
Is there any way to have two different depths when they are added into one container so one part is under the player and the other is over?


Code:
import flash.display.Sprite;

var container:Sprite = new Sprite();

var player:Sprite = new Sprite();
player.graphics.beginFill(0x000000);
player.graphics.drawCircle(75, 100, 30);

var itemtop:Sprite = new Sprite();
itemtop.graphics.beginFill(0xFFCC00);
itemtop.graphics.drawRect(50, 50, 50, 50);

var itembottom:Sprite = new Sprite();
itembottom.graphics.beginFill(0x00CCFF);
itembottom.graphics.drawRect(50, 100, 50, 50);

container.addChild(itemtop);
container.addChild(itembottom);
addChild(container);

addChild(player);

Removing A Child
Hello, Maybe it was asked before, I searched but find anything.

It is simple, I have this code in Flash:

var rain:Sprite = new Sprite();
addChild(rain);

stage.addEventListener(MouseEvent.CLICK, raining);

function raining(event:MouseEvent):void {
var drop:Water = new Water();// from my library
drop.x = Math.random ()*stage.stageWidth;
drop.y = -Math.random()*25;
rain.addChild(drop);}


In the mc with the class name "Water", I made an animation and at the end of it, I want to remove the instance, so I wrote :

parent.removeChild(this) // parent is the sprite "rain"

It works but it gives me this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at Water/::frame4()[Water::frame4:3]


Thanks for your help

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