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




AddEventListener Of A Linked Class Doesn't Work



Hey guys,
I have a small problem with linked custom classes [that do extend MovieClip] not receiving events sent by the document class. Here is the code:
Document class:

Code:
package {
import flash.display.MovieClip;
import flash.events.Event;

public class Main extends MovieClip {

public function Main() {
dispatchEvent(new Event("blah"));
trace("Main ");
}

}
}
Foo class:


Code:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Foo extends MovieClip {
function Foo() {
trace("Foo");
addEventListener("blah", workDarnIt);
}

function workDarnIt(evt:Event):void{
trace("got it in Foo");
}
}
}
Bar class:


Code:
package {
import Foo;
import flash.events.Event;

public class Bar extends Foo {

function Bar() {
super();
trace("Bar");
//addEventListener("blah", workDarnIt);
}

override function workDarnIt(evt:Event):void{
trace("got it in Bar");
}
}
}
The Bar class is linked to a simple square MovieClip that was placed on Stage during author time.
When I compile the .fla the it never traces "got it in bar" ?! It also never traces "got it in Foo" ?! It's as if dispatchEvent() function in the Main document class does nothing... I know for a fact that The Main class does fire an event, 'cause I tested it. But I don't understand why the Bar class doesn't hear the event "blah" from the Main? The constructors of the linked classes run before the Main() document class constructor. I know that, so why doesn't this work?

BTW: if i say stage.addEventListener() inside Bar class everything works properly. It's as if the linked Bar class is not part of DisplayList!!! How can this happen? (Bar extends Foo that extends MovieClip, and I can see the Bar square Movieclip on stage when movie runs.)

Please help! Thank you in advance.



FlashKit > Flash Help > Actionscript 3.0
Posted on: 11-03-2008, 07:26 PM


View Complete Forum Thread with Replies

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

Path To Linked HTML Document Doesn't Work After Burned To CD
Well in a nutshell that is the problem. When ever I burn to the CD my link to the html documents gets lost. Not sure what to do. It works on my computer. Can it not find it because the back slashes should be forward slashes.

on (release) {
getURL("../player%20file%20s/player%20files/viscusi1-01-wma launch.html", "_blank");
}

Please help.

Thanks
cs

Loadvars Class Doesn't Work
Hi, I'm using loadVars class to send data to a server using a POST method, but eventhough I use this :
lv.send("http://localhost/a.php","_blank","POST");
my flash always send variables in GET method, I can see in the URL address the variables I want to send (very bad thing indeed).

This is troubling me, I've tried getURL too but that doesn't work either...
help me pls

AttachMovie Doesn't Work Within A Custom Class?
Hey so I've just got some class called foo and foo has a method called bar. Bar wants to use attachMovie and call an ID from the library like so:

ActionScript Code:
class foo {
var myMC:MovieClip;
function foo() { /* ... constructor ... */ }
function bar() {
/*  myMC is defined and on stage */
myMC.attachMovie("candy","candy_spawn",myMC.getNextHighestDepth());
}
}

But this, alas does not work.

My FLA uses import foo; and it seems that the class foo cannot access the FLA's library. Yes I have it checked to export for actionscript and export to first frame with identifier "candy"...

Is this just illegal?

I Am Using Mc Tween Class , But It Doesn't Always Work , Online.
I have been using the MC Tween class, and it seems to work really well, doing everything I tell it to. Locally, that is. But when I post it up online, it is unreliable, and sometimes just doesn't work.

I have a big site that basically has one main swf and then calls in other swfs. When the other swfs get called in... I typically have movie clips in them that have ,

onClipEvent(load) {this._alpha = 0; }

And then I tell them to....... alphaTo(100,.4,"linear");

or something similar to that. But it doesn't always work. And I can't figure out why. One thing I have been doing is....I am 'including' the mc tween class in each swf. Do I only need to include it on the main swf once? Does it perhaps hurt me to put the include code on every sub swf?

Trace Doesn't Work From My As2 Class (partly)
I'm sending and receiving data using sockets from a flash as2 class. For
some reason the trace command only works when functions are called from the
interface and when the swf file loads in the flash IDE. If I send text from
my client (it's a chat program) to my swf file none of the trace commands
appear (from my class) even though everything is working fine. If I click a
button on the interface the same trace commands in my as2 class work fine.

Thank you

Eval Doesn't Work In Class Constructor, Why?
Okay, I thought it was too good to be true that I could coerce a string into a MovieClip reference, but I did it with no problems (see code 1 below). So I go into my new ActionScript 2.0 class that I am having tremendous luck with and I use the same convention...at which point I am informed that there is no such method....WHY?

code1

ActionScript Code:
var moonCLIPname:String="moon";
var moonCLIPpath:String="this.earth.";
var moonCLIPref:String=moonCLIPpath+moonCLIPname;
var moonCLIP:MovieClip=eval(moonCLIPref);
moonCLIP.onEnterFrame=function() {this._x+=3;}
stop();


works great, my "moon" MovieClip object (embedded in my "earth" MovieClip object) starts scootin' by 3 pixels/frame....

however:

ActionScript Code:
class menuItem {
    public var ID:Number;
    public var IDname:String;
    public var holderCLIPname:String;
    private var menuCLIP:MovieClip;
    private static var linkageID:String ="menuCLIP";
    private var labelCLIPname:String;
    public var initObj:Object;
   
    function menuItem(vID:Number, vIDname:String, vHolder:String, vinitObj:Object) {
        ID = vID;
        if (ID<0 || ID == undefined || ID == null) {
            ID = 1;
        }
        IDname = vIDname;
        if (IDname == undefined || IDname == null || IDname == "") {
            IDname = "menuItem "+ID;
        }
        holderCLIPname=vHolder;
        var holderCLIP:MovieClip=eval(holderCLIPname);
        menuCLIP = holderCLIP.attachMovie(LinkageID, IDname, menuCLIP.getNextHighestDepth());
        }
}


So I want to have this item attached to a MovieClip on the stage. I have tried a number of things, but always end up with either a string literal that can't be coerced to the clip reference or a recursive loop where my holderCLIP has a copy of my menuItem (which by definition has a copy of holderCLIP, etc. etc.)

I tried (as in the above example 2) to make the holderCLIP a local variable to the menuItem constructor function so that it would not be part of the object, but it doesn't work. Any suggestions?

----please see my next question along these lines as well (thanks).
p.s. your most gracious patience is appreciated when reviewing this post. It is really late and I may have missed a couple of capitalizations or something like that.

Rowdy

[AS2.0]extend Class, No Error, Doesn't Work
Hi, to find an error in ths one is pretty challenging, I have a class which I wanted to make this "menu" moveclip thing extends when I roll Over and go back to the original length if roll out, here's the code, it returns no errors, just doesn't work...

thanks for your help, the code is pretty long but please, if you have time, I really need your help...


ActionScript Code:
//ClASS CODE
 
class ExtendBar extends MovieClip{
    var homeX:Number;
    var finalX:Number;
    var myClip:MovieClip;
    var extendSpeed:Number;
    var slowDown:Number
    var extend:Boolean;
    function ExtendBar(origX:Number, endX:Number, clips:MovieClip, slow:Number){
        homeX = origX;
        finalX = endX;
        myClip = clips;
        slowDown = slow;
    }
    function extendIt(){
        myClip.onEnterFrame = function(){
            this.extend = true;
            extendSpeed = Math.round((finalX - homeX)*slowDown);
            if(extendSpeed == 0){
                this.extend = false;
                this._xscale = finalX;
                delete this.onEnterFrame;
            }
            myClip._xscale += extendSpeed;
        }
    }
}



ActionScript Code:
//FLA CODE
 
var menu:ExtendBar = new ExtendBar(20, 400, this, .05);
menu.onRollOver = function(){
    extendIt();
}

Please Help Flash Page Linked Do Another Flash Page On Server Doesn't Work
Hey,
I'm creating a website for a client that has a component scroll on the main stage linked to a dynamic text box with some buttons that when clicked will load an external file on Layer 1 of the main timeline in Flash. When I tested it in Flash it worked, when I previewed it in Dreamweaver it worked but when I uploaded it to the server. The main swf loads but the files that are linked to the main .swf don't

On the first frame of the main time line I have the code below
loadMovieNum("movies/Thumbnail1_mc.swf",1);



On each of th buttons I have the code below
on (release) {
loadMovieNum("Movies/Thumbnail1_mc.swf", 1);
}

I have read some of the posts here but my main .swf file plays so its not the "scripts" folder in the wrong place.
and I'm pretty sure that it can't find the files due to my path to the file, but I'm not sure how to get the main .swf file to look for the Thumbnail .swf files on the server. Please help.

Thank you

Add AddEventListener('load') To A MC From A Class?
I have a simple class that extends a MC. I want to add a load event so the MC traces it's name when loaded.

My script:


ActionScript Code:
package TreeManager
{
    import flash.display.MovieClip;
    import flash.events.*;

    public class AddProfile extends MovieClip
    {
       
        public function callback_load () {
          trace(this.name);
        }
       
        stage.addEventListener('load', callback_load);
    }
   
}

I have a MC on the stage and it's class is set to TreeManager.AddProfile.

I'm just getting errors though... anyone know where I've gone wrong?

Making My First "real" Class - Doesn't Work :P
Hello!

Im having a shot at creating my first class, which is supposed to be a function that moves something a short distance. I wanted to make the function a class so I can access it anywhere in my projects and it'll work, so I dont have to write "public function moveObject() {etcetc}" over and over again, everywhere ^^.

But, it doesn't work! I just made an object on the stage and named it "newBall" and wrote the function on the timeline like this, to test it out:


ActionScript Code:
import ClassesFolder.simpleMovement;
      simpleMovement(newBall);

I tried using addEventListener to move it as well, but then flash just told me it had no idea what addEventListener was(but I did import flash.events.. hmm!). I know this is a kinda big post but if anyone could help me with why it's not working, I would really appreciate it! Thanks a lot in advance^^

My class code looks like this:


ActionScript Code:
package ClassesFolder {
    import flash.display.*;
    import flash.utils.Timer;
    import flash.utils.*;
    import flash.events.*;
    import flash.events.Event;
    import flash.display.MovieClip;
    import flash.display.DisplayObject;
    import flash.events.TimerEvent;
    import flash.display.Stage;
        // i just imported tons of (probably) unneccessary stuff here, but i    wanted it to work ^^
   
    public class simpleMovement {
       
        // variables here
        private var moveObject:MovieClip;
       
        public function simpleMovement(mc:MovieClip) {
            moveObject = mc;
            moveObject.x += 50;
            moveObject.y += 50;
        }
    }
}

"a Class" Hover Doesn't Work On CSS In Flash>
I have managed to get a stylesheet into a flashfile. However when I call an a class style as opposed to a regular .style , it doesn't seem to like it.

Is there any other way to make dynamically loaded text which are links that can have a change of color or underline when the mouse rolls over it like "a class"?

Thanks in advance.

Cb Linked To Class
my cb is linked to the following class. and it is placed on the fla.(Interface)
it traces to show that theXML is getting loaded properly . What can I do to put it on the interface?


Code:
package chromatic.load_files{
import fl.controls.ComboBox;
import flash.display.MovieClip;
import flash.events.Event;
import fl.data.DataProvider;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequest;
import fl.containers.UILoader;
import chromatic.load_files.UIImageComponent;
import chromatic.load_files.LoadXML;
import chromatic.load_files.LoadRequest;

public class CBMajorComponent extends MovieClip {

public var cbMajor:ComboBox=new ComboBox();
private var uiImageComponent:UIImageComponent;
private var loadXML:LoadXML=new LoadXML();
private var loadRequest:LoadRequest=new LoadRequest();

private var listURL:URLRequest=new URLRequest();
private var dataLoader:URLLoader=new URLLoader();
private var theXML:XML=new XML();


private var arrayFile:Array=new Array("load_assets/keylist.xml");
private var concatArray:Array=new Array("CMajor","GMajor","DMajor","AMajor","EMajor",
"BMajor","FSharpMajor","CSharpMajor","FMajor",
"BFlatMajor","EFlatMajor","AFlatMajor",
"DFlatMajor","GFlatMajor","CFlatMajor");

private var noSpace:String;
private var fileName:String;
private var evtIndex:Number=-1;
private var sel:Number=-1;


public function CBMajorComponent():void {
trace("in CBMajorComponent");
init();
}
private function init():void {
fileName=arrayFile[0];
setFileName(fileName);

setupComponent();
}
private function setupComponent():void {
trace("in cbmajor setup "+fileName);
cbMajor=new ComboBox();
dataLoader=loadRequest.setUpRequest(fileName);

dataLoader.addEventListener(Event.COMPLETE,dataLoaded);

cbMajor.setSize(200, 22);
cbMajor.prompt = "Select a Key";
cbMajor.editable=false;
cbMajor.rowCount=15;
cbMajor.width=110;
cbMajor.move(0,0);

addChild(cbMajor);
cbMajor.addEventListener(Event.CHANGE, selectedName);
cbMajor.addEventListener(Event.CHANGE,changeEvent);

}
private function dataLoaded(evt:Event):void {

theXML=loadXML.setUpXML(fileName);
theXML=XML(dataLoader.data);


for (var i:int; i<concatArray.length; i++) {
noSpace=concatArray[i];


trace(theXML.key[noSpace].keyName);
cbMajor.addItem({label:(theXML.key[noSpace].keyName)});

}
}
private function selectedName(evt:Event):void {

/*Combobox evt.target.selectedName cannot have spaces (as we have).So until
* I learn how to rid a string of spaces thus the var noSpace
*/
uiImageComponent=new UIImageComponent();
evtIndex=evt.target.selectedIndex;
noSpace=concatArray[evtIndex];
setNoSpace(noSpace);
uiImageComponent.setFileName(fileName);
uiImageComponent.setNoSpace(noSpace);
uiImageComponent;
}
public function changeEvent(evt:Event):void {
trace(" You selected a key");
}
public function setFileName(fileName):void {

this.fileName=fileName;
}
public function getFileName():String {
return fileName;
}
public function setNoSpace(noSpace):void {

this.noSpace=noSpace;
}
public function getNoSpace():String {
return noSpace;
}
}
}

I Can Never Get AddEventListener(Event.PROGRESS... To Work
Whenever I try to use the progress event for any type of loading, I always get this error:
Desc: 1119: Access of possibly undefined property PROGRESS through a reference with static type Class.
Source: picLoader.addEventListener(Event.PROGRESS, picProgressHandler);

What am I doing wrong?

This code is straight from Adobe's example...

http://livedocs.adobe.com/flash/9.0/Act ... oader.html

Code:


//on timeline in flash movie
import fl.containers.UILoader;
import fl.controls.Label;
import fl.controls.ProgressBar;
import fl.controls.ProgressBarMode;

var picLoader:UILoader = new UILoader();
        picLoader.scaleContent = true;
        addChild(picLoader);
        picLoader.x = 25;
        picLoader.y = 25;
        picLoader.width = 190;
        picLoader.height = 230;
picLoader.source = "mypicture.jpg";

picLoader.addEventListener(Event.PROGRESS, picProgressHandler);
picLoader.addEventListener(Event.COMPLETE, picCompleteHandler);

function picCompleteHandler(event:Event) {
    trace("Number of bytes loaded: " + picLoader.bytesLoaded);
}

function picProgressHandler(event:ProgressEvent):void {
        var myLabel:Label = new Label();
        myLabel.autoSize = TextFieldAutoSize.LEFT;
        myLabel.text = "";
        myLabel.move(10, 10);
        addChild(myLabel);
       
        var myProgressBar:ProgressBar = new ProgressBar();
        myProgressBar.mode = ProgressBarMode.MANUAL;
        myProgressBar.move(10, 30);
        addChild(myProgressBar);
       
    var uiLdr:UILoader = event.currentTarget as UILoader;
    var kbLoaded:String = Number(uiLdr.bytesLoaded / 1024).toFixed(1);
    var kbTotal:String = Number(uiLdr.bytesTotal / 1024).toFixed(1);
    myLabel.text = kbLoaded + " of " + kbTotal + " KB" + " (" + Math.round(uiLdr.percentLoaded) + "%)";
    myProgressBar.setProgress(event.bytesLoaded, event.bytesTotal);
}

AddEventListener Adds Listener To All Children Of Class Instance
Hello!

I'm just getting started with writing ActionScript 3.0 apps, with classes and what have you.

I have a class called MenuItem which extends MovieClip.

When I use the addEventListener method on any MenuItem instance defined in my document class, it seems to add event listeners to the individual children of the instance, not the instance itself. Because when I try to reference the MenuItem instance in my event handler with using MenuItem(eventObject.target), it throws me a type conversion error, and says my eventObject target is a TextField or a Sprite, depending on which child within the MenuItem instance I'm technically clicking.

I have defined the MenuItem's inherited buttonMode property to be true, and I would think that adding an event listener to it would make a fictional "hit area" like in a SimpleButton, so that when I click anywhere on my MenuItem, it would invoke the MouseEvent with the MenuItem instance itself as the target of the eventObject, but this is obviously not the case.

Basically my problem is that the addEventListener method adds event listeners to all the children of the class instance instead of the class instance itself.

I've probably misunderstood something about the hierarchy of instances when using addChild or something like that, but if anyone understand what I mean and know how to help me, it would really make my day!

Thanks in advance for any help!

Importing A Swf Linked To A Class
Hello, I hope you could help me because i am really stuck into it:

I have a scroll file, taken from a tutorial, which is linked to a class. After having customized my file I did try it and it works fine. The problem is starting when I try to import this file to an empty MCL in my website. When I have imported all the elements they do not respond and act like single pieces (es. the scroll bar is detached from the scroller). What can I do? I am attaching all the codes and I hope you can help me .

thank you so much

p.s all the classes and the file are in the same directory


ActionScript Code:
//this is the scroll class//

/**
     * Flashscaper Scrollbar Component
     * Customizable Scrollbar
     *
     * @author    Li Jiansheng
     * @version  1.0.0
     * @private
     * @website     [url]http://www.flashscaper[/url]
     */

package {
       
    import caurina.transitions.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;

    public class Scrollbar extends MovieClip {

        private var target:MovieClip;
        private var top:Number;
        private var bottom:Number;
        private var dragBot:Number;
        private var range:Number;
        private var ratio:Number;
        private var sPos:Number;
        private var sRect:Rectangle;
        private var ctrl:Number;//This is to adapt to the target's position
        private var trans:String;
        private var timing:Number;
        private var isUp:Boolean;
        private var isDown:Boolean;
        private var isArrow:Boolean;
        private var arrowMove:Number;
        private var upArrowHt:Number;
        private var downArrowHt:Number;
        private var sBuffer:Number;

        public function Scrollbar():void {
            scroller.addEventListener(MouseEvent.MOUSE_DOWN, dragScroll);
            stage.addEventListener(MouseEvent.MOUSE_UP, stopScroll);           
            stage.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheelHandler);
        }
        //
        public function init(t:MovieClip, tr:String,tt:Number,sa:Boolean,b:Number):void {
            target = t;
            trans = tr;
            timing = tt;
            isArrow = sa;
            sBuffer = b;
            if (target.height <= track.height) {
                this.visible = false;
            }         

            //
            upArrowHt = upArrow.height;
            downArrowHt = downArrow.height;
            if (isArrow) {
                top = scroller.y;
                dragBot = (scroller.y + track.height) - scroller.height;
                bottom = track.height - (scroller.height/sBuffer);

            } else {
                top = scroller.y;
                dragBot = (scroller.y + track.height) - scroller.height;
                bottom = track.height - (scroller.height/sBuffer);

                upArrowHt = 0;
                downArrowHt = 0;
                removeChild(upArrow);
                removeChild(downArrow);
            }
            range = bottom - top;
            sRect = new Rectangle(0,top,0,dragBot);
            ctrl = target.y;
            //set Mask
            isUp = false;
            isDown = false;
            arrowMove = 10;
           
            if (isArrow) {
                upArrow.addEventListener(Event.ENTER_FRAME, upArrowHandler);
                upArrow.addEventListener(MouseEvent.MOUSE_DOWN, upScroll);
                upArrow.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
                //
                downArrow.addEventListener(Event.ENTER_FRAME, downArrowHandler);
                downArrow.addEventListener(MouseEvent.MOUSE_DOWN, downScroll);
                downArrow.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
            }
            var square:Sprite = new Sprite();
            square.graphics.beginFill(0xFF0000);
            square.graphics.drawRect(target.x, target.y, target.width+5, (track.height+upArrowHt+downArrowHt));
            parent.addChild(square);           
            target.mask = square;
           
        }
        public function upScroll(event:MouseEvent):void {
            isUp = true;
        }
        public function downScroll(event:MouseEvent):void {
            isDown = true;
        }
        public function upArrowHandler(event:Event):void {
            if (isUp) {
                if (scroller.y > top) {
                    scroller.y-=arrowMove;
                    if (scroller.y < top) {
                        scroller.y = top;
                    }
                    startScroll();
                }
            }
        }
        //
        public function downArrowHandler(event:Event):void {
            if (isDown) {
                if (scroller.y < dragBot) {
                    scroller.y+=arrowMove;
                    if (scroller.y > dragBot) {
                        scroller.y = dragBot;
                    }
                    startScroll();
                }
            }
        }
        //
        public function dragScroll(event:MouseEvent):void {   
            scroller.startDrag(false, sRect);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, moveScroll);
        }
        //
        public function mouseWheelHandler(event:MouseEvent):void {
            if (event.delta < 0) {
                if (scroller.y < dragBot) {
                    scroller.y-=(event.delta*2);
                    if (scroller.y > dragBot) {
                        scroller.y = dragBot;
                    }
                    startScroll();
                }
            } else {
                if (scroller.y > top) {
                    scroller.y-=(event.delta*2);
                    if (scroller.y < top) {
                        scroller.y = top;
                    }
                    startScroll();
                }
            }
        }
        //
        public function stopScroll(event:MouseEvent):void {
            isUp = false;
            isDown = false;
            scroller.stopDrag();

            stage.removeEventListener(MouseEvent.MOUSE_MOVE, moveScroll);
        }
        //
        public function moveScroll(event:MouseEvent):void {
            startScroll();

        }
        public function startScroll():void {
            ratio = (target.height - range)/range;
            sPos = (scroller.y * ratio)-ctrl;
           
            Tweener.addTween(target, {y:-sPos, time:timing, transition:trans});
        }
    }
}


//this is the AS that I am using in my scroll file//
sb.init(images_mc, "easeOutBack",2,true,2);

//this is the file script to import the swf into an empty mcl"

import LoaderExample;


var loadedAsset:LoaderExample = new LoaderExample('tee.swf');
holder.addChild(loadedAsset)

Movieclip Linked To A Class
I have a question about the garbage collector:

I have a movieclip in my library, that is linked to a class. So when I place that class on stage, I see the movieclip.
Now when I wanted to delete my class, I would delete all event listeners, and make sure there are no references to it. Then I remove it from it's parent. It's a public class, so there will be no vars to delete (right?).

Now here's the deal:
in the library, I open the movieclip, which has 10 frames, and in frame 1, I put:

trace("still here");

now when I run the program, and delete that class instance, not totally surprisingly, it will keep tracing "still here".
my question: how do I delete that class instance properly? And can I be sure the class will be deleted when the "still here" is not being traced? Maybe I need to delete the movieclip inside the class? How can I do that when they are in my library and don't have a id?
Help would be very much appreciated!

Edit:
I made a document of the situation :
download





























Edited: 06/23/2007 at 01:19:41 PM by Psycho Mantis

Importing A Swf Linked To A Class
Hello, I hope you could help me because i am really stuck into it:

I have a scroll file, taken from a tutorial, which is linked to a class. After having customized my file I did try it and it works fine. The problem is starting when I try to import this file to an empty MCL in my website. When I have imported all the elements they do not respond and act like single pieces (es. the scroll bar is detached from the scroller). What can I do? I am attaching all the codes and I hope you can help me .

thank you so much

p.s all the classes and the file are in the same directory







Attach Code

//this is the scroll class//

/**
* Flashscaper Scrollbar Component
* Customizable Scrollbar
*
* @authorLi Jiansheng
* @version1.0.0
* @private
* @website http://www.flashscaper
*/

package {

import caurina.transitions.*;
import flash.display.*;
import flash.events.*;
import flash.geom.*;

public class Scrollbar extends MovieClip {

private var target:MovieClip;
private var top:Number;
private var bottom:Number;
private var dragBot:Number;
private var range:Number;
private var ratio:Number;
private var sPos:Number;
private var sRect:Rectangle;
private var ctrl:Number;//This is to adapt to the target's position
private var trans:String;
private var timing:Number;
private var isUp:Boolean;
private var isDown:Boolean;
private var isArrow:Boolean;
private var arrowMove:Number;
private var upArrowHt:Number;
private var downArrowHt:Number;
private var sBuffer:Number;

public function Scrollbar():void {
scroller.addEventListener(MouseEvent.MOUSE_DOWN, dragScroll);
stage.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
stage.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheelHandler);
}
//
public function init(t:MovieClip, tr:String,tt:Number,sa:Boolean,b:Number):void {
target = t;
trans = tr;
timing = tt;
isArrow = sa;
sBuffer = b;
if (target.height <= track.height) {
this.visible = false;
}

//
upArrowHt = upArrow.height;
downArrowHt = downArrow.height;
if (isArrow) {
top = scroller.y;
dragBot = (scroller.y + track.height) - scroller.height;
bottom = track.height - (scroller.height/sBuffer);

} else {
top = scroller.y;
dragBot = (scroller.y + track.height) - scroller.height;
bottom = track.height - (scroller.height/sBuffer);

upArrowHt = 0;
downArrowHt = 0;
removeChild(upArrow);
removeChild(downArrow);
}
range = bottom - top;
sRect = new Rectangle(0,top,0,dragBot);
ctrl = target.y;
//set Mask
isUp = false;
isDown = false;
arrowMove = 10;

if (isArrow) {
upArrow.addEventListener(Event.ENTER_FRAME, upArrowHandler);
upArrow.addEventListener(MouseEvent.MOUSE_DOWN, upScroll);
upArrow.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
//
downArrow.addEventListener(Event.ENTER_FRAME, downArrowHandler);
downArrow.addEventListener(MouseEvent.MOUSE_DOWN, downScroll);
downArrow.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
}
var square:Sprite = new Sprite();
square.graphics.beginFill(0xFF0000);
square.graphics.drawRect(target.x, target.y, target.width+5, (track.height+upArrowHt+downArrowHt));
parent.addChild(square);
target.mask = square;

}
public function upScroll(event:MouseEvent):void {
isUp = true;
}
public function downScroll(event:MouseEvent):void {
isDown = true;
}
public function upArrowHandler(event:Event):void {
if (isUp) {
if (scroller.y > top) {
scroller.y-=arrowMove;
if (scroller.y < top) {
scroller.y = top;
}
startScroll();
}
}
}
//
public function downArrowHandler(event:Event):void {
if (isDown) {
if (scroller.y < dragBot) {
scroller.y+=arrowMove;
if (scroller.y > dragBot) {
scroller.y = dragBot;
}
startScroll();
}
}
}
//
public function dragScroll(event:MouseEvent):void {
scroller.startDrag(false, sRect);
stage.addEventListener(MouseEvent.MOUSE_MOVE, moveScroll);
}
//
public function mouseWheelHandler(event:MouseEvent):void {
if (event.delta < 0) {
if (scroller.y < dragBot) {
scroller.y-=(event.delta*2);
if (scroller.y > dragBot) {
scroller.y = dragBot;
}
startScroll();
}
} else {
if (scroller.y > top) {
scroller.y-=(event.delta*2);
if (scroller.y < top) {
scroller.y = top;
}
startScroll();
}
}
}
//
public function stopScroll(event:MouseEvent):void {
isUp = false;
isDown = false;
scroller.stopDrag();

stage.removeEventListener(MouseEvent.MOUSE_MOVE, moveScroll);
}
//
public function moveScroll(event:MouseEvent):void {
startScroll();

}
public function startScroll():void {
ratio = (target.height - range)/range;
sPos = (scroller.y * ratio)-ctrl;

Tweener.addTween(target, {y:-sPos, time:timing, transition:trans});
}
}
}


//this is the AS that I am using in my scroll file//
sb.init(images_mc, "easeOutBack",2,true,2);

//this is the file script to import the swf into an empty mcl"

import LoaderExample;


var loadedAsset:LoaderExample = new LoaderExample('tee.swf');
holder.addChild(loadedAsset);

Linked Class Constructor
I have a movieclip in my library that I have linked to a class with a constructor that takes a parameter. But I can't instantiate the library clip with the class constructor. It says the constructor should not take any parameters. Is it using the movieclip constructor instead of the linked class? Is it possible to get around this?


Code:

public class MessageBox extends Sprite
{
public function MessageBox(txt : String)
{
}
}

Code:

// MsgBox is the library clip that has linked the above class (MessageBox).
var msg : MsgBox = new MsgBox("blablablabablab");

Papervision3D Linked Class
Hi, I'm building a 3D carousel but now I got stuck with a specific problem: when instancing every MovieAssetMaterial, it gets the linked class from the library, ok? In my development this class really exists (not automatically generated), and see this class is instanced only once. Well, what I'd like is this class being instantiated each time I need a new plane, so I can pass variables, is that possible? or how can I pass data to each plane generated? I think it's a common issue.

Thanks!

Access Of Undefined Property. Work.addEventListener
Hello Guys,

I am hoping someone can help me, as i have been trying to get this to work for the last four hours.

I am trying to create button that links to URL address with AS3.0 This is the code I am using:


Code:
work.addEventListener(MouseEvent.CLICK, callLink);
function callLink():void {
var url:String = "http://www.hologramdesigns.com";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, '_self');
} catch (e:Error) {
trace("Error occurred!");
}
}


However, I am retrieving this error on running.

1120: Access of undefined property work. work.addEventListener(MouseEvent.CLICK, callLink);

I have attached the .fla file if anyone can assist me with where I am going wrong it would be much appreciated.

Access Of Undefined Property. Work.addEventListener
Hello Guys,

I am new to Action Scripting 3.0 - and I am having difficulty getting a button to open a URL.

I have created an invisible button called work (hoping that it would) and this is the action scripting I have created.


ActionScript Code:
work.addEventListener(MouseEvent.CLICK, callLink);
function callLink():void {
  var url:String = "http://www.hologramdesigns.com";
  var request:URLRequest = new URLRequest(url);
  try {
    navigateToURL(request, '_self');
  } catch (e:Error) {
    trace("Error occurred!");
  }
}

When I run/publish this script flash reports back this error. 1120: Access of undefined property work. work.addEventListener(MouseEvent.CLICK, callLink);

I hope someone can help.

Return A Obj From A Class, After A URLLoader.addEventListener(Event.COMPLETE,onJSON);
Hey all,

coment below


ActionScript Code:
loadJSON.init("data.json");//run from Doc Class

function parentTrace(decoded)
{
    trace(decoded);
}

loadJSON.as

ActionScript Code:
package
{
    import com.adobe.serialization.json.*;
    import flash.display.MovieClip;
    import flash.events.*;
    import flash.display.*;
    import flash.net.URLRequest;
    import flash.net.URLLoader;

    public class loadJSON extends MovieClip
    {
        public static function init(jsonFile):void
        {
            var loader:URLLoader=new URLLoader;
            loader.addEventListener(Event.COMPLETE,onJSON);
            loader.load(new URLRequest(jsonFile));
        }
        public static function onJSON(e:Event):void
        {
            var jsonData:String=e.currentTarget.data;
            jsonData=jsonData.replace(/
/g,"");
            var decoded:Object=JSON.decode(jsonData);
            stage.parentTrace(decoded); // this does not work
//i just want decoded to be push back to where the class was called after the file load.
        }
    }
}

Is There Any Way To Access Class Variables From Linked MC?
Let's say I have a class called "Calendar" that has an MC called "buttonDisplay_mc" linked to it. Inside "buttonDisplay_mc" I have, among other buttons, "january_mc".

How would I make it so that upon "january_mc.onRelease", it sets a variable "month" inside the "Calendar" class?

Thank you very much in advance for your time.

PS:AS2 in Flash 8;

Cb Linked To Class And Not Loading On The.fla(Interface
my cb is linked to the following class. and it is placed on the fla.(Interface)
it traces to show that theXML is getting loaded properly . What can I do to put it on the interface?


Code:
package chromatic.load_files{
import fl.controls.ComboBox;
import flash.display.MovieClip;
import flash.events.Event;
import fl.data.DataProvider;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequest;
import fl.containers.UILoader;
import chromatic.load_files.UIImageComponent;
import chromatic.load_files.LoadXML;
import chromatic.load_files.LoadRequest;

public class CBMajorComponent extends MovieClip {

public var cbMajor:ComboBox=new ComboBox();
private var uiImageComponent:UIImageComponent;
private var loadXML:LoadXML=new LoadXML();
private var loadRequest:LoadRequest=new LoadRequest();

private var listURL:URLRequest=new URLRequest();
private var dataLoader:URLLoader=new URLLoader();
private var theXML:XML=new XML();


private var arrayFile:Array=new Array("load_assets/keylist.xml");
private var concatArray:Array=new Array("CMajor","GMajor","DMajor","AMajor","EMajor",
"BMajor","FSharpMajor","CSharpMajor","FMajor",
"BFlatMajor","EFlatMajor","AFlatMajor",
"DFlatMajor","GFlatMajor","CFlatMajor");

private var noSpace:String;
private var fileName:String;
private var evtIndex:Number=-1;
private var sel:Number=-1;


public function CBMajorComponent():void {
trace("in CBMajorComponent");
init();
}
private function init():void {
fileName=arrayFile[0];
setFileName(fileName);

setupComponent();
}
private function setupComponent():void {
trace("in cbmajor setup "+fileName);
cbMajor=new ComboBox();
dataLoader=loadRequest.setUpRequest(fileName);

dataLoader.addEventListener(Event.COMPLETE,dataLoaded);

cbMajor.setSize(200, 22);
cbMajor.prompt = "Select a Key";
cbMajor.editable=false;
cbMajor.rowCount=15;
cbMajor.width=110;
cbMajor.move(0,0);

addChild(cbMajor);
cbMajor.addEventListener(Event.CHANGE, selectedName);
cbMajor.addEventListener(Event.CHANGE,changeEvent);

}
private function dataLoaded(evt:Event):void {

theXML=loadXML.setUpXML(fileName);
theXML=XML(dataLoader.data);


for (var i:int; i<concatArray.length; i++) {
noSpace=concatArray[i];


trace(theXML.key[noSpace].keyName);
cbMajor.addItem({label:(theXML.key[noSpace].keyName)});

}
}
private function selectedName(evt:Event):void {

/*Combobox evt.target.selectedName cannot have spaces (as we have).So until
* I learn how to rid a string of spaces thus the var noSpace
*/
uiImageComponent=new UIImageComponent();
evtIndex=evt.target.selectedIndex;
noSpace=concatArray[evtIndex];
setNoSpace(noSpace);
uiImageComponent.setFileName(fileName);
uiImageComponent.setNoSpace(noSpace);
uiImageComponent;
}
public function changeEvent(evt:Event):void {
trace(" You selected a key");
}
public function setFileName(fileName):void {

this.fileName=fileName;
}
public function getFileName():String {
return fileName;
}
public function setNoSpace(noSpace):void {

this.noSpace=noSpace;
}
public function getNoSpace():String {
return noSpace;
}
}
}

How To Modify Components From Within A Linked Class?
Is it possible to use or modify components in a movieclip from within a class that is linked to that movieclip.

I have a Photo class that is linked to a MovieClip called Photo_mc that has a Loader component called photoLoader. How can I change the contentPath of photoLoader from within an instance of Photo. I'd like to go photoLoader.contentPath = url but it doen't now about photoLoader.

How can I do it? Is it even possible? I may have got this whole linking thing misunderstood.

Cheers,
Glenn

Multiple Instances Of A MovieClip With Linked Class
Hi there,

I'm having trouble linking a Class to a MovieClip and putting that MovieClip on the Stage multiple times.

I have 12 instances of the Library MovieClip "mcDisplayItem" on the Stage, with the instance names "mcResult1" to "mcResult12". Each one has a text field inside it, named "txtTitle".

Whether I try adding the text field dynamically through the Class, or just setting the text of the TextField which already exists, only the first one ever gets populated with the title text, even though all 12 of them trace the correct result. Here's a cut-down version of my MovieClip Class:


Code:
package com.test.productdisplay {

import flash.display.*;
import flash.text.*;

public class DisplayItem extends MovieClip {

private var _guid:String;
private var _data:Object;

private var txtTitle:TextField;

public function DisplayItem() {
txtTitle = new TextField();
}

public function display(item:Array) : void {
_guid = item[0];
_data = item[1];

txtTitle.text = _data.name;
addChild(txtTitle);
trace(txtTitle+":"+txtTitle.text);
}

}
}


The function "display" is then called from a parent script, 12 times for each of the MovieClip instances. Although the trace shows up 12 times, only one TextField appears, and that is in the first instance of mcDisplayItem.

Please help! It's not working like AS2

Thanks

:-Joe

MovieClip With Linked Class And Initialization Parameters
So I have a movieclip that I want to play nice with my class file. So I set the linkage and all that and it works. But, my initialization function gets called with no parameters, because I have not set any. How do I do that with this method?

I've tried something like:

Code:
import tab;
tab1_mc = new tab("left", 5, 55, "testclip.swf", 0);
And that sets the parameters, but not before the linkage on the MovieClip fires. Any thoughts on how to get the best of both worlds?

Accessing Elements On The Stage From A Linked Class
I'm trying to link a clip to a class, and it goes well until I try to access MovieClips or TextFields placed on the stage within that clip from code in the class. My code is below; there is a TextField called output_txt on the stage within this clip.

Any help is much appreciated.
Dave


class Main extends MovieClip{
public function Main() {
//trace("123"); <--if I replace the line below with this, it traces nicely
output_txt.text = "123";
stop();
}
}

Change Properties Of Multiple Movieclips Linked To A Class?
If I have several movieclips all linked to one class, how could you change all of the movieclip's ._alpha properties to 50 with one onRelease function?



thanks for any input

AS 3 Library Class Links And Clips Within The Linked Object?
I've found several threads on the MOUSE_UP "problem" with AS3 where onReleaseOutside, in its AS2 form, doesn't work. The solution being to add a MOUSE_UP event to the Stage.

Question is, if I have a slide-bar class, a simple dragger, its it happens to be added to a movieclip thats in another movieclip etc, do I have to adjust my class continually so that I use: this.parent.parent.parent etc. to get to the Stage to set this listener? I can't just set it using Stage.addListener.

I think this looks cryptic - but to those that have run into this specific MOUSE_UP issue, I'm sure this will look familiar.

Thanks for any input in advance.

How To Remove A Class Or Its Function Linked To A Movie Clip?
i have a movie clip physically on the timeline with the following class attached to it.
is it possible to remove the class or its ENTER_FRAME function via script on the timeline?



Code:
package{

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

public class MCFUNCTION extends MovieClip {

public function MCFUNCTION() {
addEventListener(Event.ENTER_FRAME, loop);
}

private function loop(e:Event):void{
trace("loop");

}
}
}
thanks

Adding Instance To Stage From A Movieclip Linked Class
Hi,
I was trying to add an instance I created in a class to the main
stage, like this:


Code:
var blackD:MovieClip = new blackboardinfo();
Stage.addChild(blackD);
it was working fine, however, after I added preload page, which will now
load everything else as external swf, i began getting this error
TypeError: Error #1009: Cannot access a property or method of a null object reference.

I tried to modify the code to this based on the similar questions i found online


Code:
var mc:MovieClip = new MovieClip();
addChild(mc);
var _stage:Stage = mc.stage;
_stage.addChild(blackD);
I still get the same error, I know it is because "stage", but if I dont use stage, how
can I add an instance on top of everything? thanks.

Why Stage.root.addEventListener & Root.stage.addEventListener Both Work ?
Why does:

stage.root.addEventListener
&
root.stage.addEventListener

both work ?

which one is really under which ?

Passing Vars To Constructor Of MC In Library Which Is Linked To A Custom Class
Dear board,

how can one attach a movie clip from the library, which is linked to a custom class, to the stage and initialize it?

In the flash help it says:


Quote:




initObject:Object [optional] - (Supported for Flash Player 6 and later) An object that contains properties with which to populate the newly attached movie clip. This parameter allows dynamically created movie clips to receive clip parameters. If initObject is not an object, it is ignored. All properties of initObject are copied into the new instance. The properties specified with initObject are available to the constructor function.




The properties specified with initObject are available to the constructor function.


I am attaching the movie clip like this:


ActionScript Code:
eventDetails_mc = _root.attachMovie("EventDetailsView", "eventDetails_mc", {events_a:events_a, id_n:id_n});


The constructor of EventDetailsView looks like this:


ActionScript Code:
public function EventDetailsView(events_a:Array, id_n:Number) {
    // ... 
}


It doesn't work for some reason. I am getting a Type Mismatch error. Why is that!?

Drop Menu : Rollovers/GetURL In A Movie Don't Work...and The SWF Doesn't Work In FF
My links/rollovers don't work in Mozilla and the dropdown menu part don't work (the rollovers and the getURLs) in any browser.

What's wrong with this??? I think it's something simple.
I've already tried:

Code:
this._lockroot = true;
I also tried writing the AS as:

Code:
one.title.text = "The Text";
one.onRollOver = over;
one.onRollOut = out;
function over () {
this.gotoAndPlay(2);
}
function out () {
this.gotoAndPlay(11);
}
one.onRelease = function(){
getURL("http://www.thelink.com");
}
...didn't work...

I hope someone can help!

Download the: Source File


(Lately I've gotten no help off this site and it's been very depressing because this site people used to be very helpful...I hope someone can change my mind)

User Defined Base Class Linked With 2 Symbols Gives Error #1034: Type Coercion Failed
Hi, I have two movie clips in the library linked to the same base class, Container, with different class names defined in Properties. These clips each contain (nest) several other clips that are also linked to another base class, Contained. Is there something else that needs to be done to deal with nested clips like this? I'm not certain that nesting is an issue, but in a scenario with different symbols I could not replicate the problem. I've attached a simplified version of the problem .fla with the 2 .as files. I'm using the latest version of CS3. The error is: TypeError: Error #1034: Type Coercion failed: cannot convert Contained_AnteriorLeft@1c4ba431 to Contained_PosteriorLeft.

This._lockroot Doesn't Work (combobox Components Won't Work)
I have a preloader (preloader.swf) which loads a form (offerte.swf).

I've put the this._lockroot on the "application" timeline on the first frame of the "Flash form application" (offerte.swf).
But the combobox components still won't work.

I had it working before, but suddenly it seemed to stop! Now I can't get it get to work again.

Preview: www.blaak.nl/flash/

This._lockroot Doesn't Work (combobox Components Won't Work)
I have a preloader (preloader.swf) which loads a form (offerte.swf).

I've put the this._lockroot on the "application" timeline on the first frame of the "Flash form application" (offerte.swf).
But the combobox components still won't work.

I had it working before, but suddenly it seemed to stop! Now I can't get it get to work again.

Preview: www.blaak.nl/flash/

Variable.addEventListener OR DynamicVariable.addEventListener
This is my first post on these forums though I've appreciated tons and tons of help from others that have posted their questions (and answers). I'm trying to dynamically create a menu based on the number of entries in an xml file. I need to create a button for each entry which then triggers a function through an eventListener. So I need to either dynamically name my movieClips I'm creating (for my buttons) OR find a way to take "tempName = mc.name" and then use that in tempName.addEventListener.

The relavent code is below! Thanks for the help!


Code:
function drawImage(i) {
for (var item:int = 0; item < i; item++) {
objectType = myXML.slide[item].objectType;

if (objectType == "image") {
dataPath = myXML.slide[item].src;

var mc:MovieClip = new MovieClip();
imageMaster.addChild(mc);
mc.graphics.beginFill(0x00000);
mc.graphics.drawRect(wide*100 - 100, high*50, 40, 40);
mc.graphics.endFill();
mc.name = "mc"+item;

mc.addEventListener(MouseEvent.MOUSE_UP,function(evt:MouseEvent){switchSlide(dataPath)});

}
}
}
The code does create all the buttons but when I click on any of the buttons the action performed is the action intended for the last button.

Thanks again!

Smoothing Doesn't Work It Oughta Work
Hello!

I am trying to develope this website:

http://anarchy.primalinsanity.com/~villain/nma.rar

Its smoothing effect, however, has mysteriously disappeared. It is only enabled in authoring mode, not if I export the movie. I've tried everything to re-enable it:

1) Changed formats from JPG to PNG
2) Library > Bitmap Properties > Allow smoothing
3) File > Publish Settings > Smooth

But nothing seems to work

Thanks everyone,
Johann

Linked Flash Files With Linked Sounds.
First of all heres my project:
http://athene.riv.csu.edu.au/~jgalvi...ic/Soundcomic/
The big black smudges are buttons, so click the one to the right and the page should load.
My lil problem is that due to other effects I wanted to add I have sound linked within each of these seperate pages.
Each page has several panels, each of which plays a sound when the mouse rolls over it. This sound is played via a:
var snd1 = newsound();
snd1.attachSound("the_sounds_name");
SO each of these pages works fine by itself.
BUt I have made a "loader.swf" page where by clicking on buttons advances them timeline to another page that is loaded into an empty movie clip ("container") using:
container.loadMovie("page3.swf");
SO now when I load this way, the sounds do not play.
Is there anyway around this besides going into each seperate panel movieclip and adding it to their timelines?
PLEASE?!

New Instance Button Doesn't Work, No Apps Listed, But Apps Work
In my admin panel if I click on the New Instance button it doesn't do anything. I've seen other posts about this and they all end up being caused by people having no applications to load, but that's not the case here. My apps are installed and they work fine, but the new instance button doesn't list them and they don't show up in the applications list of the admin panel, even when they're running.

This has to be something pretty simple, but I'm not having any luck figuring it out. Any ideas?

Loader.close Doesn't Work In Flash But Does Work In Flash Player
When testing a movie in flash with simulate download the Loader.close() function doesn't seem to work when trying to cancel a load but it does work in a browser! You'll need to try to load a movie that has sound. The loader looks as if it stops but then the sound that's in the loaded movie will play, proving it hasn't stopped loading

add a button with instance name btnCancel









Attach Code

function onClickbtnCancel(e) {
// damn thing doesn't work in Flash but works online
ldr.close();
/* this stuff isn't even needed
ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, onCompleteHandler);

for (var i:uint=0; i < container.numChildren; i++) {
if (container.getChildAt(i) is DisplayObjectContainer && container.getChildAt(i).name == "movieclip loader") {
container.removeChildAt(i);
}
}
*/
}
btnCancel.addEventListener(MouseEvent.CLICK, onClickbtnCancel);

var container = new Sprite();
var ldr = new Loader();
ldr.name = "movieclip loader";
container.addChild(ldr);
var urlReq = new URLRequest("file.swf");

function onCompleteHandler(e) {
addChild(e.currentTarget.content);
}
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);

ldr.load(urlReq);

stop();

//--------------------On another note. Anyone know why I can't add text format styles to List components?

import fl.managers.StyleManager;

// set style for all components such as the List
var tf = new TextFormat();
tf.color = 0x000000;
tf.font = "Verdana";
tf.size = 14;
//StyleManager.setStyle("textFormat", tf); // <- this works but that's not the point
StyleManager.setComponentStyle(List, "textFormat", tf); // this works fine for a TextArea, just not a List??

























Edited: 07/11/2008 at 10:08:19 AM by Cine-Med

Class SET Function Doesn't Set - Why ?
Hi !
I have no idea where I go wrong ... I already spent several hours on this ...

I have a game class :

class myGame {
private var ball:ballClass;
private var Xposition:Number;

public function myGame(ballMC:ballClass) {

ball = new ballClass(ballMC);

// this works
ball.initBallPosition(Xposition,Yposition);
//this doesn't
ball.set_ballX(Xposition);

}


and the ball class relevant functions (everything here is working well - checked)

private var ballPosition:Object = new Object();

function initBallPosition(posX:Number,posY:Number):Void {

ballPosition.x = posX;
ballPosition.y = posY;
ball.set_ballX(ballPosition.x);
}


public function set_ballX(whichX:Number):Void {
_x = whichX;
}



so the functions work, the ballMC linkage is to the ballClass - it works fine in the initBallPosition() function - which calls the set_ballX function, but not through a direct call - whhhhhhhhhhhhhhhhhhhhhy ? http://board.flashkit.com/board/newt...ewthread&f=30#
Yikes!!

AS Class Doesn't Agree With MovieLoader
I've never posted here before, so if I miss something vital in this that most people post when requesting help, feel free to mention.

Basically, I have one movie (the 'mini-game') which uses two different classes, "Eye.as" and "Target.as". I then have another movie (the 'hub') which loads the first one, the mini-game, via a MovieClipLoader. When I run the mini-game on its own, all is well and good. However, when I run the mini-game through the hub, the Target class just may as well not exist. Constructor, methods, everything, all gone. But, the Eye class works perfectly fine and as it should.

Both classes extend MovieClip and are on the stage within other class-less MovieClips, not through code placement, but design in the WYSIWYG editor (Flash 8 Pro). The mini-game has a beginning frame with nothing but "stop();", and on the hub's MovieClipLoader's onLoadComplete event, the mini-game is sent to its initialization frame, which then sends it to the "instructions" portion (just a bunch of text and some graphics for the player). On which, the player may click a button and be moved onto the actual 'game' portion of the mini-game, which is where the instances of both Eye and Target exist.

Has anyone else run into this before? I've tried having the Target on the stage at the start, just like the Eye, attaching it, or duplicating the targets from one already on the stage. Nothing seems to have any affect on the problem, and the problem only arises when run through the hub.

Any help, comments, criticism, flames or anything else is welcome. I've hit a completely perplexing brick wall on this one. Thanks in advance for anything anyone can offer.

Why Doesn't My Flvplayer Pause With A Class?
ActionScript Code:
class FlvPlayer {    public var videoURL:String;    public var theVideo:MovieClip;    public var nc:NetConnection;    public var ns:NetStream;    function FlvPlayer() {        nc = new NetConnection();        nc.connect(null);        ns  = new NetStream(nc);            }    function playVideo():Void {        theVideo.attachVideo(ns);        ns.play(videoURL);    }    function rewindVideo():Void {        trace("rewind");        ns.seek(0);    }    function pauseVideo():Void {        trace("pause");        ns.pause();    }}

and with


ActionScript Code:
import FlvPlayer.as;var flvplayer:FlvPlayer = new FlvPlayer();flvplayer.theVideo = theVideoSkin;flvplayer.videoURL = "test.flv";flvplayer.playVideo();rewindBtn.onRelease = flvplayer.rewindVideo;pauseBtn.onRelease = flvplayer.pauseVideo;


Now it does play but it doesn't rewind or pause but i do see the corresponding tracing messages???

Any idea

Key Class Doesn't Function In Browser?
Using MX, and only testing with I.E. 5.5, I noticed that utilizing the Key class doesn't function. It works fine in the standalone player, however, not in the browser.

Assume a text box on the stage with instance name t_txt.
This is the code:

ActionScript Code:
var keyListener = new Object();
 
keyListener.onKeyDown = function()
{
    if(Key.isDown(Key.LEFT))
        t_txt.text = "myah";       
};
   
Key.addListener(keyListener);

The text box is populated with the string when the left arrow is pressed. But, that only occurs in the player.

Does anybody know why?
Thanks,
Chris.

I Know This Should Work, But It Doesn't
in a game i'm making i've put this scrip in a movie clip:

onClipEvent (enterFrame) {
for (i=1; i<6; i += 1) {
if (this.hitTest(_root["shot"+i])) {
removeMovieClip (_root["shot"+i]);
this.play();
}
}
}

its just a for loop see if a shot hit the movie clip the shot is removed and the movie clip plays, the clip plays fine but the shot isn't removed (the shot is a duplicated movie clip)

i also tryed to remove the movie clip the shot hit (it was also duplicated) by after the explosion takes place it is removed with this script:

removeMovieClip (this);

but that doesn't work either. can any one help? or has my copy of flash lost the ability to use the "removeMovieClip" command?

With () -- Doesn't Seem To Work
Here is the structure:

movie Clip _level0.ColorBoxX.Highlight (where X is an integer)

and there is a button on the _level0.ColorBoxX

from the 'on (release)' action of a ColorBoxY I want to modify the _visibility of the Hightlight mc on ColorBoxX

so here is my with statement.
Note: _parent.currentColor = the X of the ColorBoxX

with ("_parent.ColorBox" + _parent.currentColor){
Highlight._visible = false;
}

I know that "_parent.ColorBox" + _parent.currentColor evaluates to the proper mc name via doing a trace but the mc visible doesn't go to false (i.e. the mc still shows up)

what am I doing wrong?

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