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




Custom RectBorder Class - Can Make Hovers?



Hello,

I'm having a ton of trouble finding any decent documentation on this


http://livedocs.macromedia.com/flash...=00002742.html

I got the custom skins working from that class extention, now can I make a hover? I want the background of the entire comboBox to basically change color when I hover at any point. This should be really simple... why does flash make this such a headache.

Any help would be apprecaited, links, or other people to talk to.



SitePoint > Design Your Site > Flash and Actionscript
Posted on: Nov 13, 2006, 03:46


View Complete Forum Thread with Replies

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

RectBorder Class : ComboBox
How do I use the RectBorder class to make a custom border for a ComboBox.

I want to have a dashed border for the ComboBox....and i't hard




Case

RectBorder Class : ComboBox
How do I use the RectBorder class to make a custom border for a ComboBox.

I want to have a dashed border for the ComboBox....and i't hard




Case

Skinning Combobox RectBorder Class... Only
preface: I have experience skinning components.

Issue: trying to change the rectBorder class ONLY on the combobox instances. no others. can anyone help me with this? I've changed the rectBorder for entire documents before, but have never been able to target it to one type of component.

any guidance, links or heckling is appreciated!

Accessing RectBorder Class Properties
I would like to turn off the border on build-in TextArea component.

Using the method found at http://livedocs.macromedia.com/flash...=00002740.html

works for all the TextArea's I am dealing with, however, it makes the window component created using PopUpManager.createPopUp transparent.

I guess what I really would LOVE to know is how to set the borderStyle to "solid" and then reset the borderColor.

Any clues?

Accessing RectBorder Class Properties
I would like to turn off the border on build-in TextArea component.

Using the method found at http://livedocs.macromedia.com/flash...=00002740.html

works for all the TextArea's I am dealing with, however, it makes the window component created using PopUpManager.createPopUp transparent.

I guess what I really would LOVE to know is how to set the borderStyle to "solid" and then reset the borderColor.

Any clues?

Make Buttons Show Text When Mouse Hovers...?
Hi all.
So if I have a button (movie clip) how do I get it to show text when the mouse hovers over it?
Basically the mc is a button and the buttons are icons and they all don't have an actual site name associated with them, so I want text to show so the viewer knows what they are clicking.

Thanks!

Movieclip Follow Mouse - How To Make It Disappear When It Hovers Over A Button?
Hi there,

I have an actionscript assigned to a movie clip. This actionscript tells the movie clip to follow the cursor's x and y movement. The speed of the movie clip depends on how fast the x and y movement is. This was a script I simply copied from a tutorial. I am new to actionscript and Flash, so I have a problem adding my own touch to this script.

What I want to do is make the movieclip following the cursor disappear when you hover over a button and, of course, reappear when you leave the button. There are in total 3 buttons.

I am running Flash 8, AS 2.0, but publishing for Flash Player 7.

Now which approach should made to acheive this?

The following code is what I already have assigned to my movie clip:

code: onClipEvent (enterFrame) {
//x movement
mx=_root._xmouse;
if (mx<_x) {
dx=_x-mx;
}
else {
dx=mx-_x;
}
moveSpeedx=dx/10;
if (mx<_x) {
_x=_x-moveSpeedx;
}
else {
_x=_x+moveSpeedx;
}
//y movement
my=_root._ymouse;
if (my<_y) {
dy=_y-my;
}
else {
dy=my-_y;
}
moveSpeedy=dy/10;
if (my<_y) {
_y=_y-moveSpeedy;
}
else {
_y=_y+moveSpeedy;
}
}



I think I need to define two different outcomes. One would show the movieclip with alfa = 100 when it isn't hovering over a button and the other would show change alfa = 0 when it is. I think it would be great if I could make it gradually fade out instead of flickering from visible to invisible.
_alfa:100
_alfa:0

Do you need to define all 3 buttons in the script or can you add a piece of code to the script, which executes #2 no matter which button the cursor touches.
I would like to make it clear that I want this to happen when the cursor (not the movie clip) touches the button.

I have been looking through the actionscript documentation. Naturally, as a novice, it is hard to figure out which pieces I need to combine to complete the puzzle.

One of my main problems is know where to add this script, since it has to relate to the script which is already defined. As said, this script is attachted to the movie clip itself.

Many many thanks to anyone who can help me with this project. I hope this will be a great learning experience for me. I just need a good push in the right direction.

How Do I Make My Custom Math Class Methods Persist Across Levels?
Well, just what the title says.

On _level0 I've added a couple of tween calcuations to the Math object. Let's call it Math.calcTween(). I would have expected this to become available through the Math object in my other SWF that I load in _level1, but that doesn't seem to be the case. Have do I make the Math object update persist across all files and levels? Does the _global keyword have anything to do with it?

Cheers,
Terpentine

[F8] Problem With Using A Custom Class Inside A Custom Class
I'm getting this error:
Line 19: A function call on a non-function was attempted.
var a:Meter = new Meter(32,34,0x0000ff,0,0);
when I am trying to call a custom class (Meter) inside of another custom class, which I initialize in the main timeline. I can do this exact same line I copied above in the main timeline and it will work just fine, but not if it is used in the constructor of another custom class as I am trying to do. Any ideas on why this isn't working? Only thing I can come up with is that the class isn't imported at the time of the second class calling it but I've tried fixing that already.

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);

[AS3] Making An Auto-generated Class Inherit From Custom Class?
hi, just wondering if this is possible

i was hoping to find a way to get a bunch of objects in my library to inherit from (or even be) one class that i have made, but without having to make .as files for every single one

is this possible, or is there any other way to give objects another classes functionality in an auto-generated class?

cheers

[Flash8] Calling BitmapData Class From Within Custom Class
I've written a custom class which resides in a .as file. Is there any way that functions from within my class can call the BitmapData class for bitmap manipulation?

Tween Class Applied In Custom Class Not Working
var sizerW:Object = new Tween(pda_mc,"_xscale",mx.transitions.Tween.None.e aseNone,pdaOrigW,pdaSmallW,3,true);

this code produces and error when applied in a custom class but not in a fla?

the error = There is no property with the name 'None'.

Custom Transitionmanager Class Problem/class Scope?
I'm writing a class that fades from one scene to another in a video game. A custom transitionManager object is created, and a listener is attached. Once the fade out from one scene is complete, the listener is triggered, the scene switches, and the new scene fades in.

This is the error I'm getting: "There is no method with the name 'myTransitionManager'.
myTransitionManager.addEventListener("allTransitio nsOutDone", fadeListener);". It is given everytime myTransitionManager is accessed by any of the class functions.

I assume this is a class scope issue. How can I create a custom transitionManager object accessable to the entire class? I need it to be accessed by at least three separate class functions.

Here's the source, starting with the constructor for the GameSection class:


Code:
public function GameSection(clip_to_fade:MovieClip){
var myTransitionManager:TransitionManager = new TransitionManager();
}

//class methods

function switch_section(clip_to_fade:MovieClip, fade_in_scene:String) {
// Define a listener object to use with the Tween objects.
var fadeListener:Object = new Object();
//create event listener for transitions being complete
fadeListener.allTransitionsOutDone = function(eventObj:Object) {
trace("allTransitionsOutDone event occurred.");
gotoAndPlay(fade_in_scene);
fadeIn(clip_to_fade);
};
myTransitionManager.addEventListener("allTransitionsOutDone", fadeListener);


fadeOut(clip_to_fade);
}

function fadeIn(in_mc:MovieClip) {
myTransitionManager.start(in_mc, {type:Fade, direction:Transition.IN, duration:1, easing:None.easeNone});
}

function fadeOut(out_mc:MovieClip) {
myTransitionManager.start(out_mc, {type:Fade, direction:Transition.OUT, duration:1, easing:None.easeNone});
}


Thanks!

How Do You Listen In One Class For A Custom Event Dispatched From Another Class?
I am not sure how to word this, so here is what I would like to happen:

MyDocumentClass contains an instance of MyItem and MyItemManager. MyItem will fire an ItemEvent.ITEM_CHANGED event. I want MyItemManager to listen and react to that event. Possible? Here's my code:

ItemEvent.as:

ActionScript Code:
package
{
    import flash.events.Event;
   
    public class ItemEvent extends Event
    {

        public static const ITEM_EVENT:String = "itemEvent";
       
        public function ItemEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false)
        {
            super(type, true);
        }
       
        public override function clone():Event
        {
            return new ItemEvent(type);
        }
       
        public override function toString():String
        {
            return formatToString("ItemEvent", "type", "bubbles", "cancelable");
        }

    }
}

MyDocumentClass.as:

ActionScript Code:
package {
    import flash.display.Sprite;
    import MyItem;
    import MyItemManager;
   
    public class MyDocumentClass extends Sprite
    {
        public var item:MyItem;
        public var manager:MyItemManager;
       
        public function MyDocumentClass()
        {
            item = new MyItem();
            manager = new MyItemManager();
            item.dispatchCustomEvent();
        }

    }
}

MyItem.as:

ActionScript Code:
package
{
    import flash.display.Sprite;
    import flash.events.EventDispatcher;
    import ItemEvent;
   
    public class MyItem extends Sprite
    {
       
        public function MyItem()
        {
        }
       
        public function dispatchCustomEvent():void
        {
            dispatchEvent(new ItemEvent(ItemEvent.ITEM_EVENT));
        }
    }
}

MyItemManager.as:

ActionScript Code:
package
{
    import flash.display.Sprite;
    import ItemEvent;
    import flash.events.EventDispatcher;
   
    public class MyItemManager extends Sprite
    {
               
        public function MyItemManager()
        {
            addEventListener(ItemEvent.ITEM_EVENT, handleItemEvent);
        }
       
        public function handleItemEvent(e:ItemEvent):void
        {
            // do something here
        }
    }
}

Applying A Custom Class To An Object In The Document Class...
How's it going guys. I just started learning Actionscript 3.0 and so far not bad. However, I'm having trouble applying custom created classes to objects in the main document class. I'm using Flash as the application, however there is no timeline scripting involved. I loaded the document class called Main.as:


ActionScript Code:
package
{
    import flash.display.MovieClip;
    import flash.net.URLRequest;
    import flash.display.Loader;
   
    public class Main extends MovieClip
    {
        private var _redBox:Loader = new Loader();
        private var _redBoxLink:URLRequest = new URLRequest("images/redbox.jpg");
        public var buttonScaleHover:ButtonScaleHover = new ButtonScaleHover();
       
        public function Main()
        {
            _redBox.x = 100;
            _redBox.y = 100;
            _redBox.load(_redBoxLink);
            addChild(_redBox);
        }
    }
}

Now, what I'm trying to do is apply this class named ButtonScaleHover.as to the _redBox in the document class. Here is the code for ButtonScaleHover:


ActionScript Code:
package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
   
    public class ButtonScaleHover extends Sprite
    {
        private var _xScale:Number;
        private var _yScale:Number;
       
        public function ButtonScaleHover()
        {
            trace("The ButtonScaleHover Class is being loaded");
            _xScale = this.scaleX
            _yScale = this.scaleY
            this.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
            this.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
        }
       
        public function onRollOver(event:MouseEvent):void
        {
            this.scaleX *= 2;
            this.scaleY *= 2;
        }
       
        private function onRollOut(event:MouseEvent):void
        {
            this.scaleX = _xScale;
            this.scaleY = _yScale;
        }
    }
}

I tried using
ActionScript Code:
_redBox.ButtonScaleHover();
in the document class after i added it to the display object list. However, it didn't work. Basically, I'm just trying to apply a custom class to an object(in this case the loader). Thank you guys very much in advance.

Tween Class In Custom Extend MovieClip Class
I want to use the tween prototype in a custom class that extends MovieClip. I am already including "lmc_tween.as" in my root and I have already replaced the "MovieClip.as" file in my flash directory with the one from the shared/Zigo directory. However, I still get compiler errors if I try to include "lmc_tween.as" in the class file, or without the include in the class it will compile but the tween prototype will not work in the custom class. Does anyone know how to fix this?

Applying A Custom Class To An Object In The Document Class...
How's it going guys. I just started learning Actionscript 3.0 and so far not bad. However, I'm having trouble applying custom created classes to objects in the main document class. I'm using Flash as the application, however there is no timeline scripting involved. I loaded the document class called Main.as:

package
{
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.display.Loader;

public class Main extends MovieClip
{
private var _redBox:Loader = new Loader();
private var _redBoxLink:URLRequest = new URLRequest("images/redbox.jpg");
public var buttonScaleHover:ButtonScaleHover = new ButtonScaleHover();

public function Main()
{
_redBox.x = 100;
_redBox.y = 100;
_redBox.load(_redBoxLink);
addChild(_redBox);
}
}
}


Now, what I'm trying to do is apply this class named ButtonScaleHover.as to the _redBox in the document class. Here is the code for ButtonScaleHover:


package
{
import flash.display.Sprite;
import flash.events.MouseEvent;

public class ButtonScaleHover extends Sprite
{
private var _xScale:Number;
private var _yScale:Number;

public function ButtonScaleHover()
{
trace("The ButtonScaleHover Class is being loaded");
_xScale = this.scaleX
_yScale = this.scaleY
this.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
this.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
}

public function onRollOver(event:MouseEvent):void
{
this.scaleX *= 2;
this.scaleY *= 2;
}

private function onRollOut(event:MouseEvent):void
{
this.scaleX = _xScale;
this.scaleY = _yScale;
}
}
}


I tried using
_redBox.ButtonScaleHover();in the document class after i added it to the display object list. However, it didn't work. Basically, I'm just trying to apply a custom class to an object(in this case the loader). Thank you guys very much in advance.

API Documents For Custom Class Or Class Libraries
Is it possible to auto generate API Documents from class comments? If so, can this be done for an entire library?

Doc Class Talks To Custom Class Problems
Hello all,

I am trying to get a Doc class to initiate a function in custom class, but I cant get it to work. I am still very new to working with classes and hope any of you can shine some light onto this problem.

I have 2 MovieClips, one is animating across the the stage via its custom class, and the other is a button control through the Doc class. I want to button to stop the stage.event from animating the first movie across the stage and to rotate the movieclip a value of 20.

So far the movie clip just keeps on going and does not stop.

Here is my Doc Class Code.
Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import mcSquare;
import Movesq;

public class MasterMain extends MovieClip
{
private var _square:Movesq;

public function MasterMain ()
{
_square = new mcSquare;
btn.addEventListener(MouseEvent.CLICK, stopBlackSquare, false, 0, true);
btn.buttonMode = true;
}

private function stopBlackSquare():void
{
_square.stopLoop();
}
}
}
Here is the Custom class code ( class name is Movesq)


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

public class Movesq extends MovieClip
{
public function Movesq ()
{
this.addEventListener (Event.ENTER_FRAME, onLoop, false, 0, true);
}

private function onLoop (evt:Event):void
{
this.x +=5;
}
public function stopLoop ():void
{
this.rotation = 20;
this.removeEventListener (Event.ENTER_FRAME, onLoop);
}
}
thank you for your help in advance.

Pending Class OnResult In Custom Class.
Ok,
I have a custom class with private field:

private var test:Stringint the constructor I load the web service:

pws = new WebService(Constants.getWsURL() + "?WSDL");

then I call a method on the WS:

var pcLoadModel = pws.LoadModel();
pcLoadModel.onResult = pcLoadModel_Succ;
pcLoadModel.onFault = pcLoadModel_Fail;

where:
public function pcLoadModel_Succ(result){
//some code.
}

The problem is that where it says "some code", I cant access the members of my class! Why not? in the debugger I clearly see that I have left the scope of the instance of the class I was working from. I dont understand why this happens.

Anyone has an answer to this?
Thanks you :)
Jp

Dynamic Class Reference In Custom Class
I've created a custom class that I want to be able to dynamically insert a movie clip from the library. I'm running into trouble because I want to access the clip as a property of the custom class object (ie: so it can be swapped out for another library clip after instantiation, among other things). I'm using getDefinitionByName() but I can't use it outside my addDiagram() function (see attached code) because the string variable that stores the name of the library clip isn't defined until after the custom class constructor function. Any help is appreciated!

Thanks,
-Erik







Attach Code

public function Panel(panelTitle:String,
panelWidth:Number,
panelHeight:Number,
panelX:Number,
panelY:Number,
panelType:String = "",
panelDisplay:String = ""):void {
this.panelTitle = panelTitle;
this.panelWidth = panelWidth;
this.panelHeight = panelHeight;
this.panelX = panelX;
this.panelY = panelY;
this.panelType = panelType;
this.panelDisplay = panelDisplay;

...

//if panel is to display a diagram, add the diagram clip
protected function addDiagram():void {
var diagramClass:Class = getDefinitionByName(panelDisplay) as Class;
var panelDiagram:* = new diagramClass();
panelDiagram.x = getPanelX() + 5;
panelDiagram.y = getPanelY() + 20;
panelDiagram.scaleX = .95;
panelDiagram.scaleY = .65;

addChild(panelDiagram);
}

RectBorder In Loaded Swf
Hi

I have a TextInput component sitting in a movie. And I'm using this script to get rid of the default RectBorder ....
code:
passwordField.setStyle("borderColor", "none");

It works perfectly if I preview this movie alone. But I need to use a preloader container movie that loads the swf containing the TextInput component, and that *isn't* working.

Why should this happen? setStyle working on its own, but not if I load the swf into another movie?

thanks
mark

Importing Class To Custom Class
I'm writing my own class. (The Peacock class if you want to know.) I want to use the Tween class in my class, but I don't know how to import another class into my class. How do I go about that. Thanks.

A Custom Class Says My Class Is Null
Hi,

I have a class (Math2) with misc functions for my project. It has a function called CheckRelations() which basically checks a static array in another class (relation). But the Math2 class acts as if the Relation class is non-existent, even though I have imported it and I also have all files in the same folder. When I try to relate to the class in any way i get a Runtime-Error 1009 (Cannot access a property or method of a null object reference.)
I tried tracing the class along with two other classes (one imported, but another is not) the two classes trace fine: [class Human] [class relationship]. The Relation class when traced in the Math2 class results in a 'null'

Code for the CheckRelations function in math2 class: (takes in String value, and returns the index at which the input = relation.Type ( i.e. if (String_Input == Relation.Relations.Type) --> return i ) Return -1 if not found)
------------------------------------------------------------------------------------------------------------------------------
import Human;
import Relation; //notice that Relationship is not imported yet traces out fine

//......REST OF CLASS (other static functions

public static function CheckRelations(relationType:String):int {

///////Variables
trace(Human,Relation,Relationship); //Human and Relationship are classes I used to test problem
//Output: [class Human] null [class Relationship]
var relationType:String;
//relationType: the relation to look for in the relations array

var array:Array = Relation.Relations; //Relations is a public static var (array)
//array: the array to look inside

var relation:Relation;
//relation: used to hold temp values of relations to compare

var ReturnValue:int = -1;
//ReturnValue: the value to return

var i:uint;
//i: used in for..loops

///////Function
//SOURCE OF ERROR: any reference to Relation class
RelationCheck:for (i = 0; i < array.length; i++) {
relation = array as Relation;
if (relation.Type == relationType) { //relation.Type is a string value
ReturnValue = i;
break RelationCheck;
}
}
return ReturnValue;
}
------------------------------------------------------------------------------------------------------------------------------



Code for getRelation function in Relation class:
----------------------------------------------------------------------------------------------------------------------------
public static function getRelation(relation:String):Relation {
var val:int = Math2.CheckRelations(relation); // SOURCE OF ERROR

if (val == -1) {
GameError.InvalidRelation(relation); //throws error when an invalid relation is specified {this is NOT the problem I'm having}
}return Relations[relation];
}
---------------------------------------------------------------------------------------------------------------------------------------------------

Importing Class Into Custom Class
Hi there, I realise I'm not allowed to import classes into other classes but I am not sure how to achieve what I want. I want 2 custom classes to pass data one from another directly. I have 2 custom classes I want to use: one extends the XMLSocket Class:

ActionScript Code:
class Game extends XMLSocket {    import XMLParser //not allowed to do this I know!      var parser:XMLParser = new XMLParser();    function onXML(src:XML):Void {        //trace("xml:"+src);        parser.parseIt(src);    }}

....and the other is a custom class I want to use to parse XML data that the Game class receives from its XML Socket:

ActionScript Code:
class XMLParser {    public function XMLParser() {        // constructor    }    function parseIt(theXML:XML):Void {        trace("xmlParser received:"+theXML.toString());      //parsing code goes here    }}

As I say I realise I am not allowed to import the parsing class into my Game class (or any class for that matter) but I don't know how to pass data directly between these two classes without referencing them in the main FLA.
If anyone could let me know that would be a massive help, thanks !
Schm

That Combobox Rectborder Problem...
help:

http://www.kirupa.com/forum/showthre...78#post1765678

Hovers And Fade-outs
the answer to this must be very simple, but i can't seem to find it anywhere. right now i have a button that, when hovered over, has an image that fades in. however, when the mouse moves away from the button the image just disappears. i'd like the image to fade out as well when the mouse moves away from the button. i apologize if there is some place where i could easily find out the script or whatever for this... but alas, i am quite ignorant.

MX AS Question: Static Image Hovers?
Using this tutorial: http://www.kirupa.com/developer/mx/captions.htm

I successfully implemented this script, and have it working, etc. i would like to, however, do one of two things.

1: multiline formatted dynamic text in hovers? could this be achieved loading txt files? or is there a easier way? I can do multiline, but there is no way to format, or even do breaks.

2: Static txt loaded per picture hover? what would be the easiest way to tackle this? i thought maybe multible movie clips, but with the amount of pictures im dealing with, i wouldnt know where to begin.

help

Hover Caption Hovers In Different Location
Hi all,

I have a working hover caption function, the only problem I'm having is that the hover appears in one location and one location only. So every time I hover over different button,s the hover caption appears in one location. How do I have it so that the hover caption appears near each corresponding button (I have several buttons on the stage and all have the hover caption)?

Thank you!

MX AS Question: Static Image Hovers?
Using this tutorial: http://www.kirupa.com/developer/mx/captions.htm

I successfully implemented this script, and have it working, etc. i would like to, however, do one of two things.

1: multiline formatted dynamic text in hovers? could this be achieved loading txt files? or is there a easier way? I can do multiline, but there is no way to format, or even do breaks.

2: Static txt loaded per picture hover? what would be the easiest way to tackle this? i thought maybe multible movie clips, but with the amount of pictures im dealing with, i wouldnt know where to begin.

help

Drawing Green Halo Border With RectBorder
Hello,

I'm trying to create few custom AS2 components which would look similar to the standard components.

The component development checklist by Adobe suggests:

quote:Use the RectBorder class (mx.skins.halo.RectBorder) rather than graphical elements to draw borders around objects.

Unfortunately there aren't any docs or examples for that except the classes in the mxcontrols*.as files.

I have tried the following in my custom AS2 component:

quote:
public function createChildren():Void {
createClassObject(RectBorder, 'border_mc',
this.getNextHighestDepth(),
{ styleName: this, borderStyleName: 'default'});
}

private function size():Void {
super.size();
border_mc.setSize(width, height);
invalidate();
}


and I do see a thin grey rectangle border around it now.

But how do I get the standard haloGreen border, like the v2 Button has?

(And I want it to be themeable/skinnable as well)

Thank you for any hints
Alex

Movie Clip Will Move Left To Right Continuesly When Mouse Hovers On Bu
  I have a flash movie that displays and loops my 40 logos inside a movie clip...

 then,I have two big Button Arrows on each side(left & right  side)on the main movie.

 I need these arrows to be functional..
- when mouse hovers on left arrow, the logoClips will move fast right to left
- when mouse hovers on right arrow, the logoClips will move left to right.

 can you guys help me?

note: movie clip logos are already moving right to left slowly using motion tween, I need to put button arrows to navigate. If you have better version ...pls help

 thanks in advance.


XML With Custom Class
I am having some difficulties loading XML from an external class. I would like to place the firstChild into a Dynamic Text Box. In my Flash movie the text box is labeled LevelTitle. This is my code at the moment:


Code:
class SelectTest extends XML {
var Testlist: XML;
var curContainer:XMLNode

function SelectTest() {
var Testlist = new XML;
Testlist.load("TestList.xml");
Testlist.ignoreWhite = true;
Testlist.onLoad = getTest()

}

function getTest() {
trace ("success");
var LevelTitle= Testlist.firstChild
trace (LevelTitle);
}
}
It always traces "sucess" leading me to believe that the xml is loading successfully, but when I try to trace LevelTitle, (or Testlist.firstChild, or Testlist.toString()) I always get undefined. What am I doing wrong?

(AS1) Need Some Help With XML And A Custom Class...
Okay, I know I should be able to figure this out, but it's been bugging me for a while. I've created a program that reads in XML and ends up dumping the contents to a class I've written, and the way I have it now, it works. BUT, I'm doing things in a very sloppy way in that my xml.onLoad function is not properly defined as a method of the class, because I'm stumbling over syntax problems with "this".

So, here's the real question. If I'm creating a method for a class which is going to be used as an xml.onLoad function, how do I refer to the xml tree being passed to the function when "this" always relates to the class itself, rather than the xml tree?

And for those like me who can picture these things better when I can see some code, here's an example:


Code:
some_class = function(xmlLocation) {
var xmlInput = new XML();
xmlInput.onLoad = load_xml;
xmlInput.load(xmlLocation);
};

some_class.prototype.load_xml = function() {
var e = this.firstChild;
// the "this" reference points to the class itself
// DOESN'T WORK
};

load_xml = function() {
var e = this.firstChild;
// the "this" reference points to the xml tree
// WORKS but SLOPPY
};
My thanks in advance to anyone brave enough to tackle this one...

Custom Class Help
I wrote a simple class for linking movie clips to external websites. The constructor takes two arguments -- (mc:MovieClip, url:String).

It would probably be easier to take a quick glance at the code in full:


Code:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.net.navigateToURL;
import flash.net.URLRequest;

public class MakeLink extends MovieClip {

private var _mc:MovieClip;
private var _url:String;

public function MakeLink(mc:MovieClip, url:String) {
_mc = mc;
_url = url;
_mc.addEventListener(MouseEvent.ROLL_OVER, showHandCursor);
_mc.addEventListener(MouseEvent.CLICK, addURL);
}

private function showHandCursor(event:MouseEvent):void {
_mc.buttonMode = true;
_mc.useHandCursor = true;
}

private function addURL(event:MouseEvent):void {
var request:URLRequest = new URLRequest(_url);
navigateToURL(request, "_blank");
}
}
}

Code:
import MakeLink;
var myLink:MakeLink = new MakeLink(myMC, "http://www.google.com");
Easy enough, but I'm running into some problems adding this functionality to sprites as well. I thought it would be possible to create an optional argument (mc:MovieClip, sp:Sprite, url:String) ... and then just leave out either mc or sp depending on what I need (,sp, url) or (mc,,url) but that spits errors.

What would be the/a proper way of doing this? Any help is appreciated.

Add Custom Class To CS
Total CS/AS3 noob, I'm trying to install/include a class I wish to use with CS -- Fzip

The Fzip files can be found here: http://codeazur.com.br/lab/

Once downloaded, I have a package of files, none of which provide clear details on how to install this package, however all the .as files are within 2 folders: fzip and utils. Those 2 folders are within a parent folder, deng. which resides within the download package as: fzip/src/deng

HTML documentation is provided that refers to the package deng.fzip and within that package are classes FZip, FZipErrorEvent, FZipEvent, FZipFile, FZipLibrary.

No mention is made in the package as to what the 'public definition' is, but I'm assuming it would be the class name, which is the same as the .as file without the .as

So, I've placed the entire download folder in my project's root folder: myproject/fzip, then I've followed the Help instructions to set a classpath to myproject/fzip/src/deng by using the target tool to browse to and choose that folder. Also on the ActionScript 3 Settings pane, I've set Document class to FZip (I'm not sure if that's right, but there's no instructions in the Help files about this field)

Next, on the first line of Frame1, I write the following:

import exampe.FZip;

I test my movie and get: Definition example:FZip could not be found.

I've also tried the entire path to the .as file (with no classpath via Publish settings):

import fzip.src.deng.fzip.FZip;

(fzip/src/deng/fzip/FZip.as)

Any help or ideas much appreciated.

TIA

Len

Help With Custom Class
Sorry if this is a dumb question but I am unclear on this topic since I haven't yet created any custom classes in actionscript. I have a file called Floater.as inside a folder called tod. I have a flash movie that contains the tod folder. Inside my Floater.as file I have the following code. In my movie I'm trying to create an instance of this class by importing tod.Floater and then creating a new Floater object. But when I try I get two errors for the initializer line "var f:Floater = new Floater("test1", "test2");".

1046: Type was not found or was not a compile-time constant: Floater.
1180: Call to a possibly undefined method Floater.


Code:
package tod{

import flash.display.MovieClip;

class Floater extends flash.display.MovieClip{

private var _title:String;
private var _desc:String;

public function Floater(titleText:String, descText:String){
_title = titleText;
_desc = descText;
trace(_title);
}

}
}
Do I have my structure messed up somehow? If not, what am I doing wrong that flash can't see this class I'm trying to create? Thanks.

Custom XML Class
I have a class that loads some XML and returns a XML List, but I think it's not as efficient as it could be - seems to be too heavy in that I'm including a lot of resources that I don't need.

For instance, to dispatch an event, I found that I had to extend at least a Sprite to avoid errors (even with importing event stuff).

I was wondering if anyone had any ideas on how to better do this?


ActionScript Code:
package _resources._packages._fidoXML {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.net.*;
   
    public class fidoXML extends Sprite {
        var myXML:XML;
        var xmlLoader:URLLoader = new URLLoader;
        var myXML_List:XMLList;
       
        public function fidoXML(xmlLoc:String):void {
            xmlLoader.load(new URLRequest(xmlLoc));
            xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, onError);
            xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
        }
       
        private function onError(event:IOErrorEvent):void {
            trace(event.text);
        }
       
        private function xmlLoaded(event:Event):void {
            myXML = XML(event.target.data);
            myXML_List = myXML.children();
            dispatchEvent(new Event('xmlLoaded'));
        }
       
        public function get fidoXMLList():XMLList {
            return myXML_List;
        }
    }
}

Help With Custom Class
Below is the code I have in my .as file (called "BallGameClass.as"). It doesn't work and I get these errors in the output panel:
_____
1120: Access of undefined property stage.
1120: Access of undefined property moveMC.
1120: Access of undefined property keyPressed.
1120: Access of undefined property keyReleased.
1120: Access of undefined property rotateMC.
_____
Any help is appreciated. Thanks in advance.


ActionScript Code:
package
{
    import flash.display.MovieClip;
    import flash.events.*;
   
    class BallGameClass extends MovieClip
    {
        var yspeed:Number = 0;
        var xspeed:Number = 0;
        var wind:Number = 0.00;
        var power:Number = 0.65;
        var gravity:Number = 0.1;
        var upconstant:Number = 0.75;
        var friction:Number = 0.99;








        var upKeyDown:Boolean = false;
        var downKeyDown:Boolean = false;
        var leftKeyDown:Boolean = false;
        var rightKeyDown:Boolean = false;
        stage.addEventListener(Event.ENTER_FRAME, moveMC);
        function moveMC(event:Event):void {
            this.y = this.y + yspeed;
            this.x = this.x + xspeed;

            xspeed = (xspeed + wind) * friction;
            yspeed = yspeed + gravity;

   
   
           
            if (upKeyDown == true) {
                yspeed = yspeed - power * upconstant;
            }
            if (downKeyDown == true) {
                yspeed = yspeed + power * upconstant;
            }
            if (leftKeyDown == true) {
                xspeed = xspeed - power;
            }
            if (rightKeyDown == true) {
                xspeed = xspeed + power;
            }
        }
        stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
        stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
        function keyPressed(event:KeyboardEvent):void
        {
            if (event.keyCode == 38){
                upKeyDown = true;
            }
            if (event.keyCode == 37){
                leftKeyDown = true;
            }
            if (event.keyCode == 39){
                rightKeyDown = true;
            }
            if (event.keyCode == 40){
                downKeyDown = true;
            }
        }
        function keyReleased(event:KeyboardEvent):void
        {
            if (event.keyCode == 38){
                upKeyDown = false;
            }
            if (event.keyCode == 37){
                leftKeyDown = false;
            }
            if (event.keyCode == 39){
                rightKeyDown = false;
            }
            if (event.keyCode == 40){
                downKeyDown = false;
            }
        }

       
        function convert(radians:Number):Number {
            var degrees = radians * (180 / Math.PI);
            return degrees;
        }
        
        
        stage.addEventListener(Event.ENTER_FRAME, rotateMC);
        function rotateMC(event:Event):void {
             var adjacent:Number = this.x - mouseX;
             var opposite:Number = this.y - mouseY;
             var angle:Number = Math.atan2(opposite, adjacent);
             this.rotation = (convert(angle))-90;
        }
       
    }
}

Using A Custom Class
i am just starting to program and am making my own web site.
i have just converted the photoviewer tutorial into a custom class to be used as a function from my main fla file.
i have many layers in my fla file and other action script how can i asine it to a layer so i can view the photos

thanks

Xml In Custom Class
I apologize if this has been properly addressed somewhere but i'm starting to chase my tail on it so i think i have to post for help.

My true desire is to get [1] working below but i can't figure why any information given to PROPS is not retained in the xml load method...even if its static. When i use the Properties class i always get 'Reading xml...' whether I use [1] or [2]. At first i thought it wasn't even being invoked until i did [3] and saw that infact it was.

What am I doing wrong? Thx in advance.


ActionScript Code:
class Properties {
   
    var PROPS:Object = new Object();
    var xml:XML;
   
    public function loadProperties( file:String ) :Void {
        PROPS["SOME_VAR"]="Reading xml...";
        /* load config file */
        xml = new XML();
        xml.ignoreWhite = true;
        xml.load( file );
        xml.onLoad = mx.utils.Delegate.create(this, xmlLoaded);
    }
       
    function xmlLoaded( success:Boolean ) {
            if ( success ) {
                //PROPS[xml.childNodes[0].childNodes[0].nodeName]=xml.childNodes[0].childNodes[0].firstChild.nodeValue; // [1]
                //PROPS["SOME_VAR"]="Success loading xml"; // [2]
                _root.debugTxt=xml.childNodes[0].childNodes[0].firstChild.nodeValue; // [3]
            }
   
    }
   
}

Custom Class
Howdy fella geeks,

Check out this code:

var mc:MovieClip = new MovieClip()
mc. <-- after I type . (dot) it shows me a drop down menu with all the public functions/properties

But if I create a custom class called "bike" and try the same thing, when I type . (dot) it doesn't show me a drop down menu with all the public functions/properties.

var b:bike = new bike();
b. <-- this shows me nothing

What am I doing wrong? var b:bike = new bike(); works so I know it sees my class, but it's not seeing the public stuff.

Thanks

tk










Attach Code

package {
public class bike {
public var speed:Number;
public function forward() {
}
public function backward() {
}
}
}

Custom Class
I have developed two custom classes that extend the movie clip class. They first class (Table) draws a cool table and attaches Row objects to it which display the data. This is one part of a larger project.

There is a method inside the Table class clearRow() that fades all the rows out one by one then removes the Table object. This works fine the first time the class is instantiated; however, the second time the clearRow() functions fades and removes the whole stage. If anyone could tell me what is going on I'd be very grateful. Source files attached. Thank you all.

Custom Class
Trying to learn how to make custom classes. Just want to have two functions from the class. One to fade a mc(circle_mc) out and another to fade it back in again. I can get the class to trace to the fla file but can't get the movieclip to tween at all.

import mx.transitions.Tween;
import mx.transitions.easing.Regular;
import mx.transitions.easing.Strong;

==================class file==================== .....

XML In Custom Class?
why wouldn't this work as an AS2.0 class? the 'myXml' value always comes up undefined. i've established that it is loading the xml file and i've tried local and online xml files and i'm just stuck... i'm new to class building.

thanks for your help.


the as file...

Code:
class com.news.newsXML
{
//
private var myXml:XML;

//
public function newsXML()
{
init();
}
//
private function init():Void
{
trace("init();");
myXml = new XML();
myXml.ignoreWhite = true;
myXml.onLoad = parseNews;
myXml.load("any.xml");
}
//
private function parseNews():Void
{
trace("Function: parseNews();");
trace("myXml == " + myXml);
}
}
in the fla...


Code:
import com.news.newsXML;
var newsObj:newsXML = new newsXML();

Custom Class
I'm trying to write my first custom class and I am having a few problems with it. If anyone could point out where my problems are or give a link to a good resource on learning more about custom classes that would be wonderful.


Code:
class spawnTextFields {
public function spawnTextFields(target:String,txtName:String,depth,xLoc,yLoc,setStr:String){
if(depth == null){
depth = this.getNextHighestDepth();
}

target.createTextField([txtName],[depth],0,0,0,0);
target.txtName.text = [setStr];
target.txtName.autoSize=true;
}
}
When I run that I get the following errors:

There is no method with the name 'getNextHighestDepth'.

AS 3 Custom Class
I have been trying to convert the code posted previously to a custom class:


Code:
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.display.StageDisplayState;
import flash.accessibility.AccessibilityProperties;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextLineMetrics;
import flash.text.AntiAliasType;
import flash.text.TextFormat;
//----------------------------------------------------------------
import flash.utils.getDefinitionByName;
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundChannel;
//----------------------------------------------------------------
var stage:Stage;
var content_tb:TextField;
var xmlLoader:URLLoader;
//----------------------------------------------------------------
stage.displayState = StageDisplayState.FULL_SCREEN;
stage.scaleMode = StageScaleMode.NO_SCALE;
//----------------------------------------------------------------
content_tb.embedFonts = true;
content_tb.selectable = false;
//----------------------------------------------------------------
var clickSound:Sound;
var librarySoundOne:Class = getDefinitionByName ( "Click" ) as Class;
clickSound = new librarySoundOne();
var clickChannel:SoundChannel;
//----------------------------------------------------------------
var dingSound:Sound;
var librarySoundTwo:Class = getDefinitionByName ( "Ding" ) as Class;
dingSound = new librarySoundTwo();
var dingChannel:SoundChannel;
//----------------------------------------------------------------

public class LoadXML extends MovieClip {
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("xml/modernism.xml"));

// Constructor
public function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
LoadContent(xmlData);
}
// Method invoked automatically when the XML finishes loading
function LoadContent(textData:XML):void {
//CONTENT TO BE DISPLAYED ON INITIAL LOAD
var defaultText = textData.item[0].content.text();
var pageTitle_text = textData.item.label.text()[0];
pageTitle_tb.htmlText = "<b>" + pageTitle_text + "</b>";
var formatSpacing:TextFormat = new TextFormat();
formatSpacing.letterSpacing = 4;
pageTitle_tb.setTextFormat(formatSpacing);

//----------------------------------------

function setPage(page:Number):void {
field.scrollV = (page - 1) * linesPerPage + 1;
}
// Assigns the text field that is on the stage to a local variable
var field:TextField = content_tb;
field.embedFonts = true;
// Assign the content to the text field
field.htmlText = defaultText;

// Extracts the text format and line height properties
var format:TextFormat = field.getTextFormat();

var leading = int(format.leading);
var extent:TextLineMetrics = field.getLineMetrics(0);
var ascent = extent.ascent;
var descent = extent.descent;

// CALCULATE THIS NUMBER USING BODY TEXT OF THE SAME FONT SIZE
// IF HTML TEXT INCLUDES HEADINGS OF DIFFERING SIZES THE NUMBERS WILL BE SKEWED
//var lineHeight = ascent + descent + leading;
var lineHeight = 16;
var linesPerPage = Math.floor((field.height - 4 + leading) / lineHeight);
var lineCount = (field.maxScrollV - 1) + linesPerPage;
var pageCount = Math.ceil(lineCount / linesPerPage);

var offset = (linesPerPage * pageCount) - lineCount + 1;
var lineBreak:String = "<br />";
//var lineBreak:String = "
";

for (var i = 0; i < offset; i++) {
defaultText.htmlText += lineBreak;
}
//LINE BELOW IS A NECESSARY REPEAT
field.htmlText = defaultText;

var panelNum = pageCount;
var curNum = 1;
pageNum.htmlText = "<b>" + curNum + "</b>";
pageTotal.htmlText = "<b>" + panelNum + "</b>";
prevButton_mc.visible = false;

function NextOnClick(event:MouseEvent):void {
curNum++;
pageNum.htmlText = "<b>" + curNum + "</b>";
setPage(curNum);
if (curNum == 2) {
prevButton_mc.visible = true;
clickChannel = clickSound.play();
} else if (curNum == panelNum) {
event.currentTarget.visible = false;
curNum = panelNum;
dingChannel = dingSound.play();
} else {
clickChannel = clickSound.play();
}

}
nextButton_mc.buttonMode = true;
nextButton_mc.addEventListener(MouseEvent.CLICK, NextOnClick);

function PrevOnClick(event:MouseEvent):void {
curNum--;
pageNum.htmlText = "<b>" + curNum + "</b>";
setPage(curNum);
if (curNum == 1) {
setPage(curNum);
event.currentTarget.visible = false;
curNum = 1;
dingChannel = dingSound.play();
} else {
clickChannel = clickSound.play();
}
nextButton_mc.visible = true;
}
prevButton_mc.buttonMode = true;
prevButton_mc.addEventListener(MouseEvent.CLICK, PrevOnClick);
}
}
}
I've managed to eliminate all the errors except one:


Code:
1067: Implicit coercion of a value of type Class to an unrelated type Function.
That error refers to the following line:


Code:
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
The compiler doesn't like the name of the public function I guess. Shouldn't the public function name be the same as it's class name? Hopefully someone can spot the issue. (I'm sure I'll get a whole other group of errors once this is fixed)

[Q] Custom Class
Hello Children of the Lee,

I'm writing a Tile Class that allows you to apply a tiled background that, at the moment, using an image from your library. I was doing well until i ran a couple of tests...Code:

import net.actionscriptblog.drawing.Tile

// Usage 1: fill stage
var bkg:Tile = new Tile();
bkg._id = 'tile1.gif';
bkg._width = Stage.width;
bkg._height = Stage.height;
bkg._clip = this;
bkg.fill();

// Usage 2: with equal margins
var layer1:Tile = new Tile();
layer1._id = 'tile2.gif';
layer1._width = Stage.width - 10;
layer1._height = 60;
layer1._margin = 10;
layer1._clip = this.createEmptyMovieClip('layer1_mc', this.getNextHighestDepth());
layer1.fill();
...which works like butter but when i add the third tile, no matter the properties, no matter if is switch layer1 & layer2, that third tile gets screwed up...Code:

// Usage 3: with different margins
var layer2:Tile = new Tile();
layer2._id = 'tile3.gif';
layer2._width = 100;
layer2._height = 300;
layer2._left = 10;
layer2._top = 100;
layer2._clip = this.createEmptyMovieClip('layer2_mc', this.getNextHighestDepth());
layer2.fill();
... it seems to that my code does not allow you to add more than two tiles.... here's a snippet of my ClassCode:

import flash.display.BitmapData;
//import mx.managers.DepthManager;

class net.actionscriptblog.drawing.Tile
{
   // variables
   private var tile:BitmapData;
   private var stage:Boolean;
   private var movieclip:MovieClip;
   
   // properties
   public var id:String;
   public var width:Number;
   public var height:Number;
   public var clip:MovieClip;
   
   // default properties
   public var margin:Number = 0;
   public var left:Number = 0;
   public var top:Number = 0;

   // constructor
   public function Tile (linkage_id:String, movieclip:MovieClip, width_num:Number, height_num:Number, left_num:Number, top_num:Number)
   {
      if (arguments.length != 0)
      {
         // set properties
         this.id = linkage_id;
         this.width = width_num;
         this.height = height_num;
         this.clip = movieclip;
         
         if (left_num != undefined) this.left = left_num;
         if (top_num != undefined) this.top = top_num;
      }
      else
      {
         // do nothing
      }
   }

   public function fill(width_num:Number, height_num:Number, marginLeft_num:Number, marginTop_num:Number)
   {
      if (arguments.length != 0)
      {
         this.clip.beginBitmapFill(tile);
         this.clip.moveTo(margin_left, margin_top);
         this.clip.lineTo(width_num, margin_top);
         this.clip.lineTo(width_num, height_num);
         this.clip.lineTo(margin_left, height_num);
         this.clip.lineTo(margin_left, margin_top);
         this.clip.endFill();
      }
      else
      {
         this.clip.beginBitmapFill(tile);
         this.clip.moveTo(this.left, this.top);
         this.clip.lineTo(this.width, this.top);
         this.clip.lineTo(this.width, this.height);
         this.clip.lineTo(this.left, this.height);
         this.clip.lineTo(this.left, this.top);
         this.clip.endFill();
      }
   }
}
I'm I going to need the Delegate or the DepthManager Class?

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