开发者

How to make a text event call on a function and how to display images in AS3?

开发者 https://www.devze.com 2023-01-23 16:00 出处:网络
Originally the AS3 script would trace some words for a certain string I typed in the textfield (ti). I want to know how to display and image, instead.

Originally the AS3 script would trace some words for a certain string I typed in the textfield (ti). I want to know how to display and image, instead.

I know in AS2 it was loadMovie but I don't know how to do this in AS3. And would the loadit in the newvid function be the movieclip that changes or something else? (O got that function newvid script off a website.)

ti.border = true
ti.addEventListener(TextEvent.TEXT_INPUT, onInput);

function onInput(event:TextEvent):void {
    if(ti.text.search('happyface')!=-1) newvid;
    else if(ti.text.search('sadface')!=-1) trace ('sadface.jpg');
}

function newvid() {
    var loadit = new L开发者_开发技巧oader();
    addChild(loadit);
    loadit.load(new URLRequest("happyface.jpg"));
}


Loader class lets you load another SWF or Image file. Once loaded your loadit object becomes another display object. You can fix it's position, hide/show it or listen to it's events. Following is a very comprehensive example of using Loader class

http://www.republicofcode.com/tutorials/flash/as3loader/

Also check out the example in Loader documentation for example.


imho you need the Loader class, you should add a listener

loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
loader.load(new URLRequest("norton.swf"));

private function onInit(e:Event):void {
   addChild(loader.content);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消