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




As2.0 OnRollOver In Class Func Cant Access Var



Hi i have a simple class with a private property bgColor and a function that renders a small box on a empty movie clip. I am trying to change the color via onRollOver but whenever i try to pass the bgColor in the onRollOver function i get 0. I am not sure if a defined onRollOver function in a method can access class properties, can anyone take a look. thanks.


ActionScript Code:
//.... container_mc, cellWidth and cellHeight already defined as //class properties...private var bgColor:Number = 0x0023cc;private function createBG():Void{    container_mc.createEmptyMovieClip("bgBox",bgDepth);    container_mc.bgBox.moveTo(0,0);    container_mc.bgBox.beginFill(bgColor);    container_mc.bgBox.lineTo(cellWidth,0);    container_mc.bgBox.lineTo(cellWidth,cellHeight);    container_mc.bgBox.lineTo(0,cellHeight);    container_mc.bgBox.lineTo(0,0);    container_mc.bgBox.endFill();        container_mc.bgBox.onRollOver = function(){                    var cellColorObject = new Color(this);        cellColorObject.setRGB(bgColor);        trace(cellColorObject.getRGB());        delete cellColorObject;    }}  //trace = 0  



Ultrashock Forums > Flash > ActionScript
Posted on: 2004-11-18


View Complete Forum Thread with Replies

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

OnRollOver Mouse Icon Changes - How Do You Access This?
Hello,

I want to access the mouse's state, so that when you roll the mouse over any clickable object the icon of my custom mouse changes.

I could make every item on rollover and rollout send a msg to the mouse to change its icon. but i was hoping that there is a way to access the system mouse properties . Any ideas?

Cheers
Simon.

Unable To Access OnRollOver Event
Hi guys,
I having diificulty triggering an onRollOver event, i think it may have something to do with layers however when i trace using getDepth the panel_insert3_3 clip is above show_page_3.
If you look in the loadsecond() function you will see the panel_insert3_3.onRollOver that is unsuccessfully tracing.
I've posted the code below:

Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.filters.DropShadowFilter;

// Format the Text Box
txtFmt = new TextFormat();
// My Font is specified by the Font in the Library
txtFmt.font = "myFont";
txtFmt.align = "left";
txtFmt.size = 14;
txtFmt.color = "0xffffff";

// Format the Text Box
txtFmt2 = new TextFormat();
// My Font is specified by the Font in the Library
txtFmt2.font = "myFont";
txtFmt2.align = "left";
txtFmt2.size = 14;
txtFmt2.color = "0x000000";


loadall();

function loadall() {

// THIRD NOTE

show_page_3 = attachMovie("page1", "page1", this.getNextHighestDepth());
show_page_3._x = 785 // little note - "Where to find us" x-axis location from left of stage
show_page_3._y = 145 // little note - "Where to find us" y-axis location from top of stage
show_page_3._rotation = 0 // little note - "Where to find us" rotation (positive or negative numbers allowed)
show_page_3._width = 270 // little note - "Where to find us" width of default image
show_page_3._height = 295 // little note - "Where to find us" height of default image

var dropShadow3:DropShadowFilter = new DropShadowFilter(2, 45, 0x666666, 0.5, 5, 5, 2, 3);
show_page_3.filters = [dropShadow3];

panel_insert3 = show_page_3.attachMovie("panel_title", "panel_title3", this.getNextHighestDepth());
panel_insert3._x = -115
panel_insert3._y = -105

panel_insert3.panel_title.setNewTextFormat(txtFmt);
panel_insert3.panel_title.embedFonts = true;
panel_insert3.panel_title.text = "Sports Development";

dart3 = show_page_3.attachMovie("dart", "dart", "101");
dart3._x = -10;
dart3._y = 46;

var myTween_mp:Tween = new Tween (this.show_page_3,"_x", Back.easeOut, -100, 785, 1, true);
var myTween_mp:Tween = new Tween (this.show_page_3,"_y", Back.easeOut, 145, 145, 1, true);

loadsecond();

}

function loadsecond() {

show_page_3.onRollOver = function() {

panel_insert3_3 = show_page_3.attachMovie("panel_title", "panel_title3_3", this.getNextHighestDepth());
panel_insert3_3._x = -115
panel_insert3_3._y = 50

panel_insert3_3.panel_title.setNewTextFormat(txtFmt2);
panel_insert3_3.panel_title.multiline = true;
panel_insert3_3.panel_title.wordWrap = true;
panel_insert3_3.panel_title.embedFonts = true;
panel_insert3_3.panel_title.autoSize = "center";
panel_insert3_3.panel_title.text = "Cricket Development";

var myTween_mp:Tween = new Tween (dart3,"_alpha", Strong.easeOut, 100, 20, 1, true);

panel_insert3_3.onRollOver = function() {
trace("Cricket Development");
};

trace(show_page_3.getDepth());
trace(panel_insert3_3.getDepth());

}

show_page_3.onRollOut = function() {
var myTween_mp:Tween = new Tween (dart3,"_alpha", Strong.easeOut, 20, 100, 1, true);
panel_insert3_3.removeMovieClip();
}

};



Cheers

1119: Access Of Possibly Undefined Property OnRollOver...
I haven't touched Flash since MX 2004 and it's like a whole new learning expirience.

I'm about to stab someone in the eye, so i'd appreciate if someone could help me with the following error:
1119: Access of possibly undefined property onRollOver through a reference with static type flash.display:SimpleButton.

I have a button named btMail and made the code (in a frame):

Code:
btMail.onRollOver=function(){
// btGlass.x-=100;
gotoAndStop(5);
}
So that when it rolls over it should change the position of another button. I tried using the first commented code that in my book should have done the trick (also tried it with a root) and it didn't work. So i figured i'd just make a new frame and change the positions to my liking... Still doesn't work, and i get that damn error code... Aparently i can't just put that code in a button anymore? Well i thought i could apply actions to a button, but i guess not...

Anyways, can someone please help me find the error in my code?
Thanks,
-Steve

Class Question: How To Access Timeline Objects From Class W/o Arguments
Hey all,

I am looking into builiding an application with OO functionality. I understand most of it. Except I cannot figure out how to access something in my app from a class. For instance, lets say I have one Loader class that loads some data and stores it in a variable inside the class (or on the main timeline, doesn't matter). Now, I know I can pass a reference to the data in an argument to another class for that class to manipulate. But if I have several data sources, and other variables and such, that I need to modify in a single class function, how would I do that without having to give the function access to them through arguments? I just want to be able to say, from a class, something like _root.someObject.someFunction();

So, any help would be greatly appreciated, and sorry if that made no sense at all, I tried to explain as best I could.

Happy Holidays!
Dave

Calling SetTimeout Within Custom Class And Cannot Access The Class' Variables
Hi All,

I'm creating an user interface with Flash 8, I'm new to Flash, my background is Java therefore I decided to use ActionScript to create a custom component that is reference within an external file.

My problem I believe is scope related. I have a status bar (label component), once I update the status bar I want to call the
"setTimeout" function to wait a couple of seconds before clearing my status bar. The "setTimeout" function is executing, but for some reason my status bar is not being cleared (accessed).

Below is a snippet of my code. Any help appreciated. Thanks.


/*
External File
*/
import mx.controls.Button;
import mx.controls.Label;

class MyApp
{
//private properties
private var mc_container:MovieClip;
private var btn:Button;
private var lbl_status:Label;
private var str:String = "do see me";

//constructor
public function MyApp(target:MovieClip)
{
trace("-- MyApp --");
mc_container = target.createEmptyMovieClip("mc_container", 100);
}
//public methods
public function init(width:Number, height: Number, xPos:Number, yPos:Number):Void
{
var my_app:MyApp = this;

btn = mc_container.createClassObject(Button, "btn", 1, {label:"click me"});
btn.setSize(100, 25);
btn.move(10, 10);
btn.clickHandler = function():Void
{
trace("btn clicked");
setTimeout(my_app.clearStatus, 2400);
//correct if I call directly
//my_app.clearStatus();
trace(str);
}

lbl_status = mc_container.createClassObject(Label, "lbl_status", 2, {text:"status bar message"});
lbl_status.setSize(200, 25);
lbl_status.move(0, 50);
}
public function clearStatus():Void
{
trace("calling clearStatus");
lbl_status.text = "";
}
}


/*
Called for Flash IDE
*/
var app:MyApp = new MyApp(this);
app.init(200, 200, 0, 0);

Button Created Within Class Cannot Access Class Properties
Hi,
I'm using the following code within a class:
code:
_head_mc.attachMovie("headButton", "head_btn", this.getNextHighestDepth());

_head_mc.head_btn.onRelease = function () {
containingClip_mc._parent._parent.clickedHead(_per sonName);
}


The button gets attached (line 1). This works because I can see the mouse changing to a finger.

The onRelease function is declared and works. I know because if I put a trace in there, it works.

The function it calls (containingClip_mc._parent._parent.clickedHead also works, becuase I can see traces from within it.

But the _personName variable is passed as undefined.

I know that this variable has a value, because I can trace it outside the function, but it seems that this onRelease function is not able to see the variable. It's declared as private, but setting it to public doesn't fix anything.

I imagine there's something I don't understand about the scoping of variables. I've tried _parent references, but that doesn't appear to help either. Is there a better way to do this or a workaround?

Barrette

Added by edit
Okay, I've pretty much determined this is a scoping issue. From the onRelease function, I'm unable to access ANY of the functions within my class. I still would like advice on how to do so..

Barrette

How Do I Access A Variable Declared In My Document Class From Another Class
Hi there,

I'm pretty new to classes and am probably missing something really basic so apologies if this seems like a stupid question.

I'm trying to access a variable that I've declared in my document class from within another class.

I know I can pass the variable through when I call the class as follows:


Code:
var myBall:Ball = new Ball(5);
and pick this up in the Ball function within my Ball class as follows:


Code:
public function Ball(ballSpeed) {
trace(ballSpeed);
}
But what if I don't want to do that as I have a whole load of general global variables I want to access which were defined in my document class?

What I actually want to do is just have access to all the variables defined in the document class from within the Ball class.

I tried parent.variableName and various other ways of accessing what I need but all of them spit back errors.

Any help would be really appreciated - I'm sure this is very basic but I'm totally stuck on this.

Many thanks.
Ian

OnRollOver Help In Custom Class
semi-new to oop, and I'm about to start banging my head against my monitor.

I have a custom class called slide.as. It loads a jpg and places it in a movie clip created on the parent timeline. The class holds a property called slideRef which references the movieclip that the jpg was loaded into. With this.slideRef I have no problem changing the scale or x and y positions of the clips. What I can't do is set an onRollOver function for them. Here's there relavent code...


Code:
class slide{
var slideDir:String;
var slideRef:MovieClip;
var slideNum:Number;
var slideScale:Number;
var centerX:Number;
var distance:Number;
var cl_mc_loader:MovieClipLoader;
var cl_mc_listener:Object;


function slide(slideDir:String, slideRef:MovieClip, slideNum:Number){
this.slideDir = slideDir;
this.slideRef = slideRef;
this.slideNum = slideNum;
this.cl_mc_loader = new MovieClipLoader();
this.cl_mc_listener = new Object();
}

function addSlide(){
this.slideRef._xscale = this.slideRef._yscale = 40; // works fine

this.cl_mc_loader.addListener(this.cl_mc_listener);
this.cl_mc_loader.loadClip(this.slideDir, this.slideRef);
this.cl_mc_listener.onLoadInit = this.onClipLoad();
}
function onClipLoad(){
trace(this.slideRef); // traces _level0.stories.strip.slide0 and .slide1 etc...
this.slideRef._rotation = 45; // rotates all slides 45 degrees
this.slideRef.onRollOver = function(){ // does nothing!!
trace("rolling over");
}
}

etc...
any thoughts would be greatly appreciated.

OnRollOver Help In Custom Class
semi-new to oop, and I'm about to start banging my head against my monitor.

I have a custom class called slide.as. It loads a jpg and places it in a movie clip created on the parent timeline. The class holds a property called slideRef which references the movieclip that the jpg was loaded into. With this.slideRef I have no problem changing the scale or x and y positions of the clips. What I can't do is set an onRollOver function for them. Here's there relavent code...


Code:
class Slide{
var slideDir:String;
var slideRef:MovieClip;
var slideNum:Number;
var slideScale:Number;
var centerX:Number;
var distance:Number;
var cl_mc_loader:MovieClipLoader;
var cl_mc_listener:Object;


function slide(slideDir:String, slideRef:MovieClip, slideNum:Number){
this.slideDir = slideDir;
this.slideRef = slideRef;
this.slideNum = slideNum;
this.cl_mc_loader = new MovieClipLoader();
this.cl_mc_listener = new Object();
}

function addSlide(){
this.slideRef._xscale = this.slideRef._yscale = 40; // works fine

this.cl_mc_loader.addListener(this.cl_mc_listener);
this.cl_mc_loader.loadClip(this.slideDir, this.slideRef);
this.cl_mc_listener.onLoadInit = this.onClipLoad();
}
function onClipLoad(){
trace(this.slideRef); // traces _level0.stories.strip.slide0 and .slide1 etc...
this.slideRef._rotation = 45; // rotates all slides 45 degrees
this.slideRef.onRollOver = function(){ // does nothing!!
trace("rolling over");
}
}

etc...
any thoughts would be greatly appreciated.

HELP : OnRollOver : CreateEmptyMovieClip : Class
Hey all,

Why doesn't the trace "over" work on the below code? Anyone have any ideas?

class custom.myprojectname.load_photos {
public function load_photos(){
var num_img:Number = 8;
var i:Number = 1;
while (i <= num_img) {
_level0.createEmptyMovieClip("MyMC"+i, _level0.getNextHighestDepth());
eval("_level0.MyMC"+i).onRollOver = function() {
trace("over");
}
i += 1;
}
}
}

Thanks
Adam

Custom Class Won't Recognize OnRollOver
I created a custom Class for my menu items so I can manage them easily. The only problem is I want to use, among other things, the onRollOver clip event, but it won't work! I know there is a way to sort of duplicate the MovieClip class (basically copying movie's prototype into my class's, which would allow my class access to the onRollOver event) but I can't for the life of me figure out how. I also think there is a way to make my class a subclass of the movieclip class, but, once again, my memory fails me. I seem to remember something about __proto__ but all my efforts have ended in failure. Can someone help me out?

[help] Custom Class Oop OnRollOver Method
I have a client that I am building an image gallery. There are thumbs and then a custom viewer windo that the thumbs are to send the image location too when they are rolledOVer. The problem is that I do a loader for the fullsize image to load it into cash for each thumb, then scale down the image. Then he wanted it to be black and white images that would go to color when rolled over too.
So I basically have a class that creates a new mc inside of a defined mc. Then inside of that mc I create layers, the lowest is the full sized image that gets scaled down to the black and white image size, the next is a mask layer for it, then after that is the black and white image that doesn't scale down but centers, then there is a mask layer above that.

I can invoke the target_mc.onRollOver = function method, and if I do a trace it will display the info. But if I try to set the thumb movies _visible to false it does not do anything. If i set the _visible to false outside of the onRollover method it makes the black and white photo not visible.

So for some reason when I put the _visible in the target_mc.onRollOver = function method it is not making the black and white image invisible.

Can anyone look at my ImageViewerThumb.as and see what is wrong, it's super script is ImageViewer.as which I will include. Maybe I need to have it extend MovieClip too?


opps, can't attach .as so I will post in in next post

Problem With OnRollOver In Class File
I am working with a class object and am having a problem with the onRollOver event triggering. My code in the class file is as follows:


Code:
class ScrollItem extends MovieClip{
function ScrollItem(){
trace("test");
this.onRollOver = function () {
trace ("onRollOver called");
};
}
}
"test" fires, but "onRollOver called" does not when I mouse over the movie clip. I have also noticed that the mouse cursor for the entire movie is a text selector icon and not the pointer or hand icon. To my knowledge, there are no text boxes behind or in front of the movie clips. This is a single frame flash movie where the class-linked movie clips are scrolled by an onEnterFrame event from the main time line.

Any ideas on where this problem could be coming from or places to start looking? Let me know if this is not enough information.

Thanks,

[AS2] Using MovieClip OnRollOver For MyButton Class
I'm creating MyButton class using the MovieClip class. The problem is getting onRollOver to reDraw MyButton. The scope appears to be wrong, please help. This is a simplified version to represent the problem.

// Menu.fla
//Create an Instance of MyButton

var b:MyButton = new MyButton();

//MyButton.as Class

class MyButton{
private var mc:MovieClip;
public var xPosition:Number;
public var yPosition:Number;
public var width:Number;
public var height:Number;
public var fill;

//Construct MyButton
public function MyButton(){
create();
drawRect(0, 0, 100, 22, 0xccddaa);
drawOver();
}

//Create MovieClip Instance
private function create():Void {
mc = _root.createEmptyMovieClip("buttonx", 0);
}

//draw MyButton Shape
private function drawRect(xPosition, yPosition, width, height, fill) {
var ax = xPosition+width;
var ay = yPosition;
var bx = xPosition;
var by = yPosition+height;
mc.clear();
mc.beginFill(fill, 90);
mc.lineStyle(1, 0xccddee);
mc.moveTo(xPosition, yPosition);
mc.lineTo(ax, ay);
mc.lineStyle(1, 0xccddee);
mc.lineTo(ax, by);
mc.lineStyle(1, 0xccddee);
mc.lineTo(bx, by);
mc.lineStyle(1, 0xccddee);
mc.lineTo(bx, ay);
mc.endFill();
}

//reDraw MyButton onRollOver
private function drawOver(){
mc.onRollOver = function(){
drawRect(0, 0, 100, 22, 0x000000);
}
}
}

[AS2] Using MovieClip OnRollOver For MyButton Class
I'm creating MyButton class using the MovieClip class. The problem is getting onRollOver to reDraw MyButton. The scope appears to be wrong, please help. This is a simplified version to represent the problem.

// Menu.fla
//Create an Instance of MyButton

var b:MyButton = new MyButton();

//MyButton.as Class

class MyButton{
private var mc:MovieClip;
public var xPosition:Number;
public var yPosition:Number;
public var width:Number;
public var height:Number;
public var fill;

//Construct MyButton
public function MyButton(){
create();
drawRect(0, 0, 100, 22, 0xccddaa);
drawOver();
}

//Create MovieClip Instance
private function create():Void {
mc = _root.createEmptyMovieClip("buttonx", 0);
}

//draw MyButton Shape
private function drawRect(xPosition, yPosition, width, height, fill) {
var ax = xPosition+width;
var ay = yPosition;
var bx = xPosition;
var by = yPosition+height;
mc.clear();
mc.beginFill(fill, 90);
mc.lineStyle(1, 0xccddee);
mc.moveTo(xPosition, yPosition);
mc.lineTo(ax, ay);
mc.lineStyle(1, 0xccddee);
mc.lineTo(ax, by);
mc.lineStyle(1, 0xccddee);
mc.lineTo(bx, by);
mc.lineStyle(1, 0xccddee);
mc.lineTo(bx, ay);
mc.endFill();
}

//reDraw MyButton onRollOver
private function drawOver(){
mc.onRollOver = function(){
drawRect(0, 0, 100, 22, 0x000000);
}
}
}

Problem With OnRollOver And Multiple Tween In A Class
I am kind of a newbie and I am having trouble with an onRollOver function that includes a scripted tween in a class file. When you roll over the movieclip it seems to detect an onRollOver evertime it starts the tween. Is this a problem with the hitArea? Any help would be apprectiated.

here are the files: http://www.wiseguysink.com/test_files.zip

Actionscript Access Class Within A Class
Hey there, well i have 3 files I am working with:

homesite.fla
MainScript.as
AnotherScript.as

In homesite.fla i have

Code:

var main:MainScript = new MainScript ();



in MainScript.as I have

Code:

class MainScript{
public var small_var:Number = 2;
function MainScript(){
}
}



in AnotherScript.as I have

Code:

class AnotherScript extends MovieClip{
function AnotherScript(){
change_setting(10);
}
public function change_setting(numb){
_root.main.small_var = numb;
}
}



the issue i have now, i can edit everything in the "main" variable from within the .fla so if i wanted to change small_var I can do something like:


Code:

main.small_var = 10;



however the issue comes when i try to do that inside another class like in "anotherscript.as" i cannot do it. I am fairly new to actionscript I come from a PHP background, the way i would do it in PHP would be to use a global variable and pass that inside the function, i tried using _root. to see if that would work, but it doesnt really. I did create the variable inside the function, however that would only create one instance used in that function, so that really doesn't help, hoepfully i didn't make this to confusing. Thanks in advance.

Huh?: MyFunc = {func:func, Scope:scope, Args:args }
Hi,
I've seen this strang syntax used for functions (I think that's what I've seen anyway). Things like:

Code:
myFunc = {func:func, scope:scope, args:args };
in the above I think func is a function and scope is the critter that is supposed to call the function and args are the arguments? But I dont really understand how it works. How do you call myFunc in the above? How do you write a function using this syntax?

Or am I totally off here?

Can anyone help?

Access Class Defined In "linkage..." From External Class
Hi

Rather strange title hu? Well, I'm trying to access a class which was defined on a library symbol in my main.fla by using the Linkage... dialog. Classname: GrungeTitle, BaseClass: BitmapData.

I'm trying to access this class to build my repeating background on my main.fla (which uses a document class: base.as).

My code of the document class:

Code:
public function init():void {
grungeBackgroundTile = new GrungeTile(300, 300);

var spr:Sprite = new Sprite();
spr.graphics.beginBitmapFill(grungeBackgroundTile);
spr.graphics.drawRect(100, 100, 100, 100);
spr.graphics.endFill();

addChild(spr);
}
This code gets called on the third frame of my main.fla by calling: init();
When I try to draw a simple square in the sprite, the rectangle gets drawn on the stage, when I try to make a fill with a library item then it doesn't display a thing.

Any help?
Thanks

Access A Class From Another.
hi,

I created several classes.
I create several instances of theses classes in the main class.

What is the most simple way to call an instance of a class from another class ?

Example :
This is in main.as

ActionScript Code:
var userInstance:User=new User();
var connctionInstance:Connection=new Connection();

In User class I have a login() method that require to use the connection object created in main.as.

Note that this connection object will be unique for the animation. May I declare it as STATIC in the main class ?

What is the proper way to do it ?

I'm missing the Global object of AS2, it was too easy to use !

Access Class With In Sub MC
Hi all

I have import tween class on the first frame
like this

ActionScript Code:
mport mx.transitions.Tween;
import mx.transitions.easing.*;

Now when I put the following code on the same frame it works


ActionScript Code:
var gfBX:Tween  = new  Tween(gf, "blurX", Elastic.easeOut, 5, 5, 1, true);

but if the I put the similar code in side a Movie clip then it doesn't. But if i import the tweens again inside the Movieclip then it works.

So does it means, I have to import tweens multiple times inside the sub movie clips where ever I want to use the tweens.

Thanks

AS3 - Access A MC By It's Class Name
I have a movieclip on the stage with the class name "Yellow". How do I access it in my Document Class? This is what I have so far

Code:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.media.Sound;
import gs.TweenMax;
import gs.easing.*

public class Wheel extends MovieClip
{
var snd1:Sound = new Sound1();
var snd2:Sound = new Sound2();
var snd3:Sound = new Sound3();
var snd4:Sound = new Sound4();

public function Wheel()
{
this.addEventListener(MouseEvent.MOUSE_DOWN, down);
this.addEventListener(MouseEvent.MOUSE_UP, up);
this.buttonMode = true;
}

private function down(event:MouseEvent):void
{
TweenMax.to(this, .15, {glowFilter:{color:0x000000, alpha:.4, blurX:8, blurY:8, inner:true}});
if (Yellow)
{
snd1.play();
}
if (Orange)
{
snd2.play();
}
}

private function up(event:MouseEvent):void
{
TweenMax.to(this, .15, {glowFilter:{color:0x000000, alpha:0, blurX:8, blurY:8, inner:true}});
}
}

}

Access DataGrid From Own Class
Hello guys,

I have the problem to access all methods of a DataGrid instance within my own class.

System: Flash 8, AS2

I have two files:

mp3Player.as
mp3Player.fla

The scene is simple:

Library consists of the DataGrid component and one movie clip. In the movie clip is an instance of the DataGrid component with instance name playList. An instance of the movie clip is placed in the scene and the movie clip has been linked to the mp3Player class in the as file.

The mp3Player class is very simple. It contains a DataGrid variable playList and a constructor to initialize the DataGrid playList in the scene.

What the constructor can do is e.g. playList._visible=false or playList.setStyle(...). But as soon as i start with playList.addColumn or playList.addItem it does not work..

What am I doing wrong?

schnizZzla

Can't Access Class Member
Anyone have any thoughts on why the loadImage() method of the attached class (SmartImage.as) can't access the class's loadListener property? I have a suspicion that it has something to do with the funky way the object is instantiated (necessitated by the fact that the class is extending MovieClip).

Rys

Access To Surrounding Class...
Hi there,

I got the following code:


Code:
function playFolder(folder) {
var lv:LoadVars = new LoadVars();
lv.onLoad = function(ok) {
if (this.tracks>0) {
for (var i=1; i<=this.tracks; i++) {
_root.debug=""+(addSong);
addSong(this["track_"+i], this["track_"+i]);
}
start();
}
}
lv.load("http://"+host+"/playlist");
}
addSong and start are methods from the same class as playFolder is in. But I see not possibility to call the addSong from inside this method. this reffers to the loadVars object root referrs to the main timeline.
Can anyone help?

Thank you

Access Movieclip From Another Class
I have a movieclip on the stage "box" - preferences are set to automatically declare stage instances

I can access "box" from the main class, but not from other classes. I know I have to expose "box" so the other classes can see it

and I know it must be simple to do, but I just don't yet know how to do it

Any help greatly appreciated

How To Access MainTimeline From Class
The title says it all, I have a .as class which calls an event function. When the event fires, I'd like the MainTimeline to play... Should be easy no?

Access Class Objects
If i have a parent item that initializes the custom class ObjectTimer. and within ObjectTimer i define an object in the class body with:


ActionScript Code:
public var CloseAPrimary:Object={scaleX:.5,scaleY:.5,time:1,transition:"easeOutElastic", _blur_blurX:100, _blur_blurY:100};

how dould i access a CloseAPrimary in the parent item? I'd like to pass that object to a custom function similar to.

so like foo(CloseAPrimary);

Access Class Functionalities Between Swf
Hi,

I'm starting my first AS3-based website... and I discover how much AS3 questions my day-to-day coding habits.

I'm used to separate the code from the graphics, using a main swf having all the code and launching the visual content produced by the designers. In AS2 I use _global to give access to the main classes or methods, so the designers can use these tools from their "content" swfs without needing the actual code folder at compile time. For example:

In Main class:

ActionScript Code:
_nav:Nav = new Nav();
_global.nav = _nav

In a loaded swf:

ActionScript Code:
_global.nav.changeContent("chapter2.swf");

How can I do the same in AS3? If I try this last code in AS3, I'll have a runtime error saying that the variable _global is not defined...

So is there a way (ideally other than a LocalConnection) to access class functionalities accross several swf, without needing the source of theses classes at compile time?

URLLoader In Class > Access
hello!

i have a class where i fetch some XML data from an external file.
on the main stage, i instantiate the class and call a function to do the external file loading.

my problem now is, that the main stage doesnt know when the loading process is finished. inside the class i do it with the COMPLETE event but i dint know how to wait for that on the main stage so i thought i might return the data in th COMPLETE handler. however, i dont really find the right sntax for that.

can somebody help me with this problem?

here is my code
-------------------------------------------------
package
{
import flash.events.*;
import flash.net.*;


public class Lang
{

private varlangFile = this.loaderInfo.parameters.lang;

public function getVars(folderRoot:String):void {
var xmlURLLoader:URLLoader = new URLLoader();
var xmlURLRequest:URLRequest = new URLRequest(folderRoot + "lang/" + langFile);
xmlURLLoader.load(xmlURLRequest);
xmlURLLoader.addEventListener(Event.COMPLETE , dataLoaded );

function dataLoaded(event:Event):void {
var langVars:XML = new XML (xmlURLLoader.data);
return langVars;
}
}

}
}

How To Access MC By Instance Name From Within A Class?
I have an app that has some display objects already on the stage in the .fla. Let's say I have a text field with the instance name myTitle on the stage. If I want to access that text field (or any other named instance on the stage) from within a class that I'm writing, how do I do so? I would normally just use:

myTitle.text = "new text";

but I don't seem to be able to access instance names this way. I've tried making the class a display object and adding it to the stage/display list to see if that would help, but I have the same problem. How do I go about doing this?

Thanks in advance...

How Do I: Access Instance From Class.
how do i access a movieclip instance in the main FLA file from a class file imported by the main FLA file?

i'd like to addChild() to a movieclip instantiated in the FLA from a class file.

How To Access MC On Stage In A Class?
Hi there.
I have my custom Class, and some movieclips on Stage.
How could I access them from the class?

Let's say, we've got a MC on Stage called "bubble", and example class:

ActionScript Code:
myClass
{
  public function myClass (
    // How I can access "bubble" MC here?
  }
}

How To Access SoundChannel From Different Doc Class ?
I have a loader.swf and a main.swf, in the loader.swf I'm preloader the main.swf and an mp3 file. What I'd like to do is to somehow access the sound channel object from the loader.swf's document class and manipulate it in the main.swf file.

I tried setting up a static getter method but if I do so, then whenever I'm trying something like:


ActionScript Code:
package com.wisebisoft
{
    import com.wisebisoft.loaders.MainLoader;
   
    import flash.display.MovieClip;
    import flash.events.Event;
   
    public class MainClass extends MovieClip
    {
        public function MainClass()
        {
            addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
        }
       
        private function addedToStageHandler(event:Event):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
           
            trace(MainLoader.soundChannelObject);
        }
    }
}
It is throwing errors: type not found... undefined method... but all these from the MainPreloader class... How to solve this?

Because it seems that instead of only checking for my static getter it's running trough all the code and well, since some objects only exist in the MainLoader class, it's normal that it can't find them but why is it even checking them ?

Thanks.

AS 2.0 Can't Access A Variable In My Class
All my variables are set in the top of my class. But undefined if I trace them in my onenterframe function. Why he doesn't read them? What i do?








Attach Code

class clsAlbum {
var dragging:Boolean = false;
var friction:Number = 0.82;
var bounce:Number = 0;
var gravity:Number = 0;
var top:Number = 0;
var left:Number = 0;
var bottom:Number = Stage.height;
var right:Number = Stage.width;
var mvcAlbum:MovieClip;
var vx:Number = 0;
var vy:Number = 0;
var oldX:Number = 0;
var oldY:Number = 0;

function clsAlbum(mvc:MovieClip, object) {
vx = Math.random()*10-5;
vy = Math.random()*10-5;

mvcAlbum = mvc.attachMovie("mvcAlbum", "mvcAlbum"+object.number, mvc.getNextHighestDepth());
mvcAlbum._x = randRange(-10, 200);
mvcAlbum._y = randRange(100, Stage.height-mvcAlbum._height);
mvcAlbum._rotation = randRange(-40, 40);
mvcAlbum.onEnterFrame = function() {
if (!dragging) {
vy += gravity;
vx *= friction;
vy *= friction;
this._x += vx;
this._y += vy;
if (this._x+this._width/2>right) {
this._x = right-this._width/2;
vx *= bounce;
} else if (this._x-this._width/2<left) {
this._x = left+this._width/2;
vx *= bounce;
}
if (this._y+this._height/2>bottom) {
this._y = bottom-this._height/2;
trace(this._y);
vy *= bounce;
} else if (this._y-this._height/2<top) {
this._y = top+this._height/2;
vy *= bounce;
}
} else {
vx = this._x-oldX;
vy = this._y-oldY;
oldX = this._x;
oldY = this._y;
}
};
}
function randRange(min, max):Number {
var randomNum = Math.round(Math.random()*(max-min))+min;
return randomNum;
}
}

Cross-class Access
Just trying to get some fundamental access to properties across classes. Seems like this should be very straight forward!

I have one class (Node) that has a function that creates an instance of another class (Pointer). Node is able to set some properties of Pointer at some times, but at others times is not.

In Node, the Pointer is declared and created here successfully, and successfully prescribes the "hide" value to "true".

public var pointer:Pointer; // (in constructor)

// ADD POINTER ////////////////////////////////////////////////////////////////////////
public function addPointer():void {
pointer = new Pointer({appNode:this, app:app});
pointer.name = "pointer";
pointer.hide = true;
app.container.addChild(pointer);
}

But then when I want to change the value of "hide" to "false", I get an error. "pointer" should be available globally. Why does it appear that it is not?

// DISPLAY POINTER ////////////////////////////////////////////////////////////////////////
public function displayPointer(mode:Boolean) {
pointer.hide = true;
// produces error: 1119: Access of possibly undefined property hide
// through a reference with static type flash.display:DisplayObject
// or pointer.hide = mode;

// this also does not work:

//var rPointer:DisplayObject = app.container.getChildByName("pointer");
//rPointer.hide = false;
}

This is another function in Node that works to remove Pointer. I tried something similar in displayPointer, but it did not work either.

// CLOSE WINDOW ////////////////////////////////////////////////////////////////////////
public function closeWindow():void {
// remove pointer
var rPointer:DisplayObject = app.container.getChildByName("pointer");
app.container.removeChild(rPointer);
// remove window
var rWin:DisplayObject = app.container.getChildByName("window");
app.container.removeChild(rWin);
app.winOpen = false;
}

Access DataGrid Within Own Class
Hello guys,

I have the problem to access all methods of a DataGrid instance within my own class.

System: Flash 8, AS2

I have two files:

mp3Player.as
mp3Player.fla

The scene is simple:

Library consists of the DataGrid component and one movie clip. In the movie clip is an instance of the DataGrid component with instance name playList. An instance of the movie clip is placed in the scene and the movie clip has been linked to the mp3Player class in the as file.

The mp3Player class is very simple. It contains a DataGrid variable playList and a constructor to initialize the DataGrid playList in the scene.

What the constructor can do is e.g. playList._visible=false or playList.setStyle(...). But as soon as i start with playList.addColumn or playList.addItem it does not work..

What am I doing wrong?

schnizZzla

Can't Access Class Member
Anyone have any thoughts on why the loadImage() method of the attached class (SmartImage.as) can't access the class's loadListener property? I have a suspicion that it has something to do with the funky way the object is instantiated (necessitated by the fact that the class is extending MovieClip).

Rys

Access Document Class
how to access document class (methods, properties) from an external .swf

Access Data From Another Class?
Hello all --

So I have two classes (classes.XMLLoader) and I am trying to access the xml data from (classes.ActionScripts), but I only get null returned? The loader.Data() of classes.XMLLoader is run before xml/movies.xml has been loaded.



Code:

public function ActionScripts() {

var loader:XMLLoader = new XMLLoader("xml/movies.xml");

trace( loader.Data() ); // null

}

I am sure I will need to use addEventListener, but I have done so without success so far...

Any guidence would be grrrreat!


Thank you,
Jon

AS3 - How To Access A Class Without DisplayObject?
Hello,

I'll "try" to explain as clear as I can...

I've created two classes: ABC and XYZ

The class ABC extends Sprite and I declare it like this:


Code:
for (var i:int=0; i<5; i++) {
var abc:ABC = new ABC();
abc.name = "abc_"+i;
abc.setData(i);
this.addChild(abc);
}
If I want to have access to it, I do something like this:


Code:
for (var j:int=0; j<5; j++) {
trace(ABC(this.getChildByName("abc_"+j)).getData());
}
The class XYZ it's a "standalone" class that does not extends or import any other class, and here it is how I declare it:


Code:
var xyz_01 = new XYZ();
xyz_01.addValue('anyValue');

trace(xyz_01.getValue());
BUT, if I can't figure how to declare it and/or reference to it dynamically.


Code:
for (var i:int=0; i<5; i++) {
this['abc_0'+i] = new XYZ();
this['abc_0'+i].addValue('anyValue');
}

for (var j:int=0; j<5; j++) {
trace(this.getChildByName('abc_0'+j).getValue()); // seems that getChildByName does not work because it the object doesn't have a name and is not added as a child on the stage
trace(this['abc_0'+j].getValue()); // this one only works if I replace the "j" for a "4" (abc_04 was the last one created) otherwise I get "TypeError: Error #1010"
}
So, it could be declared correctlt, but since I can't use their methods I cannot tell, any clues on this?

regards.

Can't Access Number Var In My Class
Hiya, thanks for checking my post. I am really confused as what I am trying to do is so simple!
All I want to do is increment a counter every time a movie loads. I have a method (updateMovie) that is passed an MC and the url of the swf to load into it. My loader listener object then triggers another method that should count the number of movies loaded. For some reason I can't access my counter ('loaded').
If anyone can point out where I am going wrong here I would be really really grateful as I can't understand this at all.
Thanks for any help
Schm

Here is some of the code from within my class:

ActionScript Code:
private var loaded:Number = 0;    //loads passed swf into mc     private function updateMovie(mc:MovieClip, url:String) {        var mclListener:Object = new Object();        mclListener.onLoadInit = mcLoaded(mc);            var image_mcl:MovieClipLoader = new MovieClipLoader();        image_mcl.addListener(mclListener);        image_mcl.loadClip(url,mc);            }    //trigggered when mc is loaded    private function mcLoaded(mc:MovieClip) {        trace("loaded:"+loaded);//traces undefined        trace("mc loadeed:"+mc);                if (loaded<update_ar.length) {            loaded++;            trace("loaded:"+loaded);        }else{            trace("all loaded");        }    }

Access To The Document Class
How can I access the document class from my other classes? Creating a new instance of it seems to be impossible.

Access Class Return Value
OK, this is a follow-up to a recent post (for those who might recognize it).

I'm very confused about what I THINK is probably a simple concept. I want to send a value to a class and use the class's return value. Below is an example, and I want to make sure you understand, THIS IS NOT what I'm actually trying to do -- it's just a very simple example of what I'm not able to do, and if I can answer this question hopefully I can extend the solution to my "real" project.

Here's my AddFour class, which simply adds four to the number I passed to it:

PHP Code:



package { public class AddFour {   private var _num:Number;  public function AddFour(num:Number):void {   _num = num;   init(_num);  }  private function init(_num:Number):Number {   return _num + 4;  } }} 




My problem is, I don't know how to get to the returned value. How do I do that?

To wit: In my .fla file, I have this:


PHP Code:



var foo:AddFour = new AddFour(7); 




If I add a few traces, I see that AddFour successfully adds four to seven to get 11. So far so good.

But what do I do in my .fla file to get a variable whose value is what AddFour returns?

BTW, if I follow the above line in my .fla file with


PHP Code:



trace("foo = " + foo); 




...my trace is...


PHP Code:



foo = [object AddFour] 




This makes sense to me. Again, I assume the answer is pretty simple and I'm just missing something fundamental. What I'm looking for is a line of code that will let me define a variable whose value will be the return value of AddFour. (And PLEASE don't advise me to just do the math in my head. =) )

Thanks!

Access Stage From Class
Hi

I have a package, with classes, functions etc. Basically i need to tell some movieclips on the stage to be visible etc but using this.MyMCName obviously doesn't work. How do i reference movieclips from within a class?

Access Other Class' Variables
Hello Everyone,

I am making a tileMap class which copies bitmapdata from one location to another. I am storing all my tile-sheets as static bitmapdata objects in an Assets class. Would it be faster/ better practice to copy the tile-sheet I am using to the tileMap class instead of referencing the assets class multiple times every frame? Also the map array which stores the tile reference is stored as a static property in a map class, could I achieve better performance by duplicating this array in the tileMap class?

Thanks

Spir

Access Stage From Class
I've gone through the Access to stage and root post in the AS3 Tip of the Day thread and it's put some perspective into how things work and have changed however I just can't get the syntax right... Here's what i've got

Code:
function onUpper(event:MouseEvent):void{
switch(holder.name){
case "one" :
var startx:Number = holder.x;
var finishx:Number = holder.x+100;
//var whichclip:MovieClip = holder;
var whichclip:MovieClip = root.content_mc;
//trace(whichclip);
var xTween:Tween = new Tween(whichclip, "x", Regular.easeOut, startx, finishx, .5, true);
trace("first one")
break;
this is inside of my external class, basically this runs inside of a function that creates buttons which will be my navigation. the second declaration of "whichclip" is where i need help. it's pretty obvious what i'm trying to do and what i'm doing wrong if you're up to speed with AS3. any help is greatly appreciated. thanks.

How Do I: Access Instance From Class.
how do i access a movieclip instance in the main FLA file from a class file imported by the main FLA file?

i'd like to addChild() to a movieclip instantiated in the FLA from a class file.

How To Access A TextArea From A Class Definition?
Code:
import mx.controls.TextArea;
class printClass extends MovieClip {
// define vars
var printArea_mc:MovieClip;
var print_txta:TextArea;
var test_txt:TextField;
var myText:String;
var print_btn:mx.controls.Button;
var myPrintJob:PrintJob;
//
function printClass() {
//this returns correctly
trace(printArea_mc.print_txta._name);
//none of this works
this.printArea_mc.print_txta.label.text = "myText";
printArea_mc.print_txta.label.text = "myText";
this.printArea_mc.print_txta.text = "myText";
printArea_mc.print_txta.text = "myText";
trace(this.printArea_mc.print_txta._vPosition);
//populating a normat text field works
this.test_txt.text = "myText";
}
}
I have tried a dozen different approaches to this with no luck. The problem is that I CANNOT access any of the TextArea specific properties for with in this class definition. Everything was working fine before I ripped the code off the main time line and put in in a class. I cannot set/get the text or any other property.

I think that the problem is that I am not correctly "strict typing" the TextArea var. I suspect that the class thinks that it is a MovieClip. I have tried several options for the type: MovieClip, TextField, mx.controls.TextArea, MovieClip.mx.controls.TextArea, MovieClip.TextField, etc.

Do I need to set the nest or something?
like:
var printArea_mc.print_txta:TextArea; OR
var printArea_mc[print_txta]:TextArea; OR
var printArea_mc:MovieClip.print_txta:TextArea;
or something

pls help.
Any ideas?

thanks for help

--mm

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