-
ас3 depth help
package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class test extends Sprite {
private var box,box1,box2,box3,box4,container:Sprite;
private var pictureLoader:Loader;
private var topPosition:uint;
public function test() {
box = new Sprite();
box.x = 30;
box.y = 20;
box1 = new Sprite();
box.addChild(box1);
box2 = new Sprite();
box.addChild(box2);
addChild(box);
init();
}
function init() {
var loader1:Loader = new Loader();
var loader2:Loader = new Loader();
addChild(loader1);//pic1
addChild(loader2);//pic1
loader1.load(new URLRequest("MyPics/pic1.jpg"));
loader2.load(new URLRequest("MyPics/pic2.jpg"));
box1.addChild(loader1);
box1.x=box.x+5;
box1.y=264;
box2.addChild(loader2);
box2.x=50+box1.height+box1.x+15;
box2.y=264;
//===============
box1.addEventListener(MouseEvent.ROLL_OVER, RollOver);
box1.addEventListener(MouseEvent.ROLL_OUT , RollOut);
box2.addEventListener(MouseEvent.ROLL_OVER, RollOver);
box2.addEventListener(MouseEvent.ROLL_OUT , RollOut);
}
function RollOver(event:MouseEvent):void {
topPosition = box.numChildren - 1;
box.setChildIndex(event.target, topPosition);
event.target.scaleX=1.5;
event.target.scaleY=1.5;
event.target.x=event.target.x-5;
event.target.y=event.target.y-5;
}
function RollOut(event:MouseEvent):void {
event.target.scaleX=1;
event.target.scaleY=1;
event.target.x=event.target.x+5;
event.target.y=event.target.y+5;
}
}
}
this is OK
but
package {
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class test1 extends Sprite {
private var box,box1,box2,box3,box4,container:Sprite;
private var pictureLoader:Loader;
private var topPosition:uint;
public function test1() {
container= new Sprite();
container.x = 30;
container.y = 20;
box1 = new Sprite();
container.addChild(box1);
box2 = new Sprite();
container.addChild(box2);
addChild(container);
init();
}
function init() {
var loader1:Loader = new Loader();
var loader2:Loader = new Loader();
addChild(loader1);//pic1
addChild(loader2);//pic1
loader1.load(new URLRequest("MyPics/pic1.jpg"));
loader2.load(new URLRequest("MyPics/pic2.jpg"));
box1.addChild(loader1);
box1.x=container.x+5;
box1.y=264;
box2.addChild(loader2);
box2.x=50+box1.height+box1.x+15;
box2.y=264;
//===============
box1.addEventListener(MouseEvent.ROLL_OVER, RollOver);
box1.addEventListener(MouseEvent.ROLL_OUT , RollOut);
box2.addEventListener(MouseEvent.ROLL_OVER, RollOver);
box2.addEventListener(MouseEvent.ROLL_OUT , RollOut);
}
function RollOver(event:MouseEvent):void {
topPosition = container.numChildren - 1;
container.setChildIndex(event.target, topPosition);
event.target.scaleX=1.5;
event.target.scaleY=1.5;
event.target.x=event.target.x-5;
event.target.y=event.target.y-5;
}
function RollOut(event:MouseEvent):void {
event.target.scaleX=1;
event.target.scaleY=1;
event.target.x=event.target.x+5;
event.target.y=event.target.y+5;
}
}
}
not. Why? Error :1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.displayisplayObject.
-
This is bug Adobe.Answer is
private var container, box,box1,box2,box3,box4r:Sprite;
not
private var box,box1,box2,box3,box4,container:Sprite;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|