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




Object-Oriented Scrollbar: Part 2 - Loading Problem



Hihappy to be part of Lee family i tried the tutorial on gotoandlearn.comthe Object-Oriented Scrollbar: Part 2 tutorialevery thing is finebut, when i load the swf to main.swf- i can scrol the scroller, but not the content- i got this errorTypeError: Error #1009: Cannot access a property or method of a null object reference.at com.leebrimelow.ui::ScrollBar()at flash.display::Sprite/constructChildren()at flash.display::Sprite()at flash.display::MovieClip()at com.leebrimelow.ui::ScrollBox()at flash.display::Sprite/constructChildren()at flash.display::Sprite()at flash.display::MovieClip()TypeError: Error #1009: Cannot access a property or method of a null object reference.at com.leebrimelow.ui::ScrollBox()at flash.display::Sprite/constructChildren()at flash.display::Sprite()at flash.display::MovieClip()the scenario is:- the main time line play and stop at 56.- at 56 the main.swf loads the sec1.swfany help please to fix this probThanks in advance



Actionscript 3.0
Posted on: Sat Jan 31, 2009 1:22 pm


View Complete Forum Thread with Replies

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

Scrollbar Doesn't Work (tutorial: Object-oriented Scrollbar)
(tutorial --> object-oriented scrollbar: http://www.gotoandlearn.com/play?id=71).

I followed the tutorials instructions and this is the code that i have now:

import caurina.transitions.*;

var yOffset:Number;
var yMin:Number = 0;
var yMax:Number = sb.track.height - sb.thumb.height;

sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
stage.addEventListener(MouseEvent.MOUSE_DOWN, thumbUp);

function thumbDown(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
yOffset = mouseY - sb.thumb.y;
}

function thumbUp(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}

function thumbMove(e:MouseEvent):void
{
sb.thumb.y = mouseY - yOffset;
if(sb.thumb.y <= yMin)
sb.thumb.y = yMin;
if(sb.thumb.y >= yMax)
sb.thumb.y = yMax;
var sp:Number = sb.thumb.y / yMax;
Tweener.addTween(content, {y:(-sp*(content.height-masker.height)),
time:1});
e.updateAfterEvent();
}

Does anybody see what's going wrong? I'm a beginner beginner, so all could think of to do is check if everything was typed correct. (i double checked instance names and code). But can't seem te get it to work, nothing happens when i preview swf.
No compilers errors and no syntax error. Tweener class is installed properly. PLEASE help me i've been looking for hours now.
If someone could help me, would be great!!

Sorry for my english, thank you for your time.

Object Oriented Scrollbar Bug
So, I was modifying the code from Lee's Scrollbar tutorial. Trying to do a scrollbar so I could use it with dynamic content. However whenever I click on the thumb and scroll the content never goes back to the top position. So the top image is cut off half way. I think it is a great scrollbar but for some reason it just isn't working.

Any Ideas why it would do this?

I first on the timeline of my swf, I put this code. to create a ScrollBox
Code:

import ScrollBox;
import ScrollBarEvent;

var myScrolling:ScrollBox = new ScrollBox(sb, contentMC, masker);
addChild(myScrolling);

Then here is the scrollBox Code

Code:

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

   
   public class ScrollBox extends MovieClip
   {      
   private var myScrollBar:MovieClip;
      private var myContent:MovieClip;
      private var myMask:MovieClip;
      private var conPos:Number
   
      public function ScrollBox($scroll:MovieClip, $content:MovieClip, $mask:MovieClip):void
      {
         myScrollBar = $scroll;
         myContent = $content;
         myMask = $mask
         myScrollBar.addEventListener(ScrollBarEvent.VALUE_CHANGED, sbChange);
      }
      
      private function sbChange(e:ScrollBarEvent):void
      {
         
         conPos = -e.scrollPercent*(myContent.height- myMask.height)
         
         Tweener.addTween(myContent, {y:(conPos),  time:1});
         

      }
      
      
   }
}


Here is the ScrollBar Code
Code:

package
{
   import flash.display.*;
   import flash.events.*;
   
   public class ScrollBar extends MovieClip
   {
      private var yOffset:Number;
      private var yMin:Number;
      private var yMax:Number;
      
      public function ScrollBar():void
      {
         yMin = 0;
         yMax = track.height - thumb.height;
         this.addEventListener(Event.ADDED_TO_STAGE, init)
   
      }
      
      private function init(event:Event):void {
         thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
      }
      
      private function thumbDown(e:MouseEvent):void
      {
         stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
         stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);
         yOffset = mouseY - thumb.y;
      }

      private function thumbUp(e:MouseEvent):void
      {
         stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
      }

      private function thumbMove(e:MouseEvent):void
      {
         thumb.y = mouseY - yOffset;
         if(thumb.y <= yMin){
            thumb.y = yMin;}
         if(thumb.y >= yMax){
            thumb.y = yMax;}
         //trace(thumb.y);
         
         dispatchEvent(new ScrollBarEvent(thumb.y / yMax));
         e.updateAfterEvent();
         trace(thumb.y/yMax);
      }
   }
}

Object Oriented Scrollbar
ok,

so I implemented the scrollbar from the tutorial in my site, which works nice. But now I would like to add up and down buttons in addition to the handlebar. It shouldn't be too hard i guess, but since i'm not so experienced I need some help with this...

ideas anybody...? Where to start?

thnx,

niels

Object-Oriented Scrollbar
Okay, I solved the mystery. It seems Dynamic Text does not show up through masks...

How do I get that to work then? I changed it to static, but I need dynamic...

Object Oriented ScrollBar At Gotoandlearn
I've been a total fan of http://www.gotoandlearn.com for a long time now. I learned about it in the first place from these forums here, quite some time ago, too. Now that Lee Brimelow is getting into Actionscript 3.0, the site just keeps getting better. Yesterday I watched the two topmost tutorials there (the Object Oriented ScrollBar ones); I even watched the second one twice. I was kind of awestruck. The guy is a genius, and he's a great teacher. It was an eye-opener about OOP for me (not that I've "arrived" yet).

So here's the deal: I have been getting into programming with classes more and more, but I don't have any OOP background or training, except for self-teaching. So you can know how to make classes and packages and how all that works, but then the question becomes what kind of classes of objects should you make so that they are reusable and work together well. Also, what kind of division of labor should you use, like, what should ideally be the responsibilities of each class.

These two video tutorials seem like they've filled a gap in my knowledge and skill set. For one thing, they explain how to create a custom event class and make the scroll bar class use it to broadcast the position of the thumb so that outside code can use it. Now I understand better the role of the event object, even how the existing flash classes implement it.

I just thought I'd pass this along. This is sure to help someone, somebody needs this...

Preloading Object-Oriented Scrollbar V1 And V2
Hi Folks
I got problems when using the OOS with a Preloader.

original OOS V1 works when preloading.
original OOS V2 with external classes , doesn t work propably.
The Scrollbar works, but the content doesn t scroll anymore!

I tried several loader concepts like:

import fl.containers.UILoader;

var aLoader:UILoader = new UILoader();
aLoader.source = "prototype2.swf"; // this is my name for the OOS V2
aLoader.scaleContent = false;
addChild(aLoader);

aLoader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event) {
trace("Number of bytes loaded: " + aLoader.bytesLoaded);
}


or

package {
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.events.*;
import flash.net.URLRequest;

public class LoaderInfoExample extends Sprite {
private var url:String = "prototype2.swf";

public function LoaderInfoExample() {
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
var request:URLRequest = new URLRequest(url);
loader.load(request);
addChild(loader);
}

private function initHandler(event:Event):void {
var loader:Loader = Loader(event.target.loader);
var info:LoaderInfo = LoaderInfo(loader.contentLoaderInfo);
trace("initHandler: loaderURL=" + info.loaderURL + " url=" + info.url);
}

private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
}
}


Always I got the following message:
Error #1009: Cannot access a property or method of a null object reference
at com.leebrimelow.ui::ScrollBar$iinit()
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
at com.leebrimelow.ui::ScrollBox$iinit()
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
Error #1009: Cannot access a property or method of a null object reference
at com.leebrimelow.ui::ScrollBox$iinit()
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
Number of bytes loaded: 59746

Sorry, I m sure this must be discussed already, but I couldn t find any answer

(SOLVED) Object-Oriented Scrollbar 1 Question
I am a beginner in flash coding and I was following the video Object-Oriented Scrollbar 1

At the end of the code where

Tweener.addTween(content, {y:(-sp*(content.height-masker.height)), time:1});

Where the tweener was used in there…. However
It does not work for me I am not sure why...
I have followed the code many times and have no idea why it does not work

I have downloaded the caurina package and have the scroll bar moving and everything but when it comes to that code
it is no longer working.

any help will be great.

this is my code ...

Code:

import caurina.transitions.*;

var yOffset:Number;
var yMin:Number = 0;
var yMax:Number = scrollB.track.height - scrollB.thumb.height;

scrollB.thumb.addEventListener(MouseEvent.MOUSE_DOWN,thumbDown);
stage.addEventListener(MouseEvent.MOUSE_UP,thumbUp);

function thumbDown (e:MouseEvent):void
{
   stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
   yOffset = mouseY - scrollB.thumb.y;
}

function thumbUp (e:MouseEvent):void
{
   stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}

function thumbMove(e:MouseEvent):void
{
   scrollB.thumb.y = mouseY - yOffset;
   if (scrollB.thumb.y <= yMin)
      scrollB.thumb.y = yMin;
   if (scrollB.thumb.y >= yMax)
      scrollB.thumb.y = yMax;
   var sp:Number = scrollB.thumb.y / yMax;
   //Tweener.addTween(content, {y:(-sp*(content.height-masker.height)), time:1});
   e.updateAfterEvent();
}

thanks for viewing.

Making Up/Down Arrows On Object-Oriented Scrollbar 1
Hey guys,

I have implimented the Object-Oriented Scrollbar 1 into a project I am working on, and now the client wants to add Up/Down arrows to the functionality.

Can someone help me figure out what to do to add that functionality? I was trying to just move the content, but it didnt update the scroller bar, and I am unsure of how to go about this.

This is for a large client, and I do not have the time to re-impliment a new scrollbar system.

Thanks so much!

Object Oriented Scrollbar Made Horizontal Help?
Hey All,

Thanks in advance for checking this out!

I'm new to flash and looking for a little help with the Object Oriented Scrollbar. I've made it horizontal instead of vertical like Lee. But I'm having problems on the bounds of where the thumb bar can move. It stops half way and won't go back to the zero point (the far left).

I've attached the Fla but I think the problem is in the actions so I'll post that here for quick review:

Code:

import caurina.transitions.*;

var xOffset:Number;
var xMin:Number = 0;
var xMax:Number = sb.track.width - sb.thumb.width;

sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);

function thumbDown(e:MouseEvent):void
{
   stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
   xOffset = mouseX - sb.thumb.x;
   
}

function thumbUp(e:MouseEvent):void
{
   stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
   
}

function thumbMove(e:MouseEvent):void
{
      sb.thumb.x = mouseX - xOffset;

      if(sb.thumb.x <= xMin)
         sb.thumb.x = xMin;
      
e.updateAfterEvent();
}



Thanks again for the help!

Object-Oriented Scrollbar (Lee's Video Tutorial)
Hello People.
im trying to use Lee-s Object Oriented ScrollBar.
all is ok and scroll bar works in my swf file,
but i need to load this swf into another, when i'm trying to do this i got this error
Code:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at com.leebrimelow.ui::ScrollBar$iinit()
did anyone got same problem?

Object Oriented Scrollbar 2 Tutorial Question
In lee's latest tutorial I get the following error

5001: The name of package 'com.leebrimelow.ui' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. C:Documents and SettingsAdministratorDesktopFlashActionscriptcomleebrimelowuiScrollBarEvent.as

Object-Oriented Scrollbar 1 Inside Other Movieclip?
Hello,

I made Object-Oriented Scrollbar and its working like a dream. But when i load that movieclip inside other movieclip, it's not working anymore.

What kind of changes I should do for the main movieclip to make scrollbar movieclip work inside of it? I tried to put the code import caurina.transitions.*; in the main movieclips first frame but that didn't make it work.

Can anyone help me with this?

Object-Oriented Scrollbar 1 Error #1009
Hi guys!
I'm trying to follow through Object-Oriented Scrollbar 1 tutorial on the site, and I'm getting the error #1009: Cannot access a property or method of a null object reference.
at scrollbarTest2_fla::scrollbox_1/thumbMove()

Here is my code:
Code:

import caurina.transitions.*;
import flash.events.Event;

var yOffset:Number;
var yMin:Number = 5;
var yMax:Number = sb.track.height - sb.thumb.height;

sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);

function thumbDown(e:MouseEvent):void
{
   stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
   yOffset = mouseY - sb.thumb.y;
}
function thumbUp(e:MouseEvent):void
{
   stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}
function thumbMove(e:MouseEvent):void
{
   sb.thumb.y = mouseY - yOffset;
   if(sb.thumb.y <= yMin)
   {
      sb.thumb.y = yMin;
   }
   if(sb.thumb.y >= yMax)
   {
      sb.thumb.y = yMax;
   }
   var sp:Number = sb.thumb.y / yMax;
   Tweener.addTween(content, {y:(sp*(content.height-mask.height)),
                       time:1});
   e.updateAfterEvent();
}



What am I doing wrong? I thought that I followed the tutorial exactly..!
Thanks for any help in advance

Object Oriented Scrollbar With External HTML And CSS File
Simply put, what I'm trying to do is create a Dynamic Textfield with custom scroll bars via this tutorial (http://gotoandlearn.com/play?id=71), that renders an external HTML file with CSS attached as its content instead of images like in the tutorial.

I've tried a mix and match combination, ultimately, when I test the movie, the scroll bar works, but I see no content to scroll through.

I have attached my project file.

my appreciation in advance.

-Ziul

Object Oriented Scrollbar With External HTML And CSS File
Simply put, what I'm trying to do is create a Dynamic Textfield with custom scroll bars via this tutorial (http://gotoandlearn.com/play?id=71), that renders an external HTML file with CSS attached as its content instead of images like in the tutorial.

I've tried a mix and match combination, ultimately, when I test the movie, the scroll bar works, but I see no content to scroll through.

I have attached my project file.

my appreciation in advance.

-Ziul

Object Oriented Scrollbar With External HTML And CSS File
Simply put, what I'm trying to do is create a Dynamic Textfield with custom scroll bars via this tutorial (http://gotoandlearn.com/play?id=71), that renders an external HTML file with CSS attached as its content instead of images like in the tutorial.

I've tried a mix and match combination, ultimately, when I test the movie, the scroll bar works, but I see no content to scroll through.

I have attached my project file.

my appreciation in advance.

-Ziulprototype.fla [ 80 KiB | Viewed 265 times ]

"Object-Oriented Scrollbar 2" Question
I watched the videos on how to make the object-oriented scrollbar (great tutorial btw) and I'm using it in my own small project right now. But I ran into a problem:

I have the scrollbar on the stage and I customized it to fit the project .The content layer with the content movieclip has textfields and input textfields in it. When I move the thumb/ scrollbar the text scrolls fine but you can't see the text input fields. I receive no errors and I followed to tutorial correctly, so technically everything should work fine, but my text input fields are not appearing (I even tried importing different things into ScrollBar.as and ScrollBox.as ( import flash.text.*;) but the textinputs still don't show).

Any ideas?

Thanks.

Object Oriented
Have you known any site(or book) that explain object-orientence?
I can't understand the classes and methods in AS.

Object Oriented Help?
hello all my map page is nearing its end..... ive got a question though.... im using flashmx2004 and on my map page is a listbox in the upperleft hand corner.....i want the user to be able to click on the button in the list and have the map zoom/pan to that location on the map.... because the way i have set up my zoom/pan functions the coordinates of the map are scale dependent so setting the coordinates of each of the 58 features would be very time consuming and labor intensive.... what i am wondering is there a way that i can point the button in the list to zoom to the building(btn) within the map and center it within the frame.....
the way my map layers are set up as followed.....
zoomMC (movieclip) = scaling map
>mapMC (movieclip) = panning map
>campusmap (graphic) = contains the buttons (buildings)
each button (building) within the map has been given an instance name so how could i get the corresponding listbox button to make the map zoom and pan to the button within the map frame by calling its instance and making it the center of the map frame.....???

hope ive explained clearly if you look at the two buttons in the list: "AD - Admissions House" and "HS - Henson Science Hall" those are the only two that i have currently active look at the script on the buttons to see how i had to do it no good....and my coordinates are all screwed up....

also if anyone can explain to me how to change the pivot point (or reference point) of my map clip so that when you us the zoomin and zoomout tools it doesnt zoom to the upper left hand corner....this has boggled me for some time????

Thanks again for all the help

the link to the swf is http://www.students.salisbury.edu/~jw08193/test3.swf
and the fla is attached

Object Oriented Xml Api
hello all,
does anybody know about any good open source xml framework for actionscript? I find the one that comes with actionscript is quite cumbersome and unintuitive so I was wondering if anyone there is a framework that loads xml files into objects in actionscript 2.0
if you know of any such framework please let me know!

thank you in advance for your time and effort!

Learning Object Oriented. Please Help
I can't get this to work. I'm trying to get my objects to hit the walls and bounce off. I don't care what direction they go. That is why I have a random number generator. I'm having trouble getting one of my functions
i.e. "nextSpeed();" to be called. If someone could take a look and give me some ideas that would be great. Thanks
p.s. "bob" is the name of my button to get all of this going.

code:
__________________________________________________ _________

_global.myObjArray = new Array();



g_XBoxStart = 10;
g_YBoxStart = 10;
g_BoxWidth = 640;
g_BoxHeight = 480;
_global.levelCounter = 0;

function drawBorderBox(){
_root.lineStyle(0,0x990000,100);
_root.moveTo(g_XBoxStart,g_YBoxStart);
_root.lineTo(g_BoxWidth,g_YBoxStart);
_root.lineTo(g_BoxWidth,g_BoxHeight);
_root.lineTo(g_XBoxStart,g_BoxHeight);
_root.lineTo(g_XBoxStart,g_YBoxStart);
}
drawBorderBox();

function Ball (passingX,PassingY,passedWidth,passedHeight,hexCol or){
_global.myObjArray[_global.myObjArray.length] = this;
this.myX = passingX;
this.myY = PassingY;
this.clipsWidth = passedWidth;
this.clipsHeight = passedHeight;
this.moviePtr = _root.createEmptyMovieClip("clip_" + levelCounter,_global.levelCounter++);
/*this.moviePtr.lineStyle(0,hexColor,100);
this.moviePtr.beginFill(hexColor,100);
this.moviePtr.moveTo(this.myX,this.myY);
this.moviePtr.lineTo(this.clipsWidth,this.myY);
this.moviePtr.lineTo(this.clipsWidth,this.clipsHei ght);
this.moviePtr.lineTo(this.myX,this.clipsHeight);
this.moviePtr.lineTo(this.myX,this.myY);
this.moviePtr.endFill();*/
with (this.moviePtr)
{
lineStyle(0, 0x000000, 100);
beginFill( hexColor );
moveTo(0, -10);
curveTo(10, -10, 10, 0);
curveTo(10, 10, 0, 10);
curveTo(-10, 10, -10, 0);
curveTo(-10, -10, 0, -10);
endFill();
}

}
function rSpeed(low, high)
{

high -= low - 1;
high *= Math.random();
high += low;
high = Math.floor(high);
return high;

}
function nextSpeed ()
{
trace("0000000000000000000000000");
trace("Jon..................this.theX = " + this.theX);
this.theX = rSpeed(-5,5);
this.theY = rSpeed(-5,5);
trace("Jon..................this.theX = " + this.theX);
moviePtr.myMove();
}

Ball.prototype.myMove = function(){
//trace("myMove called");
tempX = this.myX + this.theX;
tempY = this.myY + this.theY;
//trace("this.myX = " + this.myX);
//trace("this.myYX = " + this.myY);
if(tempX >g_XBoxStart && tempX < g_BoxWidth){

this.myX = tempX;

//trace (this.myX + " =====");

}else{
//nextSpeed();
warningText="Passed X value is out of range";
trace(warningText);
return false;
}
if(tempY >g_YBoxStart && tempY < g_BoxHeight){

this.myY = tempY;

}else{
//nextSpeed();
warningText="Passed Y value is out of range";
trace(warningText);

return false;
}
this.moviePtr._x = this.myX;
this.moviePtr._y = this.myY;
//trace("this.myYX = " + this.myY);

}
Ball.prototype.theX;
Ball.prototype.theY;

clip1 = new Ball(20,20,50,50,0x009900);
clip2 = new Ball(70,70,50,50,0x0000ff);
clip3 = new Ball(170,170,50,50,0x0000ff);


Ball.prototype.test = function ()
{if (clip1.moviePtr._x< g_XBoxStart || clip1.moviePtr._x > g_BoxWidth)
{
nextSpeed();
}
if (clip1.moviePtr._y < g_YBoxStart || clip1.moviePtr._y > g_BoxHeight)
{
nextSpeed();
}
for (i=0; i < myObjArray.length; i++);
{

if(myObjArray[i].moviePtr._x < g_XBoxStart || myObjArray[i].moviePtr._x > g_BoxWidth)
{
trace (myObjArray[i].moviePtr._x + ": 9999999999999999999999999999999999");
nextSpeed();
}
if(myObjArray[i].moviePtr._y < g_YBoxStart || myObjArray[i].moviePtr._y > g_BoxHeight)
{
trace (myObjArray[i].moviePtr._y + ": 777777777777777777777777777777777777");
nextSpeed();
}
}
};
_root.onEnterFrame = function()
{
clip1.myMove();
clip2.myMove();
clip3.myMove();
test();
}

bob.onRelease = function()
{
trace("------------------------------");
trace("------------------------------");
trace("------------------------------");
for(i=0;i<myObjArray.length;i++){

myObjArray[i].theX = rSpeed(-5,5);
myObjArray[i].theY = rSpeed(-5,5);
//trace(myObjArray[i].theX +" theX");
myObjArray[i].myMove();
}

};

__________________________________________________ _________
end code//

Help With Object Oriented Programming
I'm familiar with the concepts and all of OOP (Object Oriented Programming) however I can't seem to find any tutorials or information on how to declare a class in actionscript and where to store my classes. I was hoping someone could direct me to a good tutorial or could just tell me where I should be writing my classes and how to declare them. I've done classes in Java and thought it would be helpful for game programming in flash. Any help is greatly appreciated, thank you.

Object Oriented Programming
Hi

Basicaly i'm a VB an Delphi programmer so i have some skills in oop but i can't quite understand oop in flash.
Using VB or Delphi you have a name for each object and when you need to referr to thath object you use its name a dot (.) and the proprety you need to change or the method you want to use.But how is this possible in flash when there are different layers and objects and instance without any name????


thanks

[F8] Please Help Object Oriented Programming
Hi guys,

I'm doing object oriented programming at university. -- and now i'm noticing it everywhere, it's like im going to be left behind unless i learn it.

PHP 5 is OO, Actionscript 3 is OO <-- and this is the reason i want to really know what im doing.


Like i said, im doing object oriented programming at university, but it's making little sense, so i thought the best way to learn is by trying it in flash.

I just dont get what the "classes" are supposed to do? -- they make objects, but what do you do with these?

I've been reading around the net, and on here, and it says it's a way of breaking the program down into smaller bits.

but how do you actually use the classes, i tried this:

in TestClass.as:

Code:
class TestClass {
//CONSTRUCTOR//
function TestClass() {
//The code in here is executed when the object is created;
trace("hi")
}

}


in Main.fla:

Code:
import TestClass;


var newMenuItem:TestClass = new TestClass();



It does work, i see the "hi", but if all you do is import code from a class, how do you use it?

Sorry if this sounds dumb to people who know it, but i just dont get it

(and i love actionscript 1 too )

F8 Object Oriented Programming
I am attempting to produce a jigsaw for the kids, based on one provided (see URL below). It consists of 16 pieces (4x4) all appears to be working well with the following exception the numbers 1,2,3 or 4 (text) are recognized 5 to 16 are not.
PLEASE - Can anyone help?

Http://www.actionscript.org/resource...zle/Page1.html

n=parseInt(no_of_pieces.text);
success = 0;
for(i=1;i<=n;i++)
{
this["p"+i]._x = Math.random()*180;
this["p"+i]._y = Math.random()*200;
this["p"+i]._xscale = 50;
this["p"+i]._yscale = 50;

}


onPress = function ()
{
if(this.hitTest(_root._xmouse,_root._ymouse))
{
this.startDrag();
}
}


onRelease = function ()
{
stopDrag();
name = this._name;
int_name = name.substring(1);
int_name = parseInt(int_name);

if(eval(this._droptarget) == _parent["inv_p"+int_name] )
{
_parent.joined_mc["p"+ int_name]._visible = true;
this._visible = false;
snd = new Sound();
snd.attachSound("snd_ok");
snd.start();
_parent.success++;
if (_parent.success == _parent.n)
{
_root.puzzle._visible = false;
_root.anim._visible = true;
music = new Sound(anim);
music.attachSound("jingle");
music.start();
_root.anim.play();

}
}
else
{
this._x = Math.random()*180;
this._y = Math.random()*200;
snd = new Sound();
snd.attachSound("snd_fault");
snd.start();
}
}

Oriented Object Programming
I have a class to load an xml file:

package
{
import flash.events.*
import flash.net.*

public class conexiones {

var loader:URLLoader = new URLLoader()
public static var xml_ruta:String;
public static var xml:XML;

public function cargarXML(){
loader.dataFormat = URLLoaderDataFormat.TEXT
loader.addEventListener(Event.COMPLETE, onLoadXML)
loader.load(new URLRequest(conexiones.xml_ruta)) }

public function onLoadXML(ev:Event){
try {
var myXML:XML = new XML(ev.target.data)
conexiones.xml = myXML; }

catch (e:TypeError) {
trace("Error: el formato del XML no es correcto!")
trace(e.message) }

}//fin function
}//fin clase
}//fin paquete

and the main fla:

frame 1:
var con:conexiones = new conexiones()
con.cargarXML();
trace("XML "+conexiones.xml); // null

frame 2:
trace("XML "+conexiones.xml); // the xml value

but just in the second frame the conexiones.xml has a value

What am I doing bad ?

Object Oriented OnRollOver
I'm working on my first XML project, and am looking to get a little deeper into it. My next step is I want to replace the image that is loaded through XML to a different image, but only on roll over and I need it to switch back when I rollOut. I think I should just make another XML that refers to a different set that corresponds to the first set of images, but am still a little foggy on how to properly program it. THANKS!







Attach Code

var home:MovieClip = this;
theText._alpha = 0;


var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
tooltip._alpha = 0;

var xml:XML = new XML();
xml.ignoreWhite = true;

xml.onLoad = function()
{
var nodes = this.firstChild.childNodes;
numOfItems = nodes.length;
for(var i=0;i<numOfItems;i++)
{
var t = home.attachMovie("item","item"+i,i+1);
t.angle = i * ((Math.PI*2)/numOfItems);
t.onEnterFrame = mover;
t.toolText = nodes[i].attributes.tooltip;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
}

function over()
{

home.tooltip.tipText.text = this._parent.toolText;
home.tooltip._x = this._parent._x;
home.tooltip._y = this._parent._y - this._parent._height/2;
home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
home.tooltip._alpha = 100;

}

function out()
{
delete home.tooltip.onEnterFrame;
home.tooltip._alpha = 0;
}

Object Oriented AS Not Working
For some reason I cannot add any code to symbols in flash, but only the frames. When I click a symbol (tried movie clips, buttons, and graphics) and go to actions it just says "Current selection cannot have actions applied to it". This makes no sense to me since I KNOW that flash allows object-oriented programming. I really am confused. I just installed flash by the way. Anybody have any ideas?

Object Oriented Question
Hey guys, I realize this puts me totally in the realm of freak but here goes.

I am dynamically creating a movieclip, say, a ball.

I want to apply a movement to each new ball created.

I have created a movement function and now I need to know how to use this function as a method on each newly created ball.

Would I do something like this:

ball.moveThis();

or

moveThis(ball);

Please let me know if you need me to explain further.

Object Oriented Question
I have a question regarding to object oriented Actionscripting.

I have a class A, which is the document class. Then I have a class B and class C. I create an instance of class B in the document class like this

ActionScript Code:
var _b:B = new B();addChild(_b);

in class B I create an instance of class C. In class C I want call a method that is defined in class B. How do I do this? As I understand it, I can't create another instance of class B inside of class C, because I have already done that in class A. So in class C this

ActionScript Code:
var _b:B = new B();_b.someMethod();

isn't acceptable? How do call class B's method from a class that is created in class B?

I hope this makes sense to some of you

Oriented Object Programming
I have a class to load an xml file:

package
{
import flash.events.*
import flash.net.*

public class conexiones {

var loader:URLLoader = new URLLoader()
public static var xml_ruta:String;
public static var xml:XML;

public function cargarXML(){
loader.dataFormat = URLLoaderDataFormat.TEXT
loader.addEventListener(Event.COMPLETE, onLoadXML)
loader.load(new URLRequest(conexiones.xml_ruta)) }

public function onLoadXML(ev:Event){
try {
var myXML:XML = new XML(ev.target.data)
conexiones.xml = myXML; }

catch (e:TypeError) {
trace("Error: el formato del XML no es correcto!")
trace(e.message) }

}//fin function
}//fin clase
}//fin paquete

and the main fla:

frame 1:

import conexiones
var con:conexiones = new conexiones()
con.cargarXML();
trace("XML "+conexiones.xml); // null

frame 2:
trace("XML "+conexiones.xml); // the xml value

but just in the second frame the conexiones.xml has a value

What am I doing bad ?

Object Oriented AS Order
So it's like this, I've got several MC:s that are supposed to "follow" a certain other MC instantly, without any delay at all, but unfortunatly they do indeed have a slight delay which i believe has to do with the order that flash reads the objects actionscript, as the objects are dependent on eachother..

so what I'm wondering is if there's any trick to make one objects actionscript be read before another objects actionscript..

like changing the name of it, or depth on the scene..

got that?

Object Oriented Project
Hey Everyone, just want to say thanks for all of the wonderful help gotoandlearnforum.com has provide me in my recent project. I thought I would post the final outcome and maybe get some pointers for cleaning it up/making it object oriented.

http://www.fateforge.com/superviewer/SuperViewer.html is the Product. (information was changed per company policy).

Functionality of the Application:

Drag and Drop windowsZooming/PanningInformation loads from XML
I'm just looking for any pointers regarding the Object Oriented structure of this same program.

Exactly What Is Object-oriented Programming?
Can someone put this to me in Laymans terms. Why is it asked in so many job applications, what makes it better, pros and cons, etc.

Object Oriented Programming In Flash
is there a tutorial or something somewhere on how to do Object Oriented Programming in Flash? I just need to know where to put the object script... thanks,

~jimmy.

Object Oriented Programming Tutorials
Can anyone recommend any good tutorials on OOP, specifically within Flash?

I'm slowly getting my head round the concept, but could do with a few tutorials showing some applications of OOP in Flash.

Ta.

Object Oriented Zoom Script
hello flash nation,
I am looking for some help with a university campus map i have been working on for some time now.... What i want is the script that would allow me to press a button in a MC and have it zoom to a different button in a different MC. I have included the .fla attached. Im using Flash MX 2004. When you open the file you will see the map at its full extent... in the left upper corner is a list of the buildings to which each of the names in the list is a button. The only button currently active at this time is the first one "AD-Admissions House". The on(press) handler zooms the map to full extent and the on(release) handler pans and zooms the map to the Admission House within the map clip... The building is also a button. I currently have the coordinates of inputed in the list button "AD-Admissions House" but to figure out the coordinates for each building would take an extreme amount of time. So my question is, "is there a way to make the button in the list recognize the button in the map and have it zoom to the button, rather than zoom to the coordinates. I hope this makes sense. Basically its an object-oriented command. Thanks for your help on this ahead of time. Each day I get better and better with flash script.

here is the link to the swf http://students.salisbury.edu/~jw08193/test4.swf

the .fla is attached

Object-oriented Design Tips Anyone?
I've previously written a non-object-oriented 3D engine in Flash. I'm quite new to designing object-oriented systems, and I was just wondering if anyone could give me any pointers.

My problem is, I'm not sure how to break a 3D engine into classes.

a 3D engine has a camera, a world and world-objects within that world.
Each of these has it's own transformation-matrix.

Each world-object must be transformed by its own transformation, then the world's transformation, then the camera transformation.

What classes/objects should I use?
Any tips would be highly appreciated,
Cheers!

I Would Like To Learn How To Make This AS More Object-oriented
Hello all,

I've made a fractal generator in Flash.

It basically creates 3 MovieClips, each having 3 little squares (joined together by a couple of lines), which become your way of manipulating the shape of the fractal.

The fractal is then drawn depending on the coordinates of these little squares. I don't think it's necessary to go into further detail on how the fractal is actually generated (if anyone wants, I can explain).


Would anyone mind looking at my code and seeing how I can improve it? I don't mean improve the functionality of the program, but improving how it is coded (the program as it stands does exactly what I want it to do, but probably not in the most OO way).

The reason I made this flash file was to try and do some OO stuff. I don't think it's quite there, and the movieclips confused me somewhat.

Oh, it's Flash 8 and all done in AS.

Come on guys, download the zip file and rip into my code, I'm all ears and I want to know what I've done wrong and what I could've done better. I want to learn OOP in Flash so please don't be shy with the criticisms

Object Oriented Actionscript Error?
Hi I have used the following code within one of my utility classes:

/*
* Function to print a list of all issued IDs
*/
public static function printStatus(){
for(var i:Number = 0; i < Identifier.assignedNumbers.length; i++){
trace(Identifier.assignedNumbers[i])
}
}


When I use:


Identifier.printStatus();


assignedNumbers is a class variable of type Array. Identifier is the name of the class.

It does not trace the numbers, anybody know why this might be? For all
other purposes the class works fine but I cannot get this method to
work. I don't think this is an error but if anybody could explain this I would be very grateful.


And yes... Identifier.assignedNumbers.length is greater than 0!


Thanks, John Tear.

Object Oriented Scructure <programming>
I'd like to know about the object oriented structure in ActionScript.

More excatly about abstract methods.

Is it possible to state abstract methods in ActionScript classes?

This means that the ActionScript must bear inheriance, as well.

Thanks in advance.

Object Oriented Design Problem
Today I have encountered my first problem with ActionScript 3.0: it doesn't support nested classes.

The problem scenario: I have various sprites created dynamically, and I would like to define them inside of other class in this way:


Code:
class MySprite extends Sprite {
public function MySprite() {
point.graphics.lineStyle(0, 0x000000);
point.graphics.beginFill(0x000000);
point.graphics.drawRect(0, 0, 10, 10);
point.graphics.endFill();
}
...
}
var mySprite=new MySprite();
Instead of:


Code:
var mySprite=new Sprite();
point.graphics.lineStyle(0, 0x000000);
point.graphics.beginFill(0x000000);
point.graphics.drawRect(0, 0, 10, 10);
point.graphics.endFill();
...
Because I believe the first way is most object oriented and enhaces code organization. I know it's sintactic sugar but coming from other languages that allow this, it's difficult for me to go to a more imperative programming scheme.

How do you guys overcome this limitation? (of those who care about this :-)

Friends Of Ed : Object-Oriented ActionScript 3.0
Has anybody read this book, and would you recommend it?

Friends of Ed : Object-Oriented ActionScript 3.0

http://www.amazon.com/exec/obidos/tg...X0DER&v=glance

thanks

How To Detect A Variable Change? (object Oriented)
Please help

I need the best, efficient, object-oriented method to detect, when a variable (or a property of an Array) changes.

For example, TextField object has a handler onChanged(), which detects when the content of dynamic text field changes. How does it work? Does it constantly check if the value changed (using a comparison with old value, starting every while with setInterval() or sthing like that) or is there a more efficient method of informing about value change?

Specifically, my problem is:

I have an Array with ten cells (properties). I want to start specific action in some other objects, when a specific value (property) in that Array changes. All that should be object-oriented (using broadcastMessage(), listeners and that stuff). I know how to broadcast the event to other listeners, but I don't know how to efficiently detect the moment when the value of Array's property changes. The only idea I have is to permanently check all the values (using setInterval()), but i don't think it is efficient.

To all pros — how do you deal with that problem?

Please.

AS: Object-Oriented Call Of Event-hander?
Hello!

Imagine the following class, which loads another movie-clip and assigns an onPress function, which should call the class itself:


PHP Code:



class MyClass extends MovieClip
{  public var m_sTeststring = "Parent-Class";

    public function MyClass()
    {      var pPic:MovieClip;
            pPic = createEmptyMovieClip("pic"+nCount, nCount);
            pPic.loadMovie(sUrl); // sUrl: URL of a picture to be loaded
            pPic.m_sTeststring = "Picture";
            pPic.onPress = this.onClickPic;
            trace(m_sTeststring); // Outputs "Parent-Class";
    }
    
    public function onClickPic()
    {    trace(m_sTeststring); // Outputs "Picture"
    }    
}




The result is, that onClickPic is called in the context of pPic and outputs "Picture" instead of "Parent-Class".

Why is this and how can I make the onPress-Event refer to the instance of my class WITHOUT using absolute pathes like _root.myclass1.m_sTeststring?

Object-Oriented Programming With ActionScript By Branden Hall Is It Any Good?
Hi,

I am thinking of going in for a good book on OOP with actionscript... but i wud like to know is this book worth putting money into?

cos my earlier experiences with new riders books have been, to say the least, "less than satisfying".
(yes, i bought the flash 5 magic book)

so tell me am i gonna be wasting my money once again.

I was lucky to have been told by some very knowledgeable ppl in an earlier post to go in for colin moocks book to get my bearings on actionscript. that was sound advice.... i still treasure tht book... if this book even comes 80% close to being as good as colin's i will buy it... but please be truthful.

Creating The Self-Moving Part Of A Scrollbar
In my quest to create an OS scrollbar I have come far and learned much but there is one last piece that I need. I can make a dynamic textbox scroll when buttons are pressed. Also I can make the same textbox scroll when I drag the scrollbar up and down the track. However, I do not know how to get the scrollbar to go up when I press the scroll up button or down when I press the scroll down button.

I'm looking to do this WITHOUT constants and without components. My code so far works for any height on anything and it is not dependent on constants.

Please help. Thanks.

Selfminded

Scrollbar Component Over Only Part Of A Textbox?
Hi all, I'm wanting to put a scrollbar component at the side of a textbox, but ont the whole length... I want it to not be in the top approx 100 pixels... can anyone help? I can't do this, it keeps snapping into place...

Scrollbar Component Over Only Part Of A Textbox?
Hi all, I'm wanting to put a scrollbar component at the side of a textbox, but ont the whole length... I want it to not be in the top approx 100 pixels... can anyone help? I can't do this, it keeps snapping into place...

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