English 中文(简体)
AS3 控制儿童电影记录
原标题:AS3 controlling movieclip of children

我从图书馆略去了几部电影片,在电影片片片片片片内,我只想控制它,这里是我的文字。

if (selectDiffText.text == "Collection 1 Easy")
    {
        var c1_easy:cartoonEasy = new cartoonEasy();
        addChild(c1_easy);
        c1_easy.x = 412;
        c1_easy.y = 400;
        TweenMax.from(c1_easy, 0.5, {alpha:0, ease:Expo.easeOut});
    }
    else if (selectDiffText.text == "Collection 1 Medium")
    {
        var c1_medium:cartoonMedium = new cartoonMedium();
        addChild(c1_medium);
        c1_medium.x = 412;
        c1_medium.y = 400;
        TweenMax.from(c1_medium, 0.5, {alpha:0, ease:Expo.easeOut});
    }
else
    {
        trace("ERROR!");
    }

如果改动selectDiffText,上述法律将装上图书馆的特别影片。

var movieList:Array = [cartoonMedium1,cartoonMedium2,cartoonMedium3,cartoonMedium4,cartoonMedium5,cartoonMedium6];

function getRandomMovie():MovieClip
{
    var index:int = Math.floor(Math.random() * movieList.length);
    var mcClass:Class = movieList.splice(index,1)[0];
    return new mcClass();
}
playGame = getRandomMovie();
addChild(playGame);

更不用说,如果将c1_添加到阶段,那么c1_medium也将随意从图书馆中添加1个电影片。

<>playGame mc, I ve mouseTarget.alpha = 0;...how,我能从根层控制吗? c1 - 麻省也有 mo素=0。

问题回答

为方便起见,c1_easy c1_medium 两者都应扩大同一类别。 例如:

class c1_easy extends CartoonGenericClass{[...]}

以及

class c1_medium extends CartoonGenericClass{[...]}

In CartoonGenericClass, you would have the variable mouseTarget. You make this public using the getter/setter:

protected var _mouseTarget:Number;

public function get mouseTarget():Number{
    return _mouseTarget;
}

public function set mouseTarget(value:Number):void{
    // (should probably do some verification on "value" here)
    _mouseTarget.alpha = value;
}

这将使可检索<代码>mouseTarget。 (注:无强调)任何物体均可进入c1_easyc1_medium<>:

c1_easy.mouseTarget = 0;
c1_medium.mouseTarget = .3;

etc. etc. This is standard OOP, so it may be time to crack a doc. HTH!





相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

Red5 Security Tutorial

I am looking for a step by step tutorial on securing Red5 from intrusion. This seems to be a question that comes up alot in a google search, but is never really answered in a way that makes sense to ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

visible property of DisplayObject

For example I have a hierarchy of movie clips. mc1 is a child of mc, and mc2 is a child of mc1. Turns out that when I set mc1.visible = false; mc2.visible stays true. Is that supposed to happen?...