Sprite MouseChildren Not Working
Very basic yet very difficult for some reason. I have a container Sprite, that hold many sprites inside it. I need at least one of the children sprites to works like a button. I've done this a million times before but not within a container. Anyone know what else I can do to make this work? I know I'm missing something or else Sprites wouldn't have the mouseChildren property.
Code: var __container:Sprite = new Sprite(); __container.mouseChildren = true; addChild( __container );
var insideButton:Sprite = new Sprite(); insideButton.buttonMode = true; insideButton.addEventListener( MouseEvent.CLICK, whatever ); __container.addChild( __insideButton ); Also assume both sprites are just simple boxes.
FlashKit > Flash Help > Actionscript 3.0
Posted on: 03-10-2008, 02:07 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Sprite.removeChildAt(i) Not Working
Any idea why the removeChildAt loop below isn't working?
for(var i:int=0;i<fields.numChildren-1;i++)
{
fields.removeChildAt(i);
}
I've been having some odd results, such as if I test if(child is TextField) removeChild(child), then some of the TextField children are removed, but not all.
[Fx] DragEvent On Sprite - Not Working
Is it possible to have the drag/drop area as a Sprite?
ActionScript Code:
var spr:Sprite = this.rawChildren.getChildByName(cd.target) as Sprite;spr.addEventListener(DragEvent.DRAG_DROP,doDragDrop);spr.addEventListener(DragEvent.DRAG_ENTER,doDragEnter);spr.addEventListener(DragEvent.DRAG_OVER,doDragOver);
None of these events trigger, but if I try it as a canvas it works. So can I conclude that the DragManager doesn't support rawChildren?
Unloadmovie In Flash Sprite In Director Not Working
hello;
I originally posted this question in Director Online User's Group ( DOUG ) since it is a Director question, but I believe that it may be a fair question here as well;
I have a flash sprite/swf on the stage of a Director MX 2004 application; the flash sprite/swf has two buttons and a handler for each:
button A : triggers a _root.empty_mc.loadMovie ( a_URL ) // thanks CyanBlue for the help earlier;
button B : triggers a _root.empty_mc.unloadMovie( a_URL )
this works as expected in a stand-alone .swf;
however, once integrated into Director as a sprite, the button B event fails ( button A works as expected );
any thoughts?
thanks
dsdsdsdsd
Con.mouseChildren = False;
hallo!
well, is it able to use
con.mouseChildren = false;
with something like
con.getChildByName("hoch");
so that not all of the childreens are blocked, only a few of them?
i do not want to use removeEventListener!!
thank's
Flex MouseChildren Workaround
Hello, I have a problem:
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" >
<mx:Script>
<![CDATA[
import flash.events.MouseEvent;
import mx.controls.Alert;
private function open():void{
tendina.stop();
tendina.duration=1000;
tendina.xFrom=menuslide.x;
tendina.xTo=0;
tendina.play();
}
private function close():void{
tendina.stop();
tendina.duration=1000;
tendina.xFrom=menuslide.x;
tendina.xTo=-240;
tendina.play();
}
public function clicked(event:MouseEvent):void{
Alert.show(event.currentTarget.id);
}
public function init():void{
var Buttons:Array = menus.getChildren();
menuslide.addEventListener(MouseEvent.CLICK, clicked);
for each( var s:Button in Buttons){
s.addEventListener(MouseEvent.CLICK, clicked);
}
}
]]>
</mx:Script>
<mx:Move id="tendina" target="{menuslide}" />
<mx:Panel id="pannello" layout="absolute" title="STOCAZZO.com"
width="95%" height="95%" paddingTop="5" paddingLeft="10"
paddingRight="10" paddingBottom="5" >
<mx:Canvas id="menuslide" backgroundColor="#CBCBCB" borderStyle="solid" x="-240"
mouseChildren="false" mouseOver="open();" mouseOut="close();" initialize="init();">
<mx:HBox id="menus" width="100%">
<mx:Button id="Button1" label="Ciao1"/>
<mx:Button id="Button2" label="Ciao2"/>
<mx:Button id="Button3" label="Ciao3"/>
<mx:Button id="Button4" label="Ciao4"/>
<mx:Button id="Button5" label="Ciao5"/>
</mx:HBox>
</mx:Canvas>
</mx:Panel>
</mx:Application>
As you can see I wanna do a menu that "slides" out when mouseover event is activated and then "slides" in when mouseout is activated.
In order to do so, I had to set menuslide.mouseChildren=false because if the mouse is on a button the mouseout is activated.
The problem is that I need to enable the click event on the buttons but I can't. As you can see I even tried using currentTarget but the target remains menuslide and not the buttons.
(sorry for my bad english)
This is the current file: http://dierre.netsons.org/FirstApp.swf
Problem With Bitmaps & MouseEnabled, MouseChildren
Hi all,
I have a custom sprite class like this...
ActionScript Code:
public class GameObject extends Sprite
{
internal var _sprite1:Sprite;
internal var _sprite2:Sprite;
internal var _sprite3:Sprite;
public function GameObject():void
{
_sprite1 = new Sprite;
_sprite2 = new Sprite;
_sprite3 = new ClipFromLibrary();
_sprite3.mouseEnabled = false;
_sprite3.mouseChildren = false;
this.addChild(_sprite1);
this.addChild(_sprite2);
this.addChild(_sprite3);
_sprite1.addEventListener(MouseEvent.CLICK, clickHandler, false, 0, true);
_sprite2.addEventListener(MouseEvent.CLICK, clickHandler, false, 0, true);
}
}
the ClipFromLibrary is a Sprite whose main content is a bitmap with some small vector graphics overlayed. I set the mouseEnabled (& mouseChildren) property of this sprite to false as I don't want the mouse events for _sprite1 & _sprite2 to be obscured by the bitmap, but they still are The bitmap only covers part of the sprites underneath & I still want these areas to be clickable. How?
Many thanks,
PMF
MouseEnabled, MouseChildren And Still ROLL_OUT Is Beeing Propagated
Simple example.
ActionScript Code:
import flash.events.*;
clip.addEventListener( MouseEvent.ROLL_OVER, function( event:Event )
{
trace( "over " );
clip.mouseEnabled = false;
clip.mouseChildren= false;
} );
clip.addEventListener( MouseEvent.ROLL_OUT, function( event:Event )
{
trace( "out " );
} );
Even though mouseEnabled is set to false, still ROLL_OUT is cought. Its propably cause mouse GOES out of the object, but I dont think it should be like this.
Suggestions or ideas how to handle this ? Or at least the true reason
I know that I may place some kind of bool flag in there, but its aint solution for the problem
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,
Loading Sprite Using Loader Need Access To Sprite Type
Hello,
I'm loading a Sprite via a Loader and once loaded I have access to that Sprite via the Loader class. I can manipulate the Sprites alpha, x and y coordinates ect. However, I have a custom function that fades in or out the passed param and it expects a Sprite. When I pass the loaded Sprite (loaded via the Loader class) I get an error:
1067: Implicit coercion of a value of type flash.display:Loader to an unrelated type flash.display:Sprite.
I know that the problem is that it expects a Sprite, but how do I access the Sprite type once the swf is loaded via the Loader?
My Code:
import FadeClip;
var ldrMovieCntr:Loader = new Loader();
addChild(ldrMovieCntr);
var fcLoadedMovie:FadeClip = new FadeClip(); //CUSTOM CLASS
fcLoadedMovie.setClipToFade(ldrMovieCntr); //PASSING IN A TYPE Loader - CLASS EXPECTS A Sprite
Thanks in advanced,
Vic
HELP: Sprite.addChild(NumericStepper) Resizes Sprite To 100x100
If anyone can help me with this, I would be extremely grateful. It's driving me insane.
If I run this code:
Quote:
var mySprite:Sprite = new Sprite();
trace("mySprite 1:", mySprite.width, mySprite.height);
numericStepper = new NumericStepper();
trace("numericStepper 2:", numericStepper.width, numericStepper.height);
mySprite.addChild(numericStepper);
trace("mySprite 3:", mySprite.width, mySprite.height);
I expect this output:
Quote:
mySprite 1: 0 0
numericStepper 2: 80 22
mySprite 3: 80 22
But I get this output:
Quote:
mySprite 1: 0 0
numericStepper 2: 80 22
mySprite 3: 100 100
If instead I do this:
Quote:
mySprite = new Sprite();
trace("mySprite 1:", mySprite.width, mySprite.height);
numericStepper = new NumericStepper();
trace("numericStepper 2:", numericStepper.width, numericStepper.height);
mySprite.addChild(numericStepper);
trace("mySprite 3:", mySprite.width, mySprite.height);
mySprite.width = 80;
mySprite.height = 22;
Then the numericStepper is drawn as if it is squished to 20% its normal height.
If I pre-set mySprite width and height before adding the numericstepper, the trace output is 0,0 after adding it and it is not displayed at all.
Is there some way I can make the sprite only adjust to correctly fit the numericStepper OR resize it afterwards without distorting the numericStepper component?
As I was typing this, I came across this post:
http://www.kirupa.com/forum/archive/.../t-263027.html
Can anyone help me modify that solution for a numeric stepper?
Thanks!
Dynamically Creating Sprite Inside Sprite
I'm having issues going from AS2 to AS3, mainly in this part , creating sprites/movieclips inside other sprites/movieclips, back in the days i could just create an emptymovieclip inside another, and easily locate it (fathermc.childmc), now the issue is i cant really locate the child, and from the research i have been doing i think i cannot have multiple child with the same name.
I need this because i usually work with textfields inside movieclips, and at any given time i will need to change the text on a specific movieclip's textfield, and i'm having some trouble with that for now.
Here is an example code
Code:
import flash.display.Sprite;
import flash.events.MouseEvent;
var circle1:Sprite = new Sprite();
circle1.graphics.beginFill(0xFFCC00);
circle1.graphics.drawCircle(0, 0, 40);
var circle3:Sprite = new Sprite();
circle3.graphics.beginFill(0xFF0000);
circle3.graphics.drawCircle(0, 0, 200);
circle3.alpha = 0.5;
function BuildInside(spr:Sprite) {
var circle2:Sprite = new Sprite();
circle2.graphics.beginFill(0xFFCCC0);
circle2.graphics.drawCircle(0, 0, 60);
circle2.alpha = 0.5;
spr.addChild(circle2);
}
addChild(circle1);
addChild(circle3);
BuildInside(circle1);
BuildInside(circle3);
circle1.x = 530;
circle3.x = 230;
//trace(circle1.x + " OK " + circle1.x);
stop();
i know that putting
Code:
var circle2:Sprite = new Sprite();
, inside a function , it will only be available in that function , but how can i make it available globally, do i need to define all of them in advance at the root ?
in this example i cant reach any of the circle2 inside the other circles, probly because of the var defining inside the function again.
thnx in advance for any help in this issue that has been holding back my AS2-AS3 upgrade
Why Does Sprite.filter Break Sprite.hitArea ?
Check this weird bug:
By adding the dropshadow to the circle, hit area no longer works. If you comment them out they work fine. WTHeck?
Code:
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.filters.DropShadowFilter;
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0xFFCC00);
circle.graphics.drawCircle(0, 0, 40);
var dShadow:DropShadowFilter = new DropShadowFilter();
circle.filters = [dShadow];
var square:Sprite = new Sprite();
square.graphics.beginFill(0xCCFF00);
square.graphics.drawRect(200, 0, 100, 100);
circle.hitArea = square;
square.mouseEnabled = false;
circle.addEventListener(MouseEvent.CLICK, clicked);
function clicked(event:MouseEvent):void{
trace(event.target == circle); // true
trace(event.target == square); // false
}
addChild(circle);
addChild(square);
Sprite And Child Sprite, Click Event On Both
Hello.
I have this menu item, which is a Sprite. The menu item then has several other items, also Sprite, as children. All items have a listener for click events. When I click the parent item, it's all ok, but when I click one of the children, both the child and the parent Sprite's event handler functions are triggered.
How can I stop the parent sprite from responding to the click on the child?
Thanks in advance.
Attach Code
var myParent:Sprite = new Sprite();
var myChild1:Sprite = new Sprite();
myParent.addChild(myChild1);
function click_parent ($event:MouseEvent) {
trace ("parent clicked");
}
function click_child ($event:MouseEvent) {
trace ("child clicked");
}
myParent.addEventListener(MouseEvent.CLICK, click_parent);
myChild.addEventListener(MouseEvent.CLICK, click_child);
//(Clicking myParent)
//parent clicked
//(Clicking myChild1)
//child clicked
//parent clicked
Add Listener When Sprite Hovers Over Sprite
Hi guys,
This is my first time looking for help on these forums so im giving it a go.
I have been trying to find the answer for this for a while with no luck
I have a grid with cells
When i hover over with a mouse it changes the color if the cell .... thats ok
What i want to do is hover over a cell with another object sprite and ofr it also to change color
Is their an event for this or does anyone have suggestions for another option
Thanks for any suggestions.
What i am thing is to substitute MouseEvent.ROLL_OVER for something else that will trigger when an object hovers over.
Some code:
Code:
public function createCell()
{
var temp_cell_object:Sprite = new Sprite();
........
.......
.......
the_cell_object.addEventListener(MouseEvent.ROLL_OVER,setCellBackgroundHighlightOn);
the_cell_object.addEventListener(MouseEvent.ROLL_OUT,setCellBackgroundHighlightOff);
the_cell_object.transform.colorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
return temp_cell_object;
}
private function setCellBackgroundHighlightOn(evt:MouseEvent)
{
evt.target.transform.colorTransform = new ColorTransform(1, 1, .25, 1, 40, 0, 25, 0);
}
private function setCellBackgroundHighlightOff(evt:MouseEvent)
{
evt.target.transform.colorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
}
[CS3] Sprite Collision/gravity Within Another Sprite
I'm doin an assignment based on flash but I jus learnt basic flash bt my assignment has forcen me to script higher than the level tat i had learnt.
This is roughly my idea:
correction: instead of e edge change color when the ball collide it, the ball will change color when it collide with the edges. I'm realli grateful to those who can teach & help me~ My assignment is due in 2 days time on thurs.. Thank you~
Sprite Collision/gravity Within Another Sprite
I'm doin an assignment based on flash but I jus learnt basic flash bt my assignment has forcen me to script higher than the level tat i had learnt.
This is roughly my idea:
correction: instead of e edge change color when the ball collide it, the ball will change color when it collide with the edges. I'm realli grateful to those who can teach & help me~ My assignment is due in 2 days time on thurs.. Thank you~
Cannot AddChilld(sprite) Into Another Sprite?
Hi,
First post woo,
Anyways, I'm quite new to AS3, I worked a bit with AS2 but not to a great extent, and I am now trying to teach myself AS3 (with a little help). I am creating a flash portfolio and so far have got images to import via XML and some other things, but I am stuck at one particular point:
I have an AS file called Statics.as that extends Sprite, it will contain all the code to draw the static elements of the portfolio, so far it draws a rounded rectange with gradient fine.
I then used URLRequest() and URLLoader() to load the XML, and then Loader to load the logo of the portfolio. I can add it to the Sprite now with:
Code:
addChild(logoLoader);
But I want to manipulate the x and y coords first. I initially failed as I tried to position it in the top right of the portfolio using:
Code:
logoLoader.x = 720-logoLoader.width -10
(720 being the width of the portfolio, and 10 being the padding from the right)
This did not work, after tracing logoLoader.width it seems that this property is not given and so tells me the width of the logo is 0. Therefore the x coord of the logo was mostly off the screen.
I then tried putting the logo into its own sprite to manipulate using:
Code:
var logoSprite:Sprite = new Sprite;
logoSprite.addChild(logoLoader);
logoSprite.addEventListener(Event.ADDED,logoComplete);
This didn't throw any errors, so I continued with:
Code:
public function logoComplete(evnt:Event)
{
evnt.target.x = 720-evnt.target.width -10;
trace(evnt.target.x);
}
This gave me an x coord value of 382 which is correct, this would position the logo in the top right hand corner in exactly the place I wanted.
But when I tried adding it as a child to the class, I got an error:
1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display: DisplayObject.
I believe the problem is that I am trying to add a Sprite as a child into a Sprite. As AS3 is quite new to me, I don't see why this should be a problem or a way around it, so my question is; Is what I am doing, the right way of manipulating the position of an external image before it being added to the stage?
Thankyou for your time,
Any reply is appreciated,
Blekk.
P.S.
A new instance of the AS file Statics.as is added to the stage via the DocumentClass.
Here is all the code relevant to the problem if needed:
Code:
package com.fusedDesign.userinterface
{
import flash.display.*;
import flash.geom.*;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;
public class Statics extends MovieClip
{
public function Statics()
{
drawModule();
drawLogo();
}
public function drawLogo()
{
var urlRequest:URLRequest = new URLRequest("com/fusedDesign/folio/xml.xml");
var urlLoader:URLLoader = new URLLoader();
urlLoader.load(urlRequest);
urlLoader.addEventListener(Event.COMPLETE,xmlComplete);
}
public function xmlComplete(evnt:Event)
{
var imagesXML:XML = new XML(evnt.target.data);
loadImage(imagesXML);
}
public function loadImage(xml:XML)
{
var logoLoader:Loader = new Loader();
var logoRequest:URLRequest = new URLRequest(xml.logo.attribute("href")[0]);
logoLoader.load(logoRequest);
var logo:Sprite = new Sprite();
logo.addChild(logoLoader);
logo.addEventListener(Event.ADDED,logoLoaded);
}
public function logoLoaded(evnt:Event)
{
trace("added");
evnt.target.x = 720-evnt.target.width-10;
evnt.target.y = 10;
addChild(evnt.target);
}
}
}
I have removed the code that draws and adds the rounded rectangle.
Store A Sprite In A Sprite?
What is the best thing to do when storing a Sprite to call it later?
- save it to an array ("as Sprite") (I only need to store one value!)?
- save the name as String in a string variable then getChildByName?
- save it in a variable type Sprite?
three ways seam to work fine, really don't know if there is another one, neither which one is more correct.
any ideias?
thanks
What Is A Sprite?
I remember back in the day when the posts in the Newbie forum made sense to me... back when i could help people out by answering their questions. Looks like i've been out of the loop for too long what with all these easy scrolling task bars and sprites. Which brings me to my question... what in the heck is a sprite?
Sprite Isn't Just Pop
Ok, I am dumb. Hopefully someone can clear this up for me.
When people use *sprites* in thier files. (load sprites and whatnot)
what exactly is a sprite?
I know its like movement things, but...what the advantage? How do you use them?
Thanks for any help/clarification
Sprite Help
i want to animate a sprite (an already made .gif) walking from one side to another..
the problem is whenever i import it, by default it shows on the top left part of the screen. So, i move it frame by frame to wherever i want to put it and animate it but then it looks choppy and it isnt smooth at all.
i tried motion tweening it, but then it doesnt animate the .gif anymore.
Sprite Help Plz
How do you get rid of the white BG on the sprite sheets, im new at this and started 2 days ago, but i can make short 1 person films with them...now the white bg is interfering and i want to know how to get rid of it...PLZ help
New Sprite?
i know this is an easy answer but my head is stuck today.
i have a loop...i want it to generate 5 different sprites with 5 different names...
how do i do this and trace the sprites names?
i've been using
ActionScript Code:
spriteName:Sprite = new Sprite()
spriteName.name = "whatever" + num;
but i keep overwriting my sprites...i'm drawing circles in the sprites and when i roll over them they all have the same name!!!
New Sprite
Hi,
I want to create a lot of sprites (in future), for example with array elements:
var mmm:Array = new Array();
mmm[0] = "first";
var mmm[0]:Sprite = new Sprite(); // error
or
mmm[0]:Sprite = new Sprite(); // error
But this gives me an error.
Can somenone give me some advice for this exercise?
Thanks
Odd Sprite.y -=
ok, I'm stumped
I have something like this...
It works ok if d1.y >0 but as soon at it hits 0 it stops.
if I change speed to .1 instead of .01 it works the way it is suppose to
and allows d1 to go into -y. does anyone know what could be wrong here?
I just don't see any reason this should be happening.
Thanks!
Attach Code
var speed:Number = .01;
// d1 is a sprite
this.d1.y -= speed;
AS3.0, Sprite, FP9 .fla's And So On
Ok, let me get the suggestion out of the way. Are there any plans for a AS3.0 section to the forum? It would be really nice to start lumping all the AS3.0 stuff together. Just a suggestion.
Ok I have two questions:
#1. Anyone know how to instantiate a subclass of flash.display.Sprite WITHOUT implementing the iUIComponent interface in Flex 2?
From what I have seen with say senoc's AS3 tip o'the day and others, it seems you are extending the Sprite classes then using the addChild method. That doesn't seem to work in Flex 2 since the addChild's first parameter, even though a DisplayObject, is required to implement the iUIComponent interface. This may be unique to compiling in FB2 though.
#2. Can someone briefly explain to me how some of you are compiling flash player 9 swf's using a fla and AS3.0 classes?
I have been really stuck using the Flex 1.5 & 2 IDE's lately and am out of the loop on this topic. Doing this might just solve question #1.
Thanks folks.
Sprite The Same As A MC
I have noticed in some literature when they discuss SWF's they also talk about sprites. Is that the same as a MC in a SWF?
The secret in education lies in respecting the student. {Ralph Waldo Emerson}.
Sprite Problem
I made a swi file with loads of sprites (50 or so), but when i exported the file into swf and then imported into flash i only see 1 frame and no moving movie. When i tried to copy the rectangle (what was in the sprite) to scene 1, and then exported the file and again imported into flash it works good. But the prob is, these rectangles aint on the same place when i paste them in scene 1 , so is there a way to delete all the sprites and the rectangles stay? (becoz flash 5.0 cant handle sprites)
How Do I Do A Flash Sprite?
Hi Gang,
I have a talking King Tut thumbnail SWF file.
How can I make it a Flash sprite which plays
over an HTML page?
I need to have the HTML page be visible everywhere
except where the Flash thumbnail is.
Thanks
Toby Mack
Follow Another Sprite - AI (pac Man)
Help here .....an ai script...I'm wanting the enemy to follow the hero...on his _x and _y...problem being...it's seems to get confussed...as his _x and _y at the same time are changing..so he can't follow him he just gets stuck on the spot and goes crazy...
how do you read an _x and _y at the same time and effect them both...or am I way of the mark?
I want it to follow like pac man?
would be great if youse could help me out...
code below...
}
onClipEvent (enterFrame) {
if (hitTest(_root.hero)) {
_root.gotoAndPlay("die");
}
hero = _root.hero._x;
hero = _root.hero._y;
// move the hero MC in opposite direction to free him of collision
if (_root.back.hitTest(_x+10, _y, true)) {
_x -= 4;
} else if (_root.back.hitTest(_x-10, _y, true)) {
_x += 4;
} else if (_root.back.hitTest(_x, _y-10, true)) {
_y += 4;
} else if (_root.back.hitTest(_x, _y+10, true)) {
_y -= 4;
}
// works out which direction the hero is in and follows him
if (hero<_x) {
this.gotoAndStop("left");
_rotation = 270;
_x += walk;
} else if (hero>_x) {
this.gotoAndStop("right");
_rotation = 90;
_x -=walk;
}
if (hero>_y) {
this.gotoAndStop("up");
_rotation = 0;
_y += walk;
} else if (hero<_y) {
this.gotoAndStop("front");
_rotation = 180;
_y -= walk;
}
}
VG Sprite For Mac Problem
Hey everyone.... for starters... I am a serious newbie with a mac. (Yes, I know, bad choice, but what r u gonna do??) Anyway, I have become really interested in making Video Game Movies with flash. One problem though, how do u copy a picture from an emulator onto the clipboard for the mac. Then paste it as a gif or jpeg file??? Please, if anybody can help I would really appreciate it!!!!
Sprite Problems
Hi, I just got flash 5 for my computer, hoping to make little movies or games using video game sprites. Unfortunately, it seems when I copy and paste sprites onto flash, it does:
1. Makes the sprite upside-down(I know how to fix)
2. Makes it backwards (ditto)
3. When I make a flash action, it makes the picture VERY jpeggish.
4. The sprite becomes a little blurry
5. It leaves a little stupid white box around the sprite.
Can anyone help me out? I really want to fix #3 the most. It makes my high-quality sprites look like crap.
Button/sprite Help..
OK, i've done my searching, read the manual, looked at other help/faq sites and i still have a head scratchin' problem.
I need to make a few thumbnail images that will load larger images when the user clicks them. I have a basic knowledge of Swish (36 hours) but sprites/buttons seem to be eluding me.
How do i accomplish this?
Scott Russell
www.centricity.ca
Fading Sprite
Ok i have 10 buttons each one bringing up a different sprite. now the problem is say i click on button 1 and it brings up sprite 1 but when i click on button 2 how do i get sprite 1 to disappear? thanks for your help.
Simple Sprite
How would I create a sprite that moves a graphic around in response to the directional keys?
Thanks
Simple Sprite?
Does anyone have a good method for making a graphic move around in response to the arrow keys?? (Flash MX 6.0)
How Do You Use A Sprite Sheet?
I need to use a sprite sheet in one of my movies and I was wondering how you can get the sprites into your movie. Anyhelp would be greatly accepted.
Sprite Movement
I'm making a RPG (i'm a NewB) game and i'm trying to inprove the movements of my characters. I have made sprites facing in 8 different directions, North - NE -East..... When i push the UP button the sprite should be walking and facing to the north. I've mannaged to let the sprite walk to North - E - S and W, but i can't figure out how to make it face in the other directions (NE, SE, SW, NW)
I,m using the following script (this is for the down button)
onClipEvent (enterFrame) {
a = 5;
if (_root._currentframe == 1) {
with (_root.sprite) {
//
// keyboard controls
if (Key.isDown(Key.DOWN)) {
_y += a;
// Facing Direction
this.gotoAndStop(5); <-- (5 is the south facing sprite)
}
}
}
}
What i'm trying to do is make te sprite look North-East by pressing the UP and Right at the same time.
If you know a better script or a site please sent it to me.
Tanx
Can We Add Sprite In Swish
hi,
respected sir,
I'm user of swish but very new to flash.so i want to know that can we add sprites in flash 5 if yes please tell me how is there any tutorial about this ?
can we add swf files as like we add in swish and .gifs ??
thanks
A-Ghani
Sprite Trouble
I want to add a sprite as the main character instead of that guy in this RPG template I found on the site.
http://www.flashkit.com/movies/Games...9072/index.php
The only problem is, whenever i add the sprite it comes out as really really small. The thing is, when i add the same sprite to a blank flash document its fine. Also, Manually making the all the walking sprites the exact same size so it doesnt look bad is a real chore (even if im using onion layers.) So, can someone please help?
By the way if you want to know what sprite I am trying to use it is the mario walking animation found here:
http://www.gsarchives.net/index2.php...evel1=playable
Thanks!
Scroll W/ Sprite
Ok so I want to have the window follow the spirit in the middle but i have no idea how to do it.
What i mean is how do i make a scrolling game that follows the character. so that the screen follows the sprite.
A good example of what I'd like is
http://mofunzone.com/online_games/sky_boarder_iii.shtml
In case you were wondering I'm using Flash MX
2004 pro.
Sprite Problems
I downloaded some pictures of link, Then used the pictures as sprites. But there is a white outline around him. Should I trace the bitmap?
(note:still working on drawing backrounds.)
deluxecentral.tripod.com/sitebuildercontent/sitebuilderfiles/linkremix.swf
is the site where it is located.
[f8] Sprite Actionscript
I can't quite get this sprite animation to work. Everything is fine except walking diagonally. Here is a link to the animation:
http://myfilestash.com/userfiles/pli...undSprites.swf
The following code is on the movie clip on the timeline. It takes the movie clip to a certain frame with another movie clip of him walking in a certain direction.
code:
onClipEvent (enterFrame) {
if (Key.isDown(Key.DOWN)) {
gotoAndStop("down");
move(0,s);
} else if (Key.isDown(Key.UP)) {
gotoAndStop("up");
move(0,-s);
} else if (Key.isDown(Key.RIGHT)) {
gotoAndStop("right");
move(s,0);
} else if (Key.isDown(Key.LEFT)) {
gotoAndStop("left");
move(-s,0);
} if (Key.isDown(Key.DOWN) && Key.isDown(Key.LEFT)) {
gotoAndStop("downLeft");
move(-h,-v);
} if (Key.isDown(Key.UP) && Key.isDown(Key.RIGHT)){
gotoAndStop("upRight");
move(h,v);
} if (Key.isDown(Key.DOWN) && Key.isDown(Key.RIGHT)) {
gotoAndStop("downRight");
move(h,-v);
} if (Key.isDown(Key.UP) && Key.isDown(Key.LEFT)) {
gotoAndStop("upLeft");
move(-h,v);
}
}
And I put this code on the movie clips inside the main movie clip to make them stop playing:
code:
onClipEvent (enterFrame) {
if (Key.isDown(Key."key")) {
play();
} else {
stop();
}
}
Any help would be greatly appreciated.
Unrotating A Sprite
I crated a car game that when the car crashes into the wall it relocates back to the beginning of the track.
I am able to get it in the correct _x _y position, but, I can't get the car facing the correct way. It faces the direction that it had crashed into the wall.
The tough part is the car doesn't actually crash, after it hits into the wall it instantaneousely starts from the beginning (while playing a short crash sound)
So, I don't think I can do the visible = false because I won't be able to get it to play the crash sound
If there is anything you can do to help, or have any ideas I would really appreciate it. Thank you!
MX Need Sprite Shooting Help
ok, i need some help with making my sprite shoot a goddam bullet.
Here is my current code (taken from a tutorial here but ive added some stuff):
onClipEvent (load) {
gravity = 10;
scale = _xscale;
walkSpeed = 10;
maxjump = 2;
}
onClipEvent (enterFrame) {
if (air == true) {
_y += gravity;
state = 3;
}
if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
_x -= walkSpeed;
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
_x += walkSpeed;
_xscale = scale;
}
if (_root.platforms.hitTest(_x, _y, true)) {
air = false;
} else {
air = true;
}
if (Key.isDown(Key.SPACE) && jump == true) {
_y -= jumpSpeed;
}
if (air == false) {
jump = true;
jumpcount = 0;
jumpSpeed = 22;
}
if (Key.isDown(Key.SPACE)) {
jumpcount += 1;
}
if (jumpcount>maxjump && jumpSpeed>-2) {
jumpSpeed -= 2;
}
if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) && _currentframe<4 or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65) && _currentframe<4) {
state = 1;
}
if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) && _currentframe<4 or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65) && _currentframe<4) {
state = 2;
}
if (!Key.isDown(65)) {
gotoAndStop(state);
}
_root.statetxt = state;
}
onClipEvent (keyUp) {
if (Key.getCode() == 83) {
jump = false;
}
}
can anybody help?!?!?!
Creating A Sprite
ok a brief description of what I am doing. I am trying to use a poser figure in flash. I have created a crane (bird) in poser and animated it to make its wings flap. I then rendered it by frame as pings images and imported them into flash. I built a movie so that each frame is played in sequence and now the bird flaps its wings in flash. How do I turn that movie into one animated sprite that I can then move into my flash scene and duplicate as many times as I want to make a flock of birds fly across my page?
I tried selecting all the frames, converting to symbol (movie) but the new symbol is locked on the first frame of the animation and the thing wont flap. do I do it as a graphic? please help.
Sprite Movie Help
Ok so i'm making a sprite movie in Flash. Everythings fine until i do test movie. I see that the sprites look blurred and non-pixelated. Is there a way i can make them look pixelated?
|