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




ButtonMode On Loader Object?



I'm using XML and a loader to dynamically load images (client logos) into my tesimonials page.I want it so that when the user clicks on the image loaded into the loader, it takes them to the client's website.Well, I have the link/click functionality working great...but there is no hand cursor when the user hovers over the image.....how can I set it so the loader shows the hand cursor when the user is over it???I've already tried casting it as a MovieClip, but that throws me errors too...



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 10-31-2007, 05:17 AM


View Complete Forum Thread with Replies

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

Loader And ButtonMode
Hello all,
I have just started to get into as3 development and have ran into a snag. I am trying to load an external image (a thumbnail) and then make that thumb clickable. I can get the thumb clickable but am having trouble adding buttonMode to change the cursor to the "link cursor".
below is my simple code:


Code:
public function mouseDown($e:Object) : void
{
trace("pressed"+$e.target)
}


private function onComplete($e:Object) : void
{
$e.target.loader.addEventListener(MouseEvent.CLICK, mouseDown);
$e.target.loader.buttonMode = true;
navItemLoaded++;
if (navItemLoaded==navLength)
{
this.positionNav();
}
}

private function buildNav() : void
{
for (var i : Number = 0; i < navLength; i++)
{
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete)
var urlReq:URLRequest = new URLRequest(shell.GALLERY..@thumb[i]);

ldr.load(urlReq);
shell.addChild(ldr);

thumbArr.push(ldr);
}
}

Loader Object For FLV, SWF
I'm trying to make a movie player of a sort that loads all the things in a folder and plays them one by one. This folder can contain images, flvs and swfs. Is this possible ? Anyone having some code or project lying around doing something similar, need help

[loader Object]
hey, i'm using a *stupid* loader that won't load certain pictures. yes, the path is correct. and yes, it will load other pictures in the same dir with very similar properties.

has anyone else run into this problem before???

Set ButtonMode In A Loop
Hey All--

First, I'll show you some of my code:


ActionScript Code:
var thumbLoader:Loader;

for (var i:int = 0; i < xmlList.length(); i++)
    {
        //Load thumbnail
        thumbLoader = new Loader();
        thumbLoader.load(new URLRequest(xmlList[i].thumb));

        //Renaming thumbnail instance
        this.thumbLoader.name = "item" + [i + 1];

        //Add thumnail to stage
        addChild(thumbLoader);
    }

Here's what I don't get: I can easily change the X and Y positions, make mouse events, etc., from the externally loaded .jpg files, why can't I turn buttonMode on?

Any help would be greatly, greatly appreciated.

Thanks.

ButtonMode=true
Do I have to call this function buttonMode = true on every MC where I want to show the hand pointer.

Alnoor

Buttonmode On FlvPlayBack
Hello Kirupa members,,

I want to ask something, do someone knows how to show the hand icon when rollover on a button of FLVPlayback component? Looks a simple task, but for some reason it does not works. I saw in a documentation that FLVPlayback does not comes with some movieclip things (like buttonmode), so, how to acomplish this task?

Thanks,,

ButtonMode Issues
Hi !

how do you make the deepest children in buttonMode true but not the parent? for example I have a main movieclip say family, whereby its children movieclips are named father, mother, brother and sister movieclips being the sister as the youngest she will be the deepest in the nested clips. However, sister will only be the one who will be 'clickable' if that makes sense...

I have this application in as3 (in windows xp platform, sp3) and buttonMode does not seem to function properly. Only I have turned off the buttonMode for the main movieclip and turned it on the deepest movieclip in its children.

thanks in advance!

AS3 - ButtonMode Not Working
Hey i am trying to create a sprite that acts as a button. Here is what i do:

1. Create a _container (Sprite)
2. Create a _sprite; a simple box filled with color (Sprite)
3. Create a _label (TextField)
4. Once all that is created i add them to stage like so and asign the buttonMode = true; to the _container.

Code:
addChild(_container);
_container.addChild(_sprite);
_container.addChild(_label);

_container.buttonMode = true;
_container.hitArea = _sprite;
When i have the mouse over the _container it uses a hand cursor but when i rollover the _label it goes back to the arrow. What is the problem here ? what am i doing wrong? Any help would be appreciated. Thanks

Reusing Loader Object
Hi there

I am having some troubles with adding the same Loading object to the stage more than just one time. I am working on a project, where I need to use the same image several times at once. No problems loading the images, but I only want to load the one time off course!

Loading the images:

Code:
function loadImage():void
{
var imageLoader:Loader = new Loader();

imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageOnLoadHandler);
imageLoader.load(new URLRequest(urlArray[loadImageCounter]));

imageArray[loadImageCounter] = imageLoader;
}


Adding the images to the stage:

Code:
function addImagesToStage():void
{
for (var i:int = 0; i < imageArray.length; i++)
{
var imgDaysLoader:Loader = imageArray[i];
var imgHoursLoader:Loader = imageArray[i];

imgDaysLoader.x = 0;
imgHoursLoader.x = 200;

addChild(imgDaysLoader);
addChild(imgHoursLoader);
}
}

Loader Object Question
Lets say you are loading a image from a url into the loader object. How would you detect if that url is broken or the image doesn't exist then it would load a alternative image.

Thanks...

Clone Loader Object?
Hello there!

Is there any way to clone a Loader object?

ByteArray From Loader Object
Hello there!

With Loader.loadBytes(bytes:ByteArray) you can load a byte array into a loader object.

Is it somehow possible to get the ByteArray from a Loader object or from its LoaderInfo?

[object Loader] Not Reloading
hi, I have an XML image that I loaded into a sprite and then the sprite into an array, I'm trying to now retrieve the [object Loader] that is in the original array, and display it. however, I keep getting a blank space instead. Is there any particular way to do this?

Loader Object Hell
Not sure why, but I'm having trouble grasping the loader object's real functionality.

I understand images are children of the object and the object is a child of a sprite, but I'm still having problems and hopefully someone can walk me through this.

On my stage I have six sprites and in them I've loaded images. What I need to do is randomly fade one out and fade another in its place. The images need to fade completely out before fading in again.

I've got a timer setup for 3 seconds between image changes and in that time I'm having Flash choose the next sprite to replace and preload the image. The images are all very small so 3 seconds is long enough to preload.

My logic is this:

- choose a random sprite
- load the image
- timer elapses
- fade out sprite
- add loader to sprite
- fade in sprite
- repeat

How do I do this? Do I need two loaders for each sprite or just two for the whole movie?

Any help is appreciated.

:grimey

Object Loader Info
Hi--

I know I've done this before, but am having brain freeze or something and can't get it to work.

I've got a few spites on stage that are created dynamically and live in an array. I'm rotating images through these sprites and now need to know which image is in a sprite when clicked. My code:

loading the images:


Code:

var loader:Loader = new Loader();
var request:URLRequest = new URLRequest(imgPath+"1.jpg");
loader.load(request);
spriteArray[1].addChild(loader);



click function:


Code:

function click1(e:Event) {
trace (spriteArray[1].getChildAt(0).content);
}



my click1 function above returns [object bitmap]. I'd like something like to see "1.jpg". What am I missing?

Thanks!

:grimey

Static/dynamic= || = ButtonMode?
this may not be an as3 question...i have an mc with dynamic text. It has buttonMode and useHandCursor both set to true...but upon mousing over, it ain't happening....i have another similar button which does all that i want it to do...difference? The good button has a static text box....is this the key problem? what's the fix?

Apply To Global Buttonmode
I have a site thats finally functioning the way i want it, but i didn't add any rollover effects anywhere in the site. Looking back at it, that was probably a bad idea...

i was curious, how would i go about writing a global buttonmode rollover that just dropped the opacity to .66 on mouse over. That way anything i set buttonmode = true on would at least give some interface feedback.

Conflict Between .buttonMode And KeyboardEvent?
Hello,
Ok I post on
tek-tips.com/viewthread.cfm?qid=1524696&page=1
nha khoa.com/thread?=12234
I've made a game. But as soon as I enable buttonMode for my buttons ('play game', 'instructions', etc) it breaks my keyboard controls for the game.
CODE
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyIsDown);

Once I set btnPlay.buttonMode = true, the keyIsDown function is no longer fired.

Any ideas? Thanks.
frozenpeas

ButtonMode Is Not Working Over A Text Box
this may not be an as3 question...i have an mc with dynamic text. It has buttonMode and useHandCursor both set to true...but upon mousing over, it ain't happening....i have another similar button which does all that i want it to do...the difference? The good button has a static text box....is this the key problem? what's the fix?-

i've included a snippet of code...BTW, if it has to do with text, i have the font embedded and linked.







Attach Code

public class ReverseFloor extends MovieClip
{
private var textBox:TextField;
private var bx:MovieClip;
public function ReverseFloor():void
{
init();

}
private function init():void{
this.stop();
this.buttonMode=true;
this.useHandCursor=true;
bx=MovieClip(this.getChildByName("box"));
bx.gotoAndStop(1)

textBox=TextField(this.getChildByName("tBox"));
this.addEventListener(MouseEvent.CLICK,flip)
this.addEventListener(MouseEvent.MOUSE_OVER,green)
this.addEventListener(MouseEvent.MOUSE_OUT,brown)
}

Textfield Within MC Interferes With ButtonMode
Scenario: a Movieclip used as a button contains the background graphic on the bottom layer and a dynamic textfield on the top layer. The AS 3 code used for this MC uses buttonMode to enable the cursor, but the textfield (gameButton.label) is interfering with this. Anyone know why?


Code:
public function showGameButton(buttonLabel:String) {
gameButton = new GameButton();
gameButton.label.text = buttonLabel;
gameButton.x = 220;
gameButton.y = 300;
gameButton.buttonMode = true;
gameButton.useHandCursor = true;
gameSprite.addChild(gameButton);
gameButton.addEventListener(MouseEvent.CLICK,pressedGameButton);
}

Papervision MovieAssetMaterial And ButtonMode
I have a MovieAssetMaterial and i apply it to a plane..

but I cant get the hand cursor to work. if i set the viewport to buttonMode = true .. it makes the whole thing have a hand cursor.

I read bunch of examples on the net and couldnt get it to work because either they were using older version of pv3d.

anyone?

ChildImage.buttonMode = True;
var coneBlackMaterial:BitmapFileMaterial = new BitmapFileMaterial(thumb_url);
coneBlack = new Plane( coneBlackMaterial, 250, 200, 3, 3);
planes.push(coneBlack); // push Plane objects into storage array
trace(planes[i]); // reference Plane objects in storage array
var childImage = planes[i];
rootNode.addChild(childImage);


Hi all
This new bitmap material object loads onto the stage fine.
But I am seeming to scratch my head when it comes to

adding
childImage.buttonMode = true;

and it is busting the whole gallery.

many thanks if you can help.

Conflict Between .buttonMode And KeyboardEvent?
I've made a game. But as soon as I enable buttonMode for my buttons ('play game', 'instructions', etc) it breaks my keyboard controls for the game.

CODEstage.addEventListener(KeyboardEvent.KEY_DOWN, keyIsDown);

Loader Object Reference From MovieClip
Good afternoon coders. I'm trying to reference a loader Object on the maintime line from within a MovieClip. More clearly, when I press one of my buttons (myCars or myVideos) I need my transition movieclip named container to play. Once the movieclip reaches a particular frame, I need the code in that frame to run.


First, here's the code on the main timeline:


import flash.display.*;


var my_loader:Loader = new Loader();
addChild(my_loader);

var container:blue=new blue();
container.name = "myContainer";
container.x=10.0;
container.y=74.0;
this.addChild(container);


var lastLoaded:String;

myVideos.addEventListener(MouseEvent.MOUSE_DOWN, loadTheBaby);
myCars.addEventListener(MouseEvent.MOUSE_DOWN, loadTheCars);


function loadTheBaby (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay("motivate");

}
}

function loadTheCars (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay("motivate");

}
}

Now, here's the code I need to run when the movieclip named container reaches a certain frame:

stop();

//lastLoaded=e.currentTarget.name;
my_loader.load(new URLRequest(lastLoaded+".swf"));
my_loader.contentLoaderInfo.addEventListener(Progr essEvent.PROGRESS, loop);
my_loader.contentLoaderInfo.addEventListener(Event .COMPLETE, done);

function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(my_loader);
gotoAndPlay("closeup");
}



Here are the error messages:


1120: Access of undefined property my_loader.
1120: Access of undefined property lastLoaded.


the variable lastLoaded is on the main timeline, and the loader Object my_loader is also on the main timeline. So, I believe I need to reference the loader Object and the lastLoaded variable on the main timeline from within a movieclip. I tried root.my_loader; I tried parent.my_loader to no avail. I even tried to put the loader object and the lastLoaded var in the movieclip and ran into a laundry list of errors. Is there a new way to access objects and variables on the main timeline from within a movieclip? Please steer me in the right diirection. Thanks for reading.


xFLASHSTUDENTx

Dragging A Loader Object With StartDrag()
Is it possible to drag a Loader object with startDrag()? I have a dynamically loaded image I'm trying to make dragable. I get a "1061: Call to a possibly undefined method startDrag through a reference with static type flash.display:Loader." error. I assume it's because I can only drag MovieClips and Sprites.


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

    public class PhotoLoader extends MovieClip {

        public var photoDownloader:Loader = new Loader();

        public function PhotoLoader (event:Event):void {
            var url:String = "./files/" + fileReference.name;
            var photoUrl:URLRequest=new URLRequest(url);
            statusArea.text= fileReference.name + " loaded.";
            photoDownloader.mask = photoHolder;
            photoDownloader.load (photoUrl);
            addChild (photoDownloader);
        }
        private function onMouseDown (event:MouseEvent):void {
            stage.addEventListener (MouseEvent.MOUSE_UP, onMouseUp);
            photoDownloader.startDrag ();
        }
        private function onMouseUp (event:MouseEvent):void {
            stage.removeEventListener (MouseEvent.MOUSE_UP, onMouseUp);
            photoDownloader.stopDrag ();
        }
    }
}

Problem Loading In SWF Into Loader Object
Hi,

I need help (typical tight deadline so any help appreciated).

I have a Flash movie and on Frame 1 is my preloader, and on Frame 2 is a movieclip which has one frame within it.

The Movieclip then does some animation via AS3 and then creates a loader object and adds it to the display list. The AS3 code then attempts to load another SWF into the loader object (the SWF is in the same folder as the parent SWF).

I have a preloader that checks the loading of the loader object and that is running fine, but the SWF just doesn't load?

I don't know if this has anything to do with the line "var req:URLRequest = new URLRequest("Home.swf");" and the fact that im loading the SWF into the loader object which is within a movieclip?

My code for creating the loader object is as follows....



Code:
// First request the file
var req:URLRequest = new URLRequest("Home.swf");

// Next create a loader object
var loader:Loader = new Loader();

// Then tell the loader object to load the requested file
loader.load(req);

// Position the loader object
loader.x = 14;
loader.y = 14;
loader.width = 731;
loader.height = 451;
loader.alpha = 1;

// Now add the loader object to the stage
addChild(loader);

// Turn loading bar visibility on
mcLoadingBar2.visible = true;
mcLoadingBarBorder.visible = true;
loadingBar2.visible = true;

// Check the loading progress of the requested file (the data is stored in 'contentLoaderInfo')
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);

// Run this event handler function every time the event listener is triggered
function checkProgress(p:ProgressEvent):void
{
var percent:int = (p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal) * 100;
loadingBar2.text = String(percent + '%');
mcLoadingBar2.width = percent;

if(percent == 100)
{
removeChild(mcLoadingBar2);
removeChild(mcLoadingBarBorder);
removeChild(loadingBar2);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, checkProgress);
}
}

Object Loader Loaded And Not Loading
hi, fancy title eh? hehe


anyhow, got a Q...

I loaded 5 JPG's into specific locations of an array via the URLRequest. So now when I trace my array:


ActionScript Code:
trace(getXMLlinkArray);
//[object Loader],[object Loader],[object Loader],,,,,,,,,,,,,,,,,[object Loader],[object Loader]

then later I'm looking to see if an index in an array (i.e., 10) is null and if it is, then I load it with another image. However, if NOT, then I want to take the existing [object Loader] and shove it into another array filled with sprites.


ActionScript Code:
var xmlImgHolder:Sprite;
var imgRotationHolder:Sprite;
var spriteHolderArray:Array = new Array();
var xmlImgHolder:Number = 0;

xmlImgHolder = new Sprite();
xmlImgHolder.addChild(getXMLlinksArray[imgHideRight]);
spriteHolderArray.splice(imgHideRight,1,xmlImgHolder);
imgRotationHolder.addChild(spriteHolderArray[imgHideRight]);

note: imgRotationHolder holds 5 xmlImgHolder's


THE PROBLEM: when I scan getXMLlinksArray and see that its NOT null, and i try to addChil to xmlImgHolder and then to spriteHolderArray, I just get a blank space.

The debuger is showing that spriteHolderArray contains some loader info and the appropriate URL up until I load it with the existing loader from getXMLlinksArray. Then it says it doesn't have any conentedLoadedInfo. Any ideas?

Adding Properties To A Loader Object
In theory a loader object inherits "object" for which you can add properties dynamically.
But you can't do that with a loader object...
Is this true?
//try to add a property "goobers" to loader object...
var pictLdr:Loader = new Loader();
var pictURL:String = "banana.jpg"
var pictURLReq:URLRequest = new URLRequest(pictURL);
pictLdr.goobers="goobers" //this fails
pictLdr.load(pictURLReq);
this.addChild(pictLdr);

Problem Loading In SWF Into Loader Object
Hi,

I need help (typical tight deadline so any help appreciated).

I have a Flash movie and on Frame 1 is my preloader, and on Frame 2 is a movieclip which has one frame within it.

The Movieclip then does some animation via AS3 and then creates a loader object and adds it to the display list. The AS3 code then attempts to load another SWF into the loader object (the SWF is in the same folder as the parent SWF).

I have a preloader that checks the loading of the loader object and that is running fine, but the SWF just doesn't load?

I don't know if this has anything to do with the line "var req:URLRequest = new URLRequest("Home.swf");" and the fact that im loading the SWF into the loader object which is within a movieclip?

My code for creating the loader object is as follows....









Attach Code

// First request the file
var req:URLRequest = new URLRequest("Home.swf");

// Next create a loader object
var loader:Loader = new Loader();

// Then tell the loader object to load the requested file
loader.load(req);

// Position the loader object
loader.x = 14;
loader.y = 14;
loader.width = 731;
loader.height = 451;
loader.alpha = 1;

// Now add the loader object to the stage
addChild(loader);

// Turn loading bar visibility on
mcLoadingBar2.visible = true;
mcLoadingBarBorder.visible = true;
loadingBar2.visible = true;

// Check the loading progress of the requested file (the data is stored in 'contentLoaderInfo')
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);

// Run this event handler function every time the event listener is triggered
function checkProgress(p:ProgressEvent):void
{
var percent:int = (p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal) * 100;
loadingBar2.text = String(percent + '%');
mcLoadingBar2.width = percent;

if(percent == 100)
{
removeChild(mcLoadingBar2);
removeChild(mcLoadingBarBorder);
removeChild(loadingBar2);
loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, checkProgress);
}
}

How To Reference Loader Object Through Listener?
How do I reference Loader object through a listener?
for example:

ActionScript Code:
function Main():void{    var loader:Loader = new Loader();    loader.load(new URLRequest("image.jpg"));    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadCompleted);}function onLoadCompleted(e:Event):void{     //I have no access to loader here.    //How would i access it? So i could reposition, rotate, etc.     //ie. loader.x = 50;}

Tell Loader Object To Stop Loading?
how do I know if a Loader is loading something, and if it is, cancel/unload what it is doing and go back to it's initial state..

How Do I Make A Loader Object Into A Button?
I want to make a Loader object become a button. I am not sure how to give the Loader object button properties.
this is where I'm at:
Code:

var myArray:Array = new Array('zero.swf','one.swf','two.swf','three.swf');
for (var i:uint=0; i<myArray.length; i++) {
                var contentInitializeLoader:Loader = new Loader();
      contentInitializeLoader.name='containerMC_'+(i);
      myContent.addChild(contentInitializeLoader);
urlString=myArray[i];
contentInitializeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentInitializeLoaded);
      contentInitializeLoader.load(new URLRequest(urlString));

function contentInitializeLoaded(e:Event):void {
trace('loaded');
var theMC=myContent.getChildAt(0);

// make theMC become a button

}



in AS 2, I would have done it like this:
Code:


theMC.onPress=function(){
trace(this.name);
}



thanks for any help.

Aubrey

Problem Loading SWF Into Loader Object
Hi,

I need help (typical tight deadline so any help appreciated).

I have a Flash movie and on Frame 1 is my preloader, and on Frame 2 is a movieclip which has one frame within it.

The Movieclip then does some animation via AS3 and then creates a loader object and adds it to the display list. The AS3 code then attempts to load another SWF into the loader object (the SWF is in the same folder as the parent SWF).

I have a preloader that checks the loading of the loader object and that is running fine, but the SWF just doesn't load?

I don't know if this has anything to do with the line "var req:URLRequest = new URLRequest("Home.swf");" and the fact that im loading the SWF into the loader object which is within a movieclip?

My code for creating the loader object is as follows....

Code:

// First request the file
         var req:URLRequest = new URLRequest("Home.swf");
      
      // Next create a loader object
         var loader:Loader = new Loader();
      
      // Then tell the loader object to load the requested file
         loader.load(req);
         
      // Position the loader object
         loader.x = 14;
         loader.y = 14;
         loader.width = 731;
         loader.height = 451;
         loader.alpha = 1;
         
      // Now add the loader object to the stage
         addChild(loader);
         
      // Turn loading bar visibility on
         mcLoadingBar2.visible = true;
         mcLoadingBarBorder.visible = true;
         loadingBar2.visible = true;
      
      // Check the loading progress of the requested file (the data is stored in 'contentLoaderInfo')
         loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, checkProgress);
      
      // Run this event handler function every time the event listener is triggered
         function checkProgress(p:ProgressEvent):void
         {
            var percent:int = (p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal) * 100;
            loadingBar2.text = String(percent + '%');
            mcLoadingBar2.width = percent;
            
            if(percent == 100)
            {
               removeChild(mcLoadingBar2);
               removeChild(mcLoadingBarBorder);
               removeChild(loadingBar2);
               loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, checkProgress);
            }
         }

Loader Object Reference From MovieClip
Good afternoon coders. I'm trying to reference a loader Object on the maintime line from within a MovieClip. More clearly, when I press one of my buttons (myCars or myVideos) I need my transition movieclip named container to play. Once the movieclip reaches a particular frame, I need the code in that frame to run.


First, here's the code on the main timeline:


import flash.display.*;


var my_loader:Loader = new Loader();
addChild(my_loader);

var container:blue=new blue();
container.name = "myContainer";
container.x=10.0;
container.y=74.0;
this.addChild(container);


var lastLoaded:String;

myVideos.addEventListener(MouseEvent.MOUSE_DOWN, loadTheBaby);
myCars.addEventListener(MouseEvent.MOUSE_DOWN, loadTheCars);


function loadTheBaby (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay("motivate");

}
}

function loadTheCars (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay("motivate");

}
}

Now, here's the code I need to run when the movieclip named container reaches a certain frame:

stop();

//lastLoaded=e.currentTarget.name;
my_loader.load(new URLRequest(lastLoaded+".swf"));
my_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);

function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(my_loader);
gotoAndPlay("closeup");
}



Here are the error messages:


1120: Access of undefined property my_loader.
1120: Access of undefined property lastLoaded.


the variable lastLoaded is on the main timeline, and the loader Object my_loader is also on the main timeline. So, I believe I need to reference the loader Object and the lastLoaded variable on the main timeline from within a movieclip. I tried root.my_loader; I tried parent.my_loader to no avail. I even tried to put the loader object and the lastLoaded var in the movieclip and ran into a laundry list of errors. Is there a new way to access objects and variables on the main timeline from within a movieclip? Please steer me in the right diirection. Thanks for reading.


xFLASHSTUDENTx

Sprite/Movieclip ButtonMode Question.
buttonMode is Sprite exclusive, correct? So is there any way to get a hand over my movieclips... Except by using a custom cursor?

I assume I can't place a movieclip inside a sprite. And this... I don't think this will work...

var newButton:Sprite = new menuButton();
newButton.buttonMode = true;

Custom Class Problem With ButtonMode
Hi fellow designers/ developers,

I created a class that displays text with added effects to it receiving string as its required parameter. It is extended to Sprite by default however when I made it clickable by adding MouseEvent and assigning its buttonMode to true, the useHandCursor won't work even if I switch it to true (I know its default is true once buttonMode is true).

I tried tracing the problem through the MouseEvent handler by tracing the event.target and it traces an [object Textfield] instead of my custom class. Weird because I'm using my class in setting the buttonMode and useHandCursor properties. This custom class has a TextField inside it and when I tried removing that TextField in the class the useHandCursor works. I find this weird cause I already extended my class to Sprite so why in the world would it target the TextField inside it which is btw a private variable?

Any help or suggestions would be highly appreciated. Thanks!

How/may I Duplicate Or Clone The Contents Of A Loader Object?
I want to load some .swf files using the Loader class. I'm all set with that and got the image on screen but I wish to have multiple instances of it. Do I have to reload one for each that I intent on using?

For example say I'm attempting to load a power up's graphic from an .swf (i'll call it ex.swf). I load it and then put the image I loaded into the power up. But then I also want to have another power up of the same type somewhere else, and I want to use that same graphic. Neither adding the loaded ex.swf's contents or simply assigning the contents to a child of the power up will work obviously. So do I have to load a new copy every single time i want a new one, or can I just clone/duplicate the contents?

Elsewise, is there another way I should be doing this? I mean I know it must be common for games to have 100's of copies of the same graphic being used by different things, yet If I try to preload the amount I'd need it's not exactly flexibly and if I load them as I need them it seems bad practice.. i dunno, let me know what you guys do,
Thanks,
Bobby

Duplicate Image Loaded Into Loader Object
I realize that I have to use the Loader object to load an external image. The problem I am having with the loader Object is that it doesn't support the addChild methods. Please correct me if I'm wrong. An example.

var sprite:Sprite = new Square(); //imagine a square class that draws a Square
var loader:Loader = new Loader("pic.jpg");

loader.addChild(sprite); //gives an error
//supposedly because the Loader object can only have one child which is pic.jpg

I am in a situation where I want to duplicate the picture that I have loaded into the Loader object, so I can have two instances on the stage doing different things. How would I do that?

also, I've tried doing something like this:

var loader2:Loader = new Loader();
loader2 = loader; //also give an error, because the loader get's something from a URL

Hopefully that's enough info to go on. THANKS!

Problem With Loader Object, Some Users Donīt See The Content
Iīm having a weird problem where a Flash is loading another swf object through the a Loader object. For a certain group of users (in a different location), this swf does not load, and no error message or anything is returned.

For me and others in my office, this works without a hitch. Iīve tried adding various event listeners to the Loader, but it appears that for these people no events are fired. The other content in the main swf works just fine. This does not appear to be caused by firewall/adblockers/popup blockers, etc.

Iīm fairly new to Flash development, and I really have no idea where to start debugging this. Anyone ever experienced something like this? The swf that is supposed to be loaded is a loader itself, which again loads another, final swf. Everything is served through a webpage, so itīs really weird to see this inconsistent behaviour.

If anyone can give me some tips on where to start, it would be greatly appreciated.

Preloader For Loader Object And Caching Questions
Guys.
I have a simple flash widget that i built that works like a small image gallery. It has a couple of tabs so that if you click on tab 1 you go to frame 1 and so on and so forth.

The tricky part is that I'm using a Loader to load the image for each frame.
Its very fast on my computer but when its hosted, I imagine there will be a delay as the image gets loaded. Because of that I want to add a simple preloader to the image (% loaded in top left corner).

I'm not sure how to go about this ...

I also wondered if I could get any technical link or insight into how flash caching works. I develop in PHP, .NET etc so don't be afraid to bust out the complicated version of things.

Thanks

Creating Buttons - Buttonmode Vs Actual Button?
OK, i've done this various ways. Usually it would be in an actual MC on the stage, but I have a goal to make a site in all AS.

I simply want text with maybe shape background.

My methods:

1st way: create background:shape, then a Textfield over it. Then stick those in a new Sprite, and make the Sprite buttonmode true. But it seems the textfield cancels out the buttonmode..

2nd way: create a sprite, add textfield, then add an actual button over it, but since there's not really a button class, I'd have to link one in the library, which I don't want to do.

Dynamic Text Is Jacking Up My ButtonMode = True
Okay, today I am making my first ALL AS3 site. I guess I am going to have to get used to coming here everyday to get answers instead of trying to give them...cool feels like the old days. Well, here it goes:

I have a MC that has a rectangle for a background and a dynamic textField on top of it which I set in it's Class. In that Class I also set the buttonMode to true so I get a hand cursor when the user mouses over the button. The problem is that when I mouse over the background I get the hand cursor just fine but I lose it when I mouse over the dynamic text. Anyone ran into this yet?

Thanks, Dvl

ButtonMode Doesn't Work On Extended Sprite
Hey guys,

I've extended the Sprite class to create a button. The button class adds a custom Sprite from the FLA library as the graphic.

When I try to do
ActionScript Code:
button.buttonMode = true;
nothing happens.

I've tried it inside the button class itself and in the doc class code but no luck. Does anyone know why this is?

Thanks in advance.

P.S. I know the solution of wrapping the button in a container Sprite, I just want to know why buttonMode won't work on an extended Sprite.

ButtonMode & MouseChildren & Scrollable Content :: Confused
Hi,
I've been working on simple Scroller and I'm getting stranges problems

what I need is like this :: http://www.layoutgalaxy.com/html/htm...er49-page1.htm except its Vertical

OK,
this is my code:


PHP Code:



package{ import flash.display.Sprite;  import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldAutoSize  import flash.events.MouseEvent;  public class Content extends Sprite {  private var label:TextField;   public function Content()  {    var menu:Sprite = new Sprite();    for (var i:uint = 1; i <= 15 ; i++)   {    var item:Sprite = new Sprite();    var item_lbl:TextField = new TextField();    item_lbl.text = "item " + i;    item.buttonMode = true;    item.mouseChildren = false; // !!    item.addEventListener(MouseEvent.CLICK , clickHandler);    item.addChild(item_lbl);    item.y = i * (item_lbl.textHeight + 5)    menu.addChild(item);   }            addChild(menu);    menu.graphics.beginFill(0xFF9900);   menu.graphics.drawRect(0,0,100,menu.height);  }   private function clickHandler(evt:MouseEvent)  {   trace( evt.target +" clicked");  } }} 





PHP Code:



package { import flash.display.Sprite; import flash.display.DisplayObjectContainer;  import flash.events.Event; import flash.events.MouseEvent;    public class Scroller extends Sprite {  private var _content:DisplayObjectContainer;  private var _mask:Sprite;  private var _hitarea:Sprite;   private var _scrollAmount:Number = 0;  private var _scrollAcceleration:Number = .4;  private var _scrollDirection:int = 1;   public function Scroller(content:DisplayObjectContainer,h:Number,w:Number)  {   _content = content;    _mask  = createRect(h,w);   _content.mask = _mask;    _hitarea = createRect(h,w);   _hitarea.alpha = 0;    addChild(_hitarea);   addChild(_content);   addChild(_mask);    addEventListener(MouseEvent.MOUSE_MOVE,checkScroll);   addEventListener(MouseEvent.MOUSE_OUT,stopScroll);  }   public function get changableElements():Array  {   return [_mask,_hitarea];  }   private function createRect(h:Number,w:Number):Sprite  {   var sprite:Sprite = new Sprite();   sprite.graphics.beginFill(0xFF0000);   sprite.graphics.drawRect(0,0,h,w);   return sprite;  }   private function checkScroll(evt:MouseEvent)  {   var correct:Boolean = false;    if(mouseY > _mask.y  && mouseY - _mask.y < 30)   {    correct = true;      _scrollDirection = 1;   }   else if(_mask.height > mouseY  && _mask.height - mouseY < 30)   {    correct = true;       _scrollDirection = -1;   }   if(correct)   {    _scrollAmount = 0;    addEventListener(Event.ENTER_FRAME, doScroll);    }   //trace(correct)  }   private function stopScroll(evt:MouseEvent)  {   removeEventListener(Event.ENTER_FRAME, doScroll);    addEventListener(MouseEvent.MOUSE_MOVE,checkScroll);  }   private function doScroll(evt:Event)  {   var deff:Number = 0;   if(_scrollDirection == 1)   {    if(_content.y + _scrollAmount * _scrollDirection > _mask.y)    {     _content.y =  _mask.y;     stopScroll(null);     return;    }    deff = mouseY - _mask.y;    if(!(mouseY > _mask.y  && deff < 30))    {     stopScroll(null);     return;    }   }   else   {    if( _content.y  + _scrollAmount * _scrollDirection  < _mask.y - _content.height + _mask.height)    {     _content.y = _mask.y - _content.height + _mask.height;     stopScroll(null);     return;    }    deff = _mask.height - mouseY;    if(!(_mask.height > mouseY  &&  deff < 30))    {     stopScroll(null);     return;    }   }   removeEventListener(MouseEvent.MOUSE_MOVE,checkScroll);   _content.y   += _scrollAmount * _scrollDirection;     _scrollAmount  += _scrollAcceleration;   } }} 




test :

PHP Code:



addChild( new Scroller(new Content(),100,150) ); 




the problem is when the mouse goes on any item the scroller stop
the strange thing if I remove the item.mouseChildren = false; the scroller works great
but no hand pointer

Any idea?

Thanks,

Controlling 2 Sets Of Bgnd Images Using The Loader Object
Hi,

I am trying to set up having a large background image loaded in on every main menu change on a website (what the client wants)

I am trying to use 2 versions of the loader component (i have version 8 pro) so I can 'cross fade' the images when they change by changing their depths etc. The problem is it works 90% of the time, here is the code:

Code:
var active_background:String = "my_ldr_A";
var inactive_background:String = "my_ldr_B";
var background_path:String = "images/background01.jpg";
//
this.createClassObject(Loader, "my_ldr_A", 2);
my_ldr_A.setSize(955, 600);
this.createClassObject(Loader, "my_ldr_B", 1);
my_ldr_B.setSize(955, 600);
//
function onEnd() {
trace("at end");
_root[active_background].addEventListener("progress", loadListener);
_root[active_background].addEventListener("complete", loadListener);
_root[active_background].contentPath = background_path;
}
//
var loadListener:Object = new Object();
loadListener.progress = function(eventObj:Object) {
trace("The image is "+_root[active_background].percentLoaded+"% loaded into "+active_background);
//here will go loader bar code
};
loadListener.complete = function(eventObj:Object) {
trace("active_background "+active_background+".depth = "+_root[active_background].getDepth());
trace("inactive_background "+inactive_background+".depth = "+_root[inactive_background].getDepth());
my_ldr_B.swapDepths(my_ldr_A);
//
_root[active_background].removeEventListener("progress", loadListener);
_root[active_background].removeEventListener("complete", loadListener);
//
var tempString:String = inactive_background;
inactive_background = active_background;
active_background = tempString;
};
the onEnd() function is called on the end of a tween, and even when it doesnt work the trace - trace("at end"); still traces out.

I am fairly new to objects n listeners etc so I would really appreciate some help here.

Name Property Of Loader Object Lost In CLICK Event.
PHP Code:



private function loadIcons():void{
            count = 0;
            iconArray = new Array();
            for(var i:uint = 0; i < menuArray.length; i++){
                loader = new Loader();
                loader.contentLoaderInfo.addEventListener(Event.INIT, placeIcons);
                loader.load(new URLRequest("assets/icons/" + menuArray[i] + "_icon.swf"));
            }
        }
        
        private function placeIcons(event:Event):void{
            iconArray[count] = (loader.content as MovieClip);
            var loadedContent:MovieClip = (loader.content as MovieClip);
            //loadedContent.play(); needed for later to play ani.
            iconArray[count] = loadedContent;
            iconArray[count].addEventListener(MouseEvent.MOUSE_DOWN, menuSelected);
            addChild(iconArray[count]);
            count++;
        }
        
        private function menuSelected(event:Event):void{
            //addChild(loader);
            trace(event.target.name);  //PROBLEM GETTING THE INSTANCE NAME OF THE BUTTON PRESSED!!!! Look into
        }




Well, hard title.. sorry.

the object is to load a couple of swf's which serves as icons in a menu. I place these in an array so I can reference them later, then when clicked I need to know the id, name or anything about that swf to load the appropriate page which goes with the icon swf.

The problem is that even after I make the coercion to MovieClip on the "loadedContent" I am not allowed to set the "loadedContent.name = "instance name"" and no matter what I try all I get in the menuSelected function is "instance27" or what ever the player calls it at runtime..

I am quite sure I did this a thousand times, but now it does not work?

Thanks for any help given

Flash Bug With Loader Object When User's PC Has Mcafee Installed
Flash 8, windows XP SP2, latest flash player, IE 7
Doesn't matter the PNG image's actual size, the loaded image size will always be width 77, height 107. This bug will not show in firefox, only in IE.
After investigation, the cause of it is because the user PC has mcafee installed. When it is uninstalled or completly disabled( not in itselves control panel). The problem will be solved. Not sure if other anti-virus softwares will cause the same problem







Attach Code

tShirt[upload.side].tShirtImageLoader.scaleContent=false;
subPanes_1[upload.side].DesignUploaded.selected=true;
tShirt[upload.side].tShirtImageLoader.autoLoad=false;
tShirt[upload.side].tShirtImageLoader.contentPath = "http://" + domain + webRoot + "/_images_tshirts/tshirts_temp/" + upload.side + "/lo/" + tShirt[upload.side].imageNameLo;
tShirt[upload.side].tShirtImageLoaderListener = new Object();
tShirt[upload.side].tShirtImageLoader.addEventListener("complete", tShirt[upload.side].tShirtImageLoaderListener);

tShirt[upload.side].tShirtImageLoader.load();
tShirt[upload.side].tShirtImageLoaderListener.complete = function(eo) {

Anyone Have Problems With The Loader Component .complete Event Object?
I've found a bug with the .complete event object. The total variable with this object does not react property if there is a delay in downloading the requested image in IE.

Has anyone else ran into this problem??

The below code will seem to work fine, until you put a bandwidth limiter on port 80, or attempt to proxy the image through a script, then the following will occur:

1. The flash movie sends a get request for the image:
GET some.jpg HTTP/1.1
Accept: */*
x-flash-version: 8,0,22,0
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1)
Host: 10.30.1.161
Connection: Keep-Alive


2. The Loader .complete function will fire and the 'total' variable in the event object will be -1 (failure).

3. The server will then respond with:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: image/jpeg
Content-Length: 110559
Date: Mon, 16 Oct 2006 19:09:13 GMT


Flash doesn't even attempt to wait for a response from the server.

This is horrible because there is no other way i can determine if there was an error while the image downloaded.

The time out, waiting for the response is very very low. We have only been able to reproduce this in IE with a bandwidth limiter. Firefox doesn't seem to repoduce the error.








Attach Code

import mx.controls.Alert;
import mx.utils.Delegate;
//Create loader instance.
this.createClassObject(mx.controls.Loader, "my_ldr", 10);

var poLoaderListener = new Object();
poLoaderListener.oScope = this;
poLoaderListener.complete = Delegate.create(this, function (oEvent)
{
mx.controls.Alert.show(oEvent.total);
});

poLoaderListener.progress = function() {};
my_ldr.addEventListener('complete', poLoaderListener);
my_ldr.addEventListener('progress', poLoaderListener);

my_ldr.load("http://www.bbcanada.com/pics/6676n.jpg");

TypeError: #1009 Null Object Reference And A Loader
Hi,

I'm having some trouble with the stage in AS3 when loading a swf into another swf.

I have a loader swf loading a swf with a document class which imports a few other classes. A sample from one of those imported classes follows:


Code:
// constructor
function ModelInfo() {
if (!allowInstantiation) {
throw new Error("Error: Instantiation failed: Use ModelInfo.getInstance() instead of new.");
} else {
createMouseOverHeading();
createMouseOverSubHeading();
createMouseOverDetails();
}
}
public static function getInstance(input:Stage):ModelInfo {
if (instance == null) {
myStage = input;
allowInstantiation = true;
instance = new ModelInfo();
allowInstantiation = false;
}
return instance;
}
As soon as the progress handler traces that the loader has loaded the entire swf (but before the init handler gets executed) I receive 1009 null object reference errors everywhere the stage is accessed.

Now.. unfortunately, general confusion does not make for a very good question...so,

Should the "addchild" for the loaded swf be on on the loader's onComplete handler, or somewhere else?
I've read about "ADDED_TO_STAGE" in several places, but how can I incorporate this into the above code?
Should the swf that is loaded compile properly on it's own to work with the loader?
Can anyone refer a good article that explains the problem I'm having? I've already tried several and I'm not confident that I understand it.

Thanks in advance

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