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




CurrentTarget.name As Movieclip



if I trace e.currentTarget.name, it traces btn0, btn1, btn2 etc. However that is a string. How can I convert it to see it as a movie clip?

I tried:

ActionScript Code:
var mc = e.currentTarget.name as MovieClip;

and no luck. What are my options?

This is currently working, but I dont like the fact of my instance name being a string:

ActionScript Code:
function btnClickHandler(e:Event):void{    var mc = e.currentTarget.name as MovieClip;    switch (mc)    {        case "btn0":            trace("prev");            break;        case "btn1":            trace("play");            break;        case "btn2":            trace("pause");            break;        case "btn3":            trace("next");            break;    }}



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 10-02-2008, 06:52 PM


View Complete Forum Thread with Replies

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

Which CurrentTarget?
Hi--

I've got a container holding several overlapping buttons. I want the button under the arrow to come to the front on MOUSE_OVER and then go back to its original position on MOUSE_OUT.

I can do this by creating listeners for every button, but that doesn't seem very efficient so I want to try to consolidate the code, but can't figure out how.

My code for the listener:


Code:

btnColumn.addEventListener(MouseEvent.MOUSE_OVER, bringFront);

btnColumn.addEventListener(MouseEvent.MOUSE_OUT, moveBack);



and


Code:

function bringFront(e:MouseEvent) {
navContainer.setChildIndex(e.currentTarget, navContainer.numChildren - 1);
}



the error I get when I hover a button:

Quote: 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display: DisplayObject.

I'm not sure what the error is telling me. Tracing the e.currentTarget I see [object btnColumn] so I know I'm close.

What am I missing?

Thanks!

:grimey

Event.currentTarget Help
Hello. I hope somebody can help.

I have 70 movieclips, all different, that all do the same thing on a mouse over. I was hoping I could use the currentTarget trick in a function to make them all use the same functions, but sadly it seems they don't want to.

Imagine you have 10 different movieclips, all at different points on the stage, all called different things. Can I make them all use the same function, all I want them to do is alpha to 10% on mouse over.

Or am I going to have to write 70 functions and 140 event listeners?

Sorry for my manic post, I'm stressing.

A.

E.currentTarget Problems
Hello.

Please ignore how messy this is, it's a test to see if something I learned from here a while ago can be used for an idea I have.

Basically, I get errors on e.currentTarget (and event.currentTarget) which I believe are because the if functions are running the TweenMax functions instead of those functions being driven by mouse events. If this is correct can I do this another way? I need to have a load of movie clips run one of two functions depending upon a current state, which I normally do with currentTarget but have not mixed it with conditionals.

All help would be most welcome.

A.


ActionScript Code:
package {
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.*;
    import gs.TweenMax;

    public class FP_waterTouch extends MovieClip
    {
        public function FP_waterTouch()
        {
            var toysVar = 0;
            var gardenVar = 0;
           
            toysButton.addEventListener(MouseEvent.MOUSE_DOWN, toysCond);
            gardensButton.addEventListener(MouseEvent.MOUSE_DOWN, gardenCond);
           
            function toysCond(e:Event):void {
                if(toysVar == 0){
                    sink();
                } else {float();
                    }
            }
           
            function gardenCond(e:Event):void {
                if(gardenVar == 0){
                    sink();
                } else {float();
                    }
            }
           
           
           
           
           
           
           
            function sink():void {
                TweenMax.to (event.currentTarget, 5, {blurFilter:{blurX:20, blurY:20}});
            }
           
            function float():void {
                TweenMax.to (event.currentTarget, 5, {blurFilter:{blurX:0, blurY:0}});
            }
        }
    }
}

Using Event.currentTarget With XML
It's been a long week and I'm brain dead so I'm hoping that this is something simple that one of you can help me with.

I am loading a series of thumnails through an XML file into a scrolling movieClip. I am able to get all of the images to load and scroll and even control their alpha value using event.currentTarget. What I am having a problem with is getting the corresponding XML attribute(@title) to load into a dynamic text field.

Here is a snippet of my XML file:

<thumbs>
<thumb img="http:url_1"
title="Title One" />
<thumb img="http:url_2"
title="Title Two" />
</thumbs>

The thumbnails are loaded into an XMLList called "_thumbs":
_thumbs = xmlData.thumb;
And I can load the "title" property into a text field manually using:
info_txt.text= _thumbs.@title[0];

What I want to have happen is when the user rolls over a thumbnail that thumnail's opacity changes and the "info_txt.text is updated to the thumbnail's corresponding "@title" attribute.

My MOUSE_OVER listener calls the following function:

function thumbOver(event:MouseEvent):void {
event.currentTarget.alpha = 1;

var desc:String = _thumbs.@title[1];
info_txt.text= desc;
}

The thumbnail alpha changes and the text field changes to the text that is defined by the first title attribute. What I need to figure out is how to use a variable instead of the "#". I'm assuming that I should be able to make use of event.currentTarget like I did to change the alpha of the thumbail movieClip. I've tried many incarnations of this without any luck. If anyone can point me in the right direction, I'd be very grateful. Thank you.





























Edited: 01/16/2009 at 11:29:48 AM by King Vitamin

Event.currentTarget ?
Hi guys,

Am I doing this properly:


Code:
var myTimer:Timer=new Timer(100,10);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE,timerComplete);
myTimer.start();

public function timerComplete(event:TimerEvent) : void {
// clean up the listener
event.currentTarget.removeEventListener(TimerEvent.TIMER_COMPLETE,timerComplete);
}
Should I be using currentTarget like that ?

Thanks.

Using Event.currentTarget With XML
It's been a long week and I'm brain dead so I'm hoping that this is something simple that one of you can help me with.

I am loading a series of thumnails through an XML file into a scrolling movieClip. I am able to get all of the images to load and scroll and even control their alpha value using event.currentTarget. What I am having a problem with is getting the corresponding XML attribute(@title) to load into a dynamic text field.

Here is a snippet of my XML file:


Code:
<thumbs>
<thumb img="http:url_1"
title="Title One" />
<thumb img="http:url_2"
title="Title Two" />
</thumbs>
The thumbnails are loaded into an XMLList called "_thumbs":
_thumbs = xmlData.thumb;
And I can load the "title" property into a text field manually using:
info_txt.text= _thumbs.@title[0];

What I want to have happen is when the user rolls over a thumbnail that thumnail's opacity changes and the "info_txt.text is updated to the thumbnail's corresponding "@title" attribute.

My MOUSE_OVER listener calls the following function:

ActionScript Code:
function thumbOver(event:MouseEvent):void {
event.currentTarget.alpha = 1;

var desc:String = _thumbs.@title;
info_txt.text=event.currentTarget(desc);
}



The thumbnail alpha changes and the text field changes to the text that is defined by the first title attribute. What I need to figure out is how to use a variable instead of the "#". I'm assuming that I should be able to make use of event.currentTarget like I did to change the alpha of the thumbail movieClip. I've tried many incarnations of this without any luck. If anyone can point me in the right direction, I'd be very grateful. Thank you.

Using Event.currentTarget With XML
It's been a long week and I'm brain dead so I'm hoping that this is something simple that one of you can help me with.

I am loading a series of thumnails through an XML file into a scrolling movieClip. I am able to get all of the images to load and scroll and even control their alpha value using event.currentTarget. What I am having a problem with is getting the corresponding XML attribute(@title) to load into a dynamic text field.

Here is a snippet of my XML file:

<thumbs>
<thumb img="http:url_1"
title="Title One" />
<thumb img="http:url_2"
title="Title Two" />
</thumbs>

The thumbnails are loaded into an XMLList called "_thumbs":
_thumbs = xmlData.thumb;
And I can load the "title" property into a text field manually using:
info_txt.text= _thumbs.@title[0];

What I want to have happen is when the user rolls over a thumbnail that thumnail's opacity changes and the "info_txt.text is updated to the thumbnail's corresponding "@title" attribute.

My MOUSE_OVER listener calls the following function:

function thumbOver(event:MouseEvent):void {
event.currentTarget.alpha = 1;

var desc:String = _thumbs.@title;
info_txt.text=event.currentTarget(desc);
}

The thumbnail alpha changes and the text field changes to the text that is defined by the first title attribute. What I need to figure out is how to use a variable instead of the "#". I'm assuming that I should be able to make use of event.currentTarget like I did to change the alpha of the thumbail movieClip. I've tried many incarnations of this without any luck. If anyone can point me in the right direction, I'd be very grateful. Thank you.

Help CurrentTarget In PV3d
hey i made a code that add childern of planes with "for" and i add an event
but it's only applyed to the last child
what to do ?

Code:

import flash.display.Sprite;
   import flash.events.MouseEvent;
   
   import org.papervision3d.cameras.Camera3D;
   import org.papervision3d.materials.ColorMaterial;
   import org.papervision3d.objects.Plane;
   import org.papervision3d.scenes.MovieScene3D;

      
   // ExamplePicking extends Sprite
   {
       var container :Sprite;
       var scene :MovieScene3D;
       var camera :Camera3D;
       var plane :Plane;
      
      function ExamplePicking()
      {
         
            container = new Sprite;
         container.x = Math.random () * 100+ (stage.width );
         container.y = Math.random () * 100 +(stage.height );
         addChild( container );

         
         scene = new MovieScene3D( container );
         
         camera = new Camera3D();
         camera.z = -500;
         camera.zoom = 5;

         // create a plane
         
         plane = new Plane( new ColorMaterial(0xFF0000), 128, 128, 1, 1);
         plane.material.doubleSided = true;
         plane.rotationX = 35;
         plane.rotationZ = 35;

         // register the plane
         
         scene.addChild( plane ) ;
         
         
         
         // register events for the plane
         plane.container.addEventListener( MouseEvent.MOUSE_OVER, onMouseOver );
         plane.container.addEventListener( MouseEvent.MOUSE_OUT, onMouseOut );

         // render the scene once
         scene.renderCamera( camera );
      }
      
       function onMouseOver( event: MouseEvent ): void
      {
            plane.material.fillColor = 0xFFF000;
            plane.scale = 1.5
            plane.rotationX =Math.random() * 100;
   plane.x = Math.random() * 100;
   plane.y = Math.random() * 100;
            // render the scene once
            scene.renderCamera( camera );
      }

       function onMouseOut( event: MouseEvent ): void
      {
            plane.material.fillColor = 0xFF0000;
            plane.scale = 1;

            // render the scene once
            scene.renderCamera( camera );
      }

   }
    for (var i:uint=1; i<=5; i++) {
       ExamplePicking();
    }

Event.currentTarget Problem
Hi


I have problem with
ActionScript Code:
event.currentTarget
. My target is a Movie clip and i would like to ask how can i check the y property of my
ActionScript Code:
event.currentTarget
. Someting like
ActionScript Code:
event.currentTarget.y
but this does not work. How can i check for that propery for
ActionScript Code:
event.currentTarget


tnx

Luka

Return Event.currentTarget. Name
hi, i'm trying to get the target name of a mouse event and trace it in another function. when i try to trace the name within the frameForward function, it succeeds, but it fails to do the same in the checkSwatches function. any ideas? thank you.










Attach Code

public function frameForward(event:MouseEvent):String
{
_mainFrame ++;
trace(_mainFrame);
gotoAndStop(_mainFrame);
checkSwatches();
return (event.currentTarget.name);
}

public function checkSwatches():void
{

if(_mainFrame == 2)
{
trace(frameForward);
}

}


/*
---------------

should trace:

2
ileri


actually traces:

2
function Function() {}

*/

CurrentTarget.name Doesn't Give Instance Name...
I'm dynamically creating 5 buttons named consecutively but1...but5.

On click, I want to pull the number value from the button's name, and navigate to the associated section. (e.g. but1 = section1...but5 = section5)

However, the code below does not return the dynamic instance name, it returns something like instance19, instance21, instance23, etc...

Can anyone let me know what I'm doing wrong?


Code:
for (i = 1; i<=5; i++) {
this["but"+i] = new clearBut();
addChild(this["but"+i]);
this["but"+i].x = this["txt"+i].x;
this["but"+i].addEventListener(MouseEvent.CLICK, onMouseDownhandler);
}
function onMouseDownhandler (event:MouseEvent):void {
trace("instance name: " + event.currentTarget.name);
}

CurrentTarget.name Doesn't Give Instance Name...
I'm dynamically creating 5 buttons named consecutively but1...but5.

On click, I want to pull the number value from the button's name, and navigate to the associated section. (e.g. but1 = section1...but5 = section5)

However, the code below does not return the dynamic instance name, it returns something like instance19, instance21, instance23, etc...

Can anyone let me know what I'm doing wrong?


Code:
for (i = 1; i<=5; i++) {
this["but"+i] = new clearBut();
addChild(this["but"+i]);
this["but"+i].x = this["txt"+i].x;
this["but"+i].addEventListener(MouseEvent.CLICK, onMouseDownhandler);
}
function onMouseDownhandler (event:MouseEvent):void {
trace("instance name: " + event.currentTarget.name);
}

Pass Event.currentTarget On To Another ENTER_FRAME Function
i've got a function associated with a mouse event listener with one clip which sets the x and y of another clip (here it's 'myClip') as well as specifying the ENTER_FRAME function for that clip:


Code:
function mcOver(event:MouseEvent):void{
myClip.x = event.currentTarget.x;
myClip.y = event.currentTarget.y;
myClip.addEventListener(Event.ENTER_FRAME, moveClip);
}
then i have a function that i want to use for the ENTER_FRAME function which will cause the second clip ('myClip' again) to continue to follow the clip targeted with the mcOver function above:


Code:
function moveClip(){
myClip.x = ??? // need to target the event.currentTarget of the 'mcOver' function above
myClip.y = ??? // ditto.
}
I'm not sure how to target the currentTarget of that first mouse event within the enter frame function... I know there was a delegate method/class in AS2... how can i do this in AS3???

thanks for any help!

SetChildIndex --> Event.currentTarget (simple Problem)
Hi guys,

I have a problem. I'm still learning the basics of Flash, so this will seem pretty trivial to most of you, but I would really appreciate some help with this.

I tried using setChildIndex on event.currentTarget, but it doesn't seem to work. I can't decipher the error that pops up.

This is the entire code:

Code:
for(var i:int=0;i<10;i++){ //Sphere worm
var Circle:BlueSphere = new BlueSphere();
Circle.x = 40*i+50;
Circle.y = 200;
Circle.scaleX = i*.4;
Circle.scaleY = i*.4;
Circle.buttonMode = true;
Circle.pos = i;
Circle.addEventListener(MouseEvent.CLICK,clickCircle);
function clickCircle(event:MouseEvent){
event.currentTarget.y += 10;
setChildIndex(event.currentTarget,0);
trace("You clicked " + event.currentTarget + " " + event.currentTarget.pos + "!");
}
addChild(Circle);
}
This is the error::

Code:
1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.
It refers to this:

Code:
setChildIndex(event.currentTarget,0);
Thanks for reading this. Any help would be greatly appreciated!

Associating Event.currentTarget Back To It's Class Instance?
I'm not sure I even labelled this correctly, but here's my problem.

I have five instances of object "Category", of which each in turn create instances of object "Tab".

the 5 instances of category, when created, are pushed to an array, which is sitting inside a class named "ButtonGroup" - ButtonGroup exists so I can addEventListeners to the Tabs from one central place which allows me to modify all the tabs in one place when a button gets pressed instead of setting up Broadcasters for every tab instance.

The event listener has been put upon Category Object>Tab Object> tabElement:MovieClip, ala


Code:
theTab.tab.tabElement.addEventListener(MouseEvent.MOUSE_UP, tabClicked);
Withing tabClicked function, I have:


Code:
selectedTab = event.currentTarget;
Hence, selectedTab is the tab I just clicked on. However, herein lies my problem. If I try to discover that tabs "Tab" instance, I can't, because the event.currentTarget.parent would be the stage...not the Tab object instance it is associated with!

How can I find what Tab instance it is associated with??

Here my class files - if they help.

HomeFlash.as

Code:
package {

import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;

public class HomeFlash extends MovieClip {

//public var category:Array = new Array();
public var category:Array;
public var buttonGroup:ButtonGroup;

//Constructor
public function HomeFlash() {

trace("im in your constructor, tracing all your code");

buttonGroup = new ButtonGroup();
//category = buttonGroup.getCategories();

//add the all the buttons into the array.
addContents();

//Because "Hosting" is just one word, I need to move tab one into middle
//Ideally, I should be checking all tabs for text length and positioning them appropriately
tab1.button.tabText.y = 10;
}

//Adds each orb into the array
public function addContent(cItem:Category):void {
//add to teh animation handler
//category.push(cItem);
buttonGroup.addCategory(cItem);
}

//Declare all the information to go into the array
private function addContents():void {
addContent(new Category(tab1,"HOSTING", new hosting()));
addContent(new Category(tab2,"WEB" + "
" + "DESIGN", new web_design()));
addContent(new Category(tab3,"WEB" + "
" + "DEVELOPMENT", new web_dev()));
addContent(new Category(tab4,"VOIP" + "
" + "SERVICES", new voip_services()));
addContent(new Category(tab5,"NETWORK" + "
" + "SERVICES", new network_services()));
}

}

}
Category.as


Code:
package {
/*Importing neccesary classes*/
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.utils.Timer;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.Event;
import flash.events.MouseEvent;

/* Orb Class*/
public class Category {

private var _tabElement:theTab;

private var _tabLabel:String;

private var _tabIcon:MovieClip;

private var _tab:Tab;


//Costructor
public function Category(tabElement:theTab, tabLabel:String, tabIcon:MovieClip) {

this._tabElement = tabElement;
this._tabLabel = tabLabel;
this._tabIcon = tabIcon;

//Creates a new instance of tab
_tab = new Tab(_tabElement, _tabLabel, _tabIcon);

}

//Getter functions
//Allow these functions to be called outside of this class but not be written over.
public function get tabElement():MovieClip { return _tabElement; }
public function get tabLabel():String { return _tabLabel; }
public function get tabIcon():MovieClip { return _tabIcon; }
public function get tab():Tab { return _tab; }
}
}
Tab.as


Code:
package {
/*Importing neccesary classes*/
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.utils.Timer;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.Event;
import flash.events.MouseEvent;

/* Tab Class*/
public class Tab {

private var _tabElement:MovieClip;
private var tabLabel:String;
private var tabIcon:MovieClip;

private var tabActive:Boolean = false;

public var tabClickTime:Number = 50;
public var tabClickTimer:Timer;

public var clip:MovieClip;

public var category:Category;

//Costructor
public function Tab(tabElement:MovieClip, tabLabel:String, tabIcon:MovieClip) {


//Just store some variables
this._tabElement = tabElement;
this.tabLabel = tabLabel;
this.tabIcon = tabIcon;
this.clip = this._tabElement;
//Call function to add content onto each tab
populateTab(this.tabElement, this.tabLabel, this.tabIcon);

}

public function populateTab(_tabElement:MovieClip, tabLabel:String, tabIcon:MovieClip){

//Set the text on each tab
_tabElement.button.tabText.text = tabLabel;

//Add the icon onto each tab
_tabElement.button.addChild(tabIcon);

//Setting position and transparency of the icon on each tab
tabIcon.alpha = 0.4;
tabIcon.x = 8;
tabIcon.y = (39 - tabIcon.height)/2;

}
public function turnOff(){
tabElement.onTab.visible = false;
}
public function turnOn(){
tabElement.onTab.visible = true;
}
public function get tabElement():MovieClip { return _tabElement; }

}
}
And finally, ButtonGroup.as


Code:
package {
/*Importing neccesary classes*/
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.utils.Timer;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.Event;
import flash.events.MouseEvent;

public class ButtonGroup {

public var tabs:Array = new Array();
public var selectedTab;

public function ButtonGroup() {

}

public function addCategory(theTab:Category):void {
tabs.push(theTab.tab);
//trace(tab);
trace(theTab.tab);
theTab.tab.tabElement.addEventListener(MouseEvent.MOUSE_UP, tabClicked);
}

public function tabClicked(ev:MouseEvent):void {
//loop through tabs:Array and turn all tabs "off"
for each (var tab:Tab in tabs) {
tab.turnOff(); //turn off function?? tab.visible = false;?
}
//set the newly selected tab
selectedTab = ev.currentTarget; //tab that triggered event
//turn it on, 'selected' references the tab that was just pressed
//selectedTab.turnOn(); //dont know what your function is? tab.visible = true;?
}
public function get getCategories():Array { return tabs; }

}
}

How To Send "everything Else That's Not The CurrentTarget" To A Labeled Frame
Olá!
I'm looking for a simple solution, or at least some light over my duh-ness here.

What I need is that before the currentTarget button of this dynamic menu goes to the "Selected" frame, to reset all the buttons and make them all go to the "notSelected" frame. So the only one with the "Selected" appearance is the currentTarget.

My idea was to just send the var to the frame. But it doesn't work. All the menu numbers stay selected as I click on them.

Any help is greatly appreciated, I'm just an Illustrator trying to program
Here's the code:

// Construct the menu and addEventListener:
private function init_ImageMenu(a:int,imageItems:int,myXML:XML):voi d {
var numberMenuPosition:uint;
for (var e:uint = 0; e < imageItems; e++) {
var numberBtn:MovieClip = new btn_numero(); // create new instance of button
numberBtn.x = numberMenuPosition; // set position for the button
numContainer.addChild(numberBtn); // add button to the container on the stage
numberBtn.numero_texto.num_txt.text = [e+1]; // giving dynamic names to buttons
numberMenuPosition += 20; // positioning the rest of the buttons

numberBtn.addEventListener(MouseEvent.CLICK, openImage(a,e,myXML,numberBtn)); // the on click event
}
}

private function openImage(a:int,e:int,myXML:XML,numberBtn:MovieCli p):Function {
var discoverImg:Function = function(evt:MouseEvent):void {

numberBtn.gotoAndPlay("notSelected");
// I'm trying to reset all the buttons here by sending the var to a labeled frame
// where the buttons appear deselected. This doesn't work as is.... so I'm guessing
// that I can't use this var here, or that I need something else...

evt.currentTarget.gotoAndPlay("Selected");
// This works fine. But unless I deactivate all other buttons first I'll get all buttons
// in the Selected state one by one as I click on them.

(...) // rest of the function is not relevant

I Don't Understand The Keywords: This, Event.target, Event.currentTarget
I am almost a complete beginner to Actionscript 3.0.
I've been looking at tutorials and I now understand most of the basic principles and methods of this programing language (creating basic functions ect..).

However I do not understand the following keywords.

1. this
2. event.target
3. event.currentTarget

What do these words refer to?
How are they different from each-other?
When must i use them?

On HitTest To A Movieclip(a) By Movieclip(b)i Want To Attach Another Movieclip(c) To
on hitTest to a movieclip(a) by movieclip(b)i want to attach another movieclip(c) to movieclip(b)which is in the stage,so how to do it??
can anybody help on this???

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

? Resize Stage To Dynamically Match External Movieclip Loaded Into Empty Movieclip
Hi all,
Does anyone know how I can resize the stage to match the size of an external graphic/movieclip which is loaded into an empty movieclip,
thanks

#1009 Error Movieclip Inside Movieclip Changing The Alpha Property
Problem:
I'm getting this "TypeError: Error #1009: Cannot access a property or method of a null object reference."
What's happening in the flash file is that I've got a movieclip inside a movieclip and when you roll over one of the movieclips the alpha setting for the movieclip inside the initial movieclip is set to 1, then it transitions out back to 0 over a period of time.

var myTween:Tween = new Tween(event.target.parent.ripple_mc, "alpha", Strong.easeOut, 0, 100, 24, false);

It seems to be random but eventually after rolling over the several movieclips on the stage the error comes up. Sometimes the alpha setting stops working and will continue to be visible even though it should have stopped and be invisible after 24 frames.

Would love some help on this.

Cheers

#1009 Error Movieclip Inside Movieclip Changing The Alpha Property
Problem:
I'm getting this "TypeError: Error #1009: Cannot access a property or method of a null object reference."
What's happening in the flash file is that I've got a movieclip inside a movieclip and when you roll over one of the movieclips the alpha setting for the movieclip inside the initial movieclip is set to 1, then it transitions out back to 0 over a period of time.

var myTween:Tween = new Tween(event.target.parent.ripple_mc, "alpha", Strong.easeOut, 0, 100, 24, false);

It seems to be random but eventually after rolling over the several movieclips on the stage the error comes up. Sometimes the alpha setting stops working and will continue to be visible even though it should have stopped and be invisible after 24 frames.

Would love some help on this.

Cheers,

Sarge

Control A Nested MovieClip From A Button Component Inside A Seperate MovieClip.
I am a beginner in using Flash and Action Scripting.

This is the Scenerio:

I want to control a movieclip that is inside of another movie clip.
I control it from a button component that is inside of a seperate movie clip.

test = button component instance name
test1 = function
test2 = Movieclip instance name
test3 = Movieclip instance name
testbutton = movieclip name where button component is located

I am able to control a movieclip on the main timeline with the following AS 3.0:

test.addEventListener (MouseEvent.CLICK, test1);
function test1(event:MouseEvent):void
{
event.target.root.test2.gotoAndPlay(2);
}

I want to control a movieclip inside MovieClip1.

I tried this:

test.addEventListener (MouseEvent.CLICK, test1);
function test1(event:MouseEvent):void
{
event.target.root.test2.test3.gotoAndPlay(2);
}

The movie loaded fine when I tested but got this error when I pressed the button:

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

Please help!!!!!!!!!

MovieClip.onRelease = MovieCLip.Protoype Function Fails To Execute Properly
Dear all,

I created a simpe function:

MovieClip.prototype.hiMe = function(me, theRest)
{
//declare the format colors white and grey
formatMe = new TextFormat();
formatMe.color = Colors[0];
formatMe.font = "Adventure Subtitles";

formatTheRest = new TextFormat();
formatTheRest.color = Colors[1];
formatTheRest.font = "Adventure Subtitles";

// assign grey to theRest
for (i =0 ; i < theRest.length; i++)
{
theRest[i].tfield.setTextFormat(formatTheRest);
}
// make the me white
me.tfield.setTextFormat(formatMe);

}

when I call it (bar[0] is an array of objects)
bar[0].invar.onRelease = hiMe(bar[0],bar);

it executes on load regardless of the onRelease eventHandler and the ownards it does not execute when exciting the event.

does somebody know why this may be?

Cheers

DDT

MovieClip.onRelease = MovieCLip.Protoype Function Fails To Execute Properly
Dear all,

I created a simpe function:

MovieClip.prototype.hiMe = function(me, theRest)
{
//declare the format colors white and grey
formatMe = new TextFormat();
formatMe.color = Colors[0];
formatMe.font = "Adventure Subtitles";

formatTheRest = new TextFormat();
formatTheRest.color = Colors[1];
formatTheRest.font = "Adventure Subtitles";

// assign grey to theRest
for (i =0 ; i < theRest.length; i++)
{
theRest[i].tfield.setTextFormat(formatTheRest);
}
// make the me white
me.tfield.setTextFormat(formatMe);

}

when I call it (bar[0] is an array of objects)
bar[0].invar.onRelease = hiMe(bar[0],bar);

it executes on load regardless of the onRelease eventHandler and the ownards it does not execute when exciting the event.

does somebody know why this may be?

Cheers

DDT

#1009 Error Movieclip Inside Movieclip Changing The Alpha Property
Problem:
I'm getting this "TypeError: Error #1009: Cannot access a property or method of a null object reference."
What's happening in the flash file is that I've got a movieclip inside a movieclip and when you roll over one of the movieclips the alpha setting for the movieclip inside the initial movieclip is set to 1, then it transitions out back to 0 over a period of time.

var myTween:Tween = new Tween(event.target.parent.ripple_mc, "alpha", Strong.easeOut, 0, 100, 24, false);

It seems to be random but eventually after rolling over the several movieclips on the stage the error comes up. Sometimes the alpha setting stops working and will continue to be visible even though it should have stopped and be invisible after 24 frames.

Would love some help on this.

Cheers,

User Input Creates MovieClip Made Of MovieClip Symbols
Hello. I need some help either with my situation or with the search terms I'm using to try to find an answer.

I am using Flash MX Pro 2004.
I have drawn letters A-Z in Flash in two different styles (for example one that is furry and another that looks like metal). I would like users to select a text style (furry or metal) and enter text via text input field. When they have pressed an Enter button I would like the word to appear made up of the drawn symbols that I created.

I don't want to make an actual font. Any ideas on search terms to find the sort of thing I am looking for? Here's some that I've tried already:

convert text to symbols -- I get tons of results talking about putting textfields in symbols.

user input to symbols -- almost same results as above

custom fonts using symbols -- I get results talking about how to embed fonts and making text bold, italic, etc. Also not what I'm after.

All help is appreciated. Thanks in advance.

Scott

Receive Full Path To A MovieClip, Return A MovieClip Reference.
Hi, I got this function...

Code:
Function getMCPath(path:String)
{
var MC:MovieClip;
MC = eval(path)
return MC;
}

If I send "_level0" this will return _level0, but if I send "_level0.myMC" this will return undefined.

what should I do in order to get full path to _level0.myMC

Thanks in Advance,
DMZ

How To Hide My Current Movieclip And Display 2nd Dynamically Created Movieclip?
I have a movieclip in which there is an image create this movieclip dynamically by reading the oath of the image from file and play an effect. its working fine, now i want to hide this MC after its effect is ended and then dynamically want to create the other MC and similarly so on. how to do that. my code is as below:

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);

lv.load("data.txt");
var my_lv:LoadVars = new LoadVars();
my_lv.load("data.txt");
my_lv.onLoad = function(success)
{
if (success)
{
if(this.pic1!=undefined)
{
var ImgMc:MovieClip = createEmptyMovieClip("ImgMc", getNextHighestDepth());
_root.mcLoader.loadClip(this.pic1,_root.ImgMc);
//Some effect on ImgMc

//how to hide the ImgMc whe nits effect is played and then load another image in a movieclip and so on
}
}
}

Load Movieclip From Libary Into Another Blank Movieclip On Stage (URGENT PLEASE)
hi all i just need to know how to load a movieclip into a blank movie clip all in the same movie?! please help many regards peter thanks in advance!

Movieclip Rollover Effect Disables Internal Movieclip Buttons
Is it possible to have a movieclip rollover effect with another movieclip inside of it that is able to be clicked and do what it's scripted to do?

Let me try to get specific...


Movieclip 1 -- Has www.kirupa.com/developer/mx2004/button_effect.htm applied

Inside of Movieclip 1 --> Buttons that appear visible when you rollover the menu (it comes out of eases into view)

These buttons inside are not being allowed to be pushed because from what I can gather, the complex rollover is not allowing anything to be activated except the rollover effect.

So here's a diagram:

Rollover Movieclip 1 --> Eases it's bottom part up revealing 4 buttons --> These buttons when clicked are supposed to do an action --> Buttons cannot be activated for some unknown reason.

Can anyone help me out? I'm out of ideas after working on this for the past hour or so. If you need any extra info or materials, let me know; I'm sitting right here working on this problem haha.

-Indecisive

Problem With OnRelease For MovieClip Inside Draggable MovieClip [Flash Pro 8]
I have a movie clip, circle_mc, and in it is embed another movie clip, point_mc. I made the circle draggable with this:


Code:
circle_mc.onPress = function() {
startDrag(this);
};
circle_mc.onRelease = function() {
stopDrag();
};
and that part works fine.

I also want to be able to click on point_mc which is within the circle_mc movie clip. So, I added this:


Code:
circle_mc.point_mc.onRelease = function() {
trace("click was successful");
}
This does not work, and I'm pretty sure it is BECAUSE its parent clip is draggable and therefore has its own onRelease function. (If I comment-out the drag code, then the other code works as intended.)

Is there any way to do this or am I out of luck?

How To Load Image Into Movieclip Inside Movieclip That Is Dynamically Created?
Hello Kirupa Cats!

I am building a menu from an XML file, and I'm cool with cyclying thru the xml data to create menu items.

For every menu item in my XML file, I'm using attachMovie to insert a movie clip called menuitem from my library into a movieclip called menuholder. This works no problem, my menuholder movieclip is poplulated with as many menuitem movieclips from the library as designated by the xml data.

However, inside the library movieclip called menuitem, I have another movieclip on its stage, called mc_menuImage. I want to load an image into that movieclip, and I'm taking the URL for the image from the XML data.

My problem is I can't seem to figure out how to fully identify the movieclip mc_menuImage to load the image. It may have something to do with the fact that the library movieclip is being loaded dynamically, but the movieclip inside the library movieclip exisits pysically on the stage. I don't know...here's the code I'm working with:

THE CODE:

var xmlMenu:String = "menu.xml";
menuholder = createEmptyMovieClip("menuholder", -1);

var xmlMenuData:XML = new XML();
xmlMenuData.ignoreWhite = true;
xmlMenuData.load( xmlMenu );
xmlMenuData.onLoad = function(loaded) {
if (loaded) {
var mImage:Array = new Array();
var mRootNode = this.firstChild.childNodes;
totalMenuItems = mRootNode.length;

// fill array
for (var i = 0; i<totalMenuItems; i++) {
mImage.push(mRootNode[i].attributes.menuImage);
}
}

//make the menu
for (var i = 0; i<totalMenuItems; i++) {
var menuitem = menuholder.attachMovie("menuitem", "menu"+i, i);
menuitem.id = i;

/* now here I thought I could just do this: */
menuitem.mc_menuImage.loadMovie(mImage[i]);
/* but that doesn't work... */

};


When I trace menuitem I get this: _level0.menuholder.menu0, _level0.menuholder.menu1, etc, so I figured the syntax menuitem.mc_menuImage would identify the movieclip inside menuitem, but to no avail. Maybe it has something to do with levels, I'm not sure...

So I don't know, any suggestions? Thanks so much!!!

How To Scale The Movieclip Without Transform The Text Inside That Movieclip Uisng As
hi
how to scale the movieclip without transform the text inside that movieclip uisng actionscript


thanks in Advance

Wait Till Movieclip Gets To Particular Frame Then Play Another Section Of Movieclip
Hi,

I'm trying to reconstruct http://www.kswissfreerunning.com/AU/ with movies of my own.

Basically I have an array that contains the letters the user enters and I have the movie in a separate moviecilps with labels representing the letters.

I have a (what I think) logical set of code here to run through each letter in the user enters:

Code:
for(var k=0; k < letterArray.length; k++){
movie_mc.gotoAndPlay(letterArray[k]);
}
The problem is that it will only play the last letter the user enters. How am I able to make my flash wait till it gets to the end of a section of the movieclip, then play the next one, without it rushing to go straight to the last letter.

My pseudocode looks like this:

For the length of the array
play the next letter
when that letter movie gets to the end
play the next letter

Thanks in advance.

Loading A Movieclip On The Main Stage From A Button Within A Movieclip - Big Headache
Hi there,

i am trying to put together a portfolio site, which uses a 'floating' panel with buttons on it. In order for it to move around it has to be a movieclip. So all the buttons are stored within a single movieclip, which is giving me a headache because i want those buttons to load other movieclips from my library onto the main stage (as like a popup window within the flash)

Its all slightly confusing. i have tried using this code based within the movieclip where my button is based:

button_play.buttonMode = true;
button_play.addEventListener(MouseEvent.CLICK, OpenBox);
function OpenBox (e:MouseEvent):void{
this.addChild(new mc_box());
}


button play is within a movieclip called mcTweenMe2 (which is on the main timeline) and i want the movieclip to be loaded on the main timeline (not within in the movieclip where the button 'button_play' is based) mc_box is the movieclip i wish to load on the main timeline (in the centre) with the ability to close it also!

Bit of a headache, please help me someone i have run out of sites to look for answers!

PS: does anyone know why stop (); wont stop my timeline playing like it used to in AS2? beacause another option for making my site work is making this button target labeled frames in the main timeline, however stop (); don't seem to work now!

Thanks!

[HELP] DuplicateMovie / AttachMovie Movieclip Located Inside A MovieClip To Root
As title.

Example:
I have a movieclip(innerClip) inside a movieclip(mainclip).
Is there anyway if I duplicate / attach my innerclip to my root stage? So I can access it like _root.innerclip2, instead of normal duplication that make to _root.mainclip.innerclip2

Thanks in advance.

Control/sinc Video Movieclip And Text Movieclip
Here´s a tricky one:

I need to sincronize/control a movieclip with texts and a swf (a video) that I loaded, both on the main timeline.

I have a swf (a video) that I loaded in a movieclip into my flash file and a movieclip with texts in it. Both are on the main timeline. Trouble is if the movie is playing and I want to pause it, for example, the swf video pauses but the texts movieclip keeps on playing. If I rewind it, the swf video goes back, the text movieclip still keeps on going. You get the picture.

For control I´m using a camtasia component - camtasia is the software I made the video with. I´m not putting the movie straight into the flash file because the swf made with camtasia turns to be way smaller that if I just loaded into flash.

I´ve attached a txt file with the controller script. Also i´ve put for download the flash file i´m talking about (flashsinc.zip) so you can better understand what I mean. Here´s the adress:

http://www.altoqi.com.br/temp/flashsinc.zip

Thanks a lot.

Trapping Mouse Events For A Movieclip Inside A Movieclip
Hi

Im having a few problems with my events for some movieclips. What I have is an AS2 class which creates a blank movieclip as a holder for submenu movieclips. This blank movieclip must trap its onRollOut event so that it can fade out the menus. The submenu movieclips which are then attached to the holder clip must trap their own mouse events which are defined in another AS2 class. The only trouble is they are not trapped.

I have seen a couple of other posts on the subject but got no clues from them. I was just wondering if what Im trying to do is possible or if Im fighting a loosing battle.

Any help would be much appreciated.
Thanks in advance
Dan

Mouse Event Triggers For Movieclip Inside Movieclip (can It Be Done?)
'canvas' is a large movieclip I am using to put other movieclips 'in' so I can move around and zoom everything at once. Like a coffee table with pictures on it.

I am loading up two images below with variables named map01 and map02. They overlap.


Code:
var map01:MovieClip = canvas.createEmptyMovieClip("map01", canvas.getNextHighestDepth());
map01.loadMovie("http://imagelocation1.jpg");
map01._x=-1000;
map01._y=39;
var map02:MovieClip = canvas.createEmptyMovieClip("map02", canvas.getNextHighestDepth());
map02.loadMovie("http://imagelocation2.jpg");
map02._x=-1000;
map02._y=130;

map01.onRelease = function () {
this.swapDepths(map02);
}
I would like to be able to click one of the images inside canvas and have it jump to the top. In this case, just a simple swap with map02 would be fine, I can manage the depths.

I have put a breakpoint right on the swapdepths line and debugged, and the function never gets called. Probably because it is the onrelease is for 'canvas', not any of the sibling movieclips that flash is looking for.

'canvas' has an onRelease that triggers a stopdrag and a onpress that triggers a startdrag. Removing these two triggers still does not allow any triggers for map01 or map02 to trigger though.

Any suggestions?

Is there some way to setup some logic on a canvas.onRelease function that can easily check to see if the clicked region is on an movieclip inside the canvas?

[F8] MovieClip._currentframelabel Would Be Nice Or, MovieClip.gotoAndStop(_nextlabel)
Ok, so, to my knowledge, up to AS 2.0, there is still no way to return the value of a frame label, correct? Or better yet, why haven't "they" added a "_nextFrameLabel();" or "_prevFrameLabel();" method!?!? Flash has the ability to move the playhead 1 frame at a time just by using the _nextFrame(); and the _prevFrame(); soooooooooo why can't it have the same function, just with frame labels!!!?! e.g. I have a Forward button that would have:


Code:
on(release){
_nextFrameLabel();
}


This would take me to the next frame which has a label, regardless of what it's called... the label could be "c", or "gibblets", or "blahblahblah"...

Or, if there was a property similar to MovieClip._currentframe, which, instead of returning an integer, it would return a string value if the playhead is on a labeled frame! e.g. MovieClip._currentframelabel would return "gibblets" instead of 145.

Basically, if I have a long linear animation with a bunch of manual stops and pauses put into the timeline, I want to avoid having to put a new keyframe in for the "Step Forward" and "Step Backward" buttons every time the playhead reaches a new stop/frame label. Has anyone figured an easier way to do this?

Example:
I have a timeline with 4 labeled frames, A, B, C, D... frame 1 is labeled "A", frame 50 is labeled "B", etc.
I have a layer with a Back and a Next button. So, on frame 50 (labeled "B"), the code for those buttons would be:


Code:
// Back Button
on(release){
gotoAndStop("A");
}

// Forward Button
on(release){
gotoAndStop("C");
}


In order to change that code (e.g. when the playhead gets to the "C" frame) I need to add a keyframe on the button layer... which is fine for this example where I only have 4 sections to deal with... but it's a pain when I have frames "A" through "W" or much more.

Is there a way to dynamically know what the next frame label is with ActionScript without implicitly definining it, thereby removing the necessity for numerous keyframes/code changes for the Back and Next Buttons???

i.e. instead of gotoAndStop("C")... I want gotoAndStop(_nextFrameLabel);

[CS3] Referencing A Movieclip Inside A Movieclip From A Class File
Hello All,

I'm trying to access a movieclip inside another movie clip from a class file that is not attached to either movieclip. For instance, I'm checking hitTests for the avatar the player uses on the game, there are two enemy movieclips. Inside each enemy movieclip is another movie clip that serves as a bounding box (specifically around the mouth of the enemy so it can eat the player). Here is what I have so far that isnt working:


Code:
if (_root['otter']['obbox'].hitTest(this) && touch == false) {
trace("Otter touched Urchin");
gotoAndPlay("hit");
_root['otter'].gotoAndPlay("eat");
touch = true;
}
The class file is for the avatar. On the stage is the otter mc and inside the otter mc is another mc called obbox which is what I'm trying to hitTest against. Needless to say, it doesn't hitTest or trace or play the animation. Is there a way to reference a nested mc? Thanks in advance.

Terror.

Determining The Name Of A Dynamically Loaded Movieclip From A Child Movieclip
I had posted earlier on this topic, but I don't think I was clear enough in my title, or description.

Here's a more detailed explaination of what I I'm trying to do:

I have a .swf file that dynamically generates container movieclips (giving them dynamically generated instance names) and then dynamically loads external .swf files into it.

In my main time line I have a series of objects.

I would like to be able to, from the loaded .swf files, make a call to the objects in the _root timeline (which I can do without a problem) letting these objects know, the name of it's dynamically generated container movieclip that contains my loaded .swf.

1. Parent SWF:
|
2. Dynamically Generated MovieClip Instance:
|
3. Dynamically loaded external SWF File:
. Script needs to know the name of the instance
of #2.

In 3. I tried using the _parent and _parent._parent to get a reference to #2. but all I was able to get was "_level0".

I've also tried using _lockroot (which somone else kindly suggested) to no avail.

Any help is greatly appreciated

Attaching A Movieclip At A Specific Location Inside Another Movieclip
Hello all,

I am trying to attach a movieclip(a) inside another movieclip(b). When (a) is attached it is always attached at the top left corner OR if I use getNextHighestDepth() then the movieclip (a) is attached randomly at different locations. I would like (a) to be attached at the centre of the parent movieclip or at a specific location inside parent movieclip.

Please help me with this. Me a newbie to actionscripting.

Thanks,

Nish

Child Movieclip Staying Within Boundries Of Parent Movieclip
I am trying to create a child movieclip that should only be displayed within the boundaries of the parent movieclip.

Lets say I have a stage of 800x600 pixels. The parent movieclip is 600x400 pixels. When I create a child-movieclip and place it at _x = 650, the movieclip "disapears" as it is outside the boundaries of the parent movieclip.

I'm pretty sure I am doing something wrong in the creation of the child movieclip, but can anyone help me PLEASE!?!

- mortenft

Dynamic Movieclip Resizing With A Textfield Inside Of The Movieclip
Hello,

I've searched past posts in regards to resizing textfields but I was unable to find any help with the problem I am having resizing a movieclip that contains a textfield.

Basically I am dynamically creating an emptyMovieClip, then within that empty movieClip I am then creating a text fielld and populating it with text.

When I try to resize the movieclips instance by clicking on a button and changing the ._width of the movieclip and it fails.

Please help,

frank grimes

Unable To Select Previous Movieclip After Duplicate Movieclip
i have a movieClip and was able to duplicate the movieClip. But now the problem is, after i have duplicated the movieClip i cannot select the previous movieclip which don allow me to move it around. Is there anyway that will allow me to select my previous movieclip after duplicated?

Below is my code:










Attach Code

var mySelection = "";

wire.onPress = function ()
{
this.createEmptyMovieClip("mc1", 90);
duplicate(mc1);
mc1 = attachMovie("idwire", "wire1", 91);
mc1._x = 273;
mc1._y = 196.5;
dragging(mc1);
}

function dragging(mc)
{
mc.onPress = function()
{
this.startDrag(true);
mySelection = this;
}
mc.onRelease = mc.onReleaseOutside = function()
{
stopDrag();
}
}

function duplicate(mc)
{
amount = 50;
while(amount>0)
{
mc.duplicateMovieClip ("mc"+i, i);
i++;
amount--;
}
}

SetProperty Doesn't Work With Movieclip Inside Of Movieclip
I originally had this set up this way and it worked.

var hita:Boolean = false;
logotop.onEnterFrame = function() {
hita = this.hitTest(this._parent.middle.hitme);
if (hita == true) {
setProperty ("logotop", _alpha, "0");
}
}

Then I put everything in a new movieclip with the instance name "printme".
Now it doesn't work and doesn't give me an error.

var hita:Boolean = false;
printme.logotop.onEnterFrame = function() {
hita = this.hitTest(this._parent.printme.middle.hitme);
if (hita == true) {
setProperty ("printme.logotop", _alpha, "0");
}
}

Do you see anything wrong with the above code?

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